Skip to content

Commit fd4c90f

Browse files
committed
feat(init commit):init commit
0 parents  commit fd4c90f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1413
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild
10+
11+
/.idea
12+

app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/libs

app/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "com.coderqian.chapter2"
7+
minSdkVersion 15
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
27+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.coderqian.chapter2;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.coderqian.chapter2", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.coderqian.chapter2">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
20+
<activity
21+
android:name=".LinearActivity"
22+
android:label="线性布局1 AdapterView">
23+
<intent-filter>
24+
<action android:name="android.intent.action.VIEW" />
25+
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
30+
<activity
31+
android:name=".TableActivity"
32+
android:label="表格布局 TextView/ImageView">
33+
<intent-filter>
34+
<action android:name="android.intent.action.VIEW" />
35+
36+
<category android:name="android.intent.category.LAUNCHER" />
37+
</intent-filter>
38+
</activity>
39+
40+
<activity
41+
android:name=".Linear2Activity"
42+
android:label="线性布局2 ProgressBar">
43+
<intent-filter>
44+
<action android:name="android.intent.action.VIEW" />
45+
46+
<category android:name="android.intent.category.LAUNCHER" />
47+
</intent-filter>
48+
</activity>
49+
50+
<activity
51+
android:name=".RelativeActivity"
52+
android:label="相对布局 ViewAnimator">
53+
<intent-filter>
54+
<action android:name="android.intent.action.VIEW" />
55+
56+
<category android:name="android.intent.category.LAUNCHER" />
57+
</intent-filter>
58+
</activity>
59+
60+
<activity
61+
android:name=".Linear3Activity"
62+
android:label="线性布局3 DatePicker/TimePicker">
63+
<intent-filter>
64+
<action android:name="android.intent.action.VIEW" />
65+
66+
<category android:name="android.intent.category.LAUNCHER" />
67+
</intent-filter>
68+
</activity>
69+
</application>
70+
71+
</manifest>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.coderqian.chapter2;
2+
3+
import android.os.Bundle;
4+
import android.os.Handler;
5+
import android.os.Message;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.widget.ProgressBar;
8+
9+
/**
10+
* @author qianliqing
11+
* @since 2018-09-30 下午2:32
12+
13+
*/
14+
public class Linear2Activity extends AppCompatActivity {
15+
16+
private int[] data = new int[100];
17+
18+
int hasData = 0;
19+
int status = 0;
20+
21+
ProgressBar progress, seek;
22+
23+
Handler handler = new Handler() {
24+
public void handleMessage(Message msg) {
25+
if (msg.what == 0x111) {
26+
progress.setProgress(status);
27+
seek.setProgress(status);
28+
}
29+
}
30+
};
31+
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_linear_2);
36+
37+
progress = findViewById(R.id.progress);
38+
seek = findViewById(R.id.seek);
39+
40+
new Thread() {
41+
public void run() {
42+
while (status < 100) {
43+
status = doWork();
44+
handler.sendEmptyMessage(0x111);
45+
}
46+
}
47+
}.start();
48+
}
49+
50+
private int doWork() {
51+
data[hasData++] = (int) Math.random() * 100;
52+
try {
53+
Thread.sleep(100);
54+
} catch (InterruptedException e) {
55+
e.printStackTrace();
56+
}
57+
return hasData;
58+
}
59+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package com.coderqian.chapter2;
2+
3+
import android.content.DialogInterface;
4+
import android.os.Bundle;
5+
import android.support.v7.app.AlertDialog;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.view.View;
8+
import android.widget.Toast;
9+
10+
import java.util.HashSet;
11+
import java.util.Set;
12+
13+
/**
14+
* @author qianliqing
15+
* @since 2018-09-30 下午6:45
16+
17+
*/
18+
public class Linear3Activity extends AppCompatActivity {
19+
20+
private String[] names = {"钱立清", "刘尚楠", "许知宇", "陈振宇"};
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_linear_3);
26+
}
27+
28+
public void simple(View source) {
29+
30+
AlertDialog.Builder builder = new AlertDialog.Builder(this)
31+
.setTitle("普通对话框")
32+
.setIcon(R.drawable.qianliqing)
33+
.setMessage("钱立清\nJava爬虫技术小白");
34+
35+
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
36+
@Override
37+
public void onClick(DialogInterface dialog, int i) {
38+
39+
}
40+
})
41+
.create()
42+
.show();
43+
}
44+
45+
public void simpleList(final View source) {
46+
47+
AlertDialog.Builder builder = new AlertDialog.Builder(this)
48+
.setTitle("简单列表项对话框")
49+
.setIcon(R.drawable.qianliqing)
50+
.setItems(names, new DialogInterface.OnClickListener() {
51+
@Override
52+
public void onClick(DialogInterface dialog, int i) {
53+
Toast.makeText(source.getContext(), names[i], Toast.LENGTH_LONG).show();
54+
}
55+
});
56+
57+
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
58+
@Override
59+
public void onClick(DialogInterface dialog, int i) {
60+
61+
}
62+
})
63+
.create()
64+
.show();
65+
}
66+
67+
public void singleChoice(final View source) {
68+
AlertDialog.Builder builder = new AlertDialog.Builder(this)
69+
.setTitle("单选列表项对话框")
70+
.setIcon(R.drawable.qianliqing)
71+
.setSingleChoiceItems(names, 1, new DialogInterface.OnClickListener() {
72+
@Override
73+
public void onClick(DialogInterface dialog, int i) {
74+
Toast.makeText(source.getContext(), names[i], Toast.LENGTH_LONG).show();
75+
}
76+
});
77+
78+
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
79+
@Override
80+
public void onClick(DialogInterface dialog, int i) {
81+
82+
}
83+
})
84+
.create()
85+
.show();
86+
}
87+
88+
89+
public void multiChoice(final View source) {
90+
final Set<String> set = new HashSet<>();
91+
AlertDialog.Builder builder = new AlertDialog.Builder(this)
92+
.setTitle("多选列表项对话框")
93+
.setIcon(R.drawable.qianliqing)
94+
.setMultiChoiceItems(names, new boolean[]{false, false, false, false}, new DialogInterface.OnMultiChoiceClickListener() {
95+
@Override
96+
public void onClick(DialogInterface dialog, int i, boolean b) {
97+
if (b) set.add(names[i]);
98+
else set.remove(names[i]);
99+
Toast.makeText(source.getContext(), set.toString(), Toast.LENGTH_LONG).show();
100+
}
101+
});
102+
103+
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
104+
@Override
105+
public void onClick(DialogInterface dialog, int i) {
106+
107+
}
108+
})
109+
.create()
110+
.show();
111+
}
112+
}

0 commit comments

Comments
 (0)