├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── skypan
│ │ └── helloworld
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── test.html
│ ├── java
│ │ └── com
│ │ │ └── skypan
│ │ │ └── helloworld
│ │ │ ├── ButtonActivity.java
│ │ │ ├── CheckBoxActivity.java
│ │ │ ├── CustomDialogActivity.java
│ │ │ ├── DialogActivity.java
│ │ │ ├── EditTextActivity.java
│ │ │ ├── ImageViewActivity.java
│ │ │ ├── LifeCycleActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── PopupWindowActivity.java
│ │ │ ├── ProgressActivity.java
│ │ │ ├── RadioButtonActivity.java
│ │ │ ├── TextViewActivity.java
│ │ │ ├── ToastActivity.java
│ │ │ ├── UIActivity.java
│ │ │ ├── WebViewActivity.java
│ │ │ ├── fragment
│ │ │ ├── AFragment.java
│ │ │ ├── BFragment.java
│ │ │ └── ContainerActivity.java
│ │ │ ├── gridview
│ │ │ ├── GridViewActivity.java
│ │ │ └── MyGridViewAdapter.java
│ │ │ ├── jump
│ │ │ ├── AActivity.java
│ │ │ └── BActivity.java
│ │ │ ├── listview
│ │ │ ├── ListViewActivity.java
│ │ │ └── MyListAdapter.java
│ │ │ ├── recyclerview
│ │ │ ├── GridAdapter.java
│ │ │ ├── GridRecyclerViewActivity.java
│ │ │ ├── HorAdapter.java
│ │ │ ├── HorRecyclerViewActivity.java
│ │ │ ├── LinearAdapter.java
│ │ │ ├── LinearRecyclerViewActivity.java
│ │ │ ├── PuRecyclerViewActivity.java
│ │ │ ├── RecyclerViewActivity.java
│ │ │ └── StaggeredGridAdapter.java
│ │ │ ├── util
│ │ │ └── ToastUtil.java
│ │ │ └── widget
│ │ │ └── CustomDialog.java
│ └── res
│ │ ├── drawable-xxhdpi
│ │ ├── bg_dropdown.9.png
│ │ ├── bg_iron_man.png
│ │ ├── icon_arrow_off.png
│ │ ├── icon_checkbox_false.png
│ │ ├── icon_checkbox_true.png
│ │ ├── icon_password.png
│ │ ├── icon_progress.png
│ │ ├── icon_smile.png
│ │ ├── icon_user.png
│ │ ├── image1.png
│ │ └── image2.png
│ │ ├── drawable
│ │ ├── bg_btn2.xml
│ │ ├── bg_btn3.xml
│ │ ├── bg_checkbox.xml
│ │ ├── bg_custom_dialog.xml
│ │ ├── bg_progress.xml
│ │ ├── bg_username.xml
│ │ ├── list_item.xml
│ │ ├── selector_orange.xml
│ │ └── selector_orange_radiobutton.xml
│ │ ├── layout
│ │ ├── activity_a.xml
│ │ ├── activity_b.xml
│ │ ├── activity_button.xml
│ │ ├── activity_check_box.xml
│ │ ├── activity_container.xml
│ │ ├── activity_custom.xml
│ │ ├── activity_dialog.xml
│ │ ├── activity_edit_text.xml
│ │ ├── activity_grid_recycler_view.xml
│ │ ├── activity_gridview.xml
│ │ ├── activity_hor_recycler_view.xml
│ │ ├── activity_image_view.xml
│ │ ├── activity_linear_recycler_view.xml
│ │ ├── activity_listview.xml
│ │ ├── activity_main.xml
│ │ ├── activity_popup_window.xml
│ │ ├── activity_progress.xml
│ │ ├── activity_pu_recycler_view.xml
│ │ ├── activity_radio_button.xml
│ │ ├── activity_recycler_view.xml
│ │ ├── activity_test.xml
│ │ ├── activity_text_view.xml
│ │ ├── activity_toast.xml
│ │ ├── activity_ui.xml
│ │ ├── activity_web_view.xml
│ │ ├── fragment_a.xml
│ │ ├── fragment_b.xml
│ │ ├── layout_custom_dialog.xml
│ │ ├── layout_dialog.xml
│ │ ├── layout_grid_item.xml
│ │ ├── layout_grid_recyclerview_item.xml
│ │ ├── layout_hor_item.xml
│ │ ├── layout_linear_item.xml
│ │ ├── layout_linear_item_2.xml
│ │ ├── layout_list_item.xml
│ │ ├── layout_pop.xml
│ │ ├── layout_staggered_grid_recyclerview_item.xml
│ │ └── layout_toast.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── skypan
│ └── helloworld
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidCourse
2 | 该项目是我在Android教学视频中的演示代码。教程地址:http://www.jianshu.com/p/9618c038135f
3 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "26.0.1"
6 | defaultConfig {
7 | applicationId "com.skypan.helloworld"
8 | minSdkVersion 21
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | repositories {
23 | mavenCentral() // jcenter() works as well because it pulls from Maven Central
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29 | exclude group: 'com.android.support', module: 'support-annotations'
30 | })
31 | compile 'com.android.support:appcompat-v7:25.3.1'
32 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
33 | compile 'com.github.bumptech.glide:glide:4.0.0'
34 | compile 'com.android.support:design:25.3.1'
35 | testCompile 'junit:junit:4.12'
36 | annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/skypan/Downloads/software/develop/adt-bundle-mac-x86_64-20131030/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/skypan/helloworld/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
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 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
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.skypan.helloworld", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/assets/test.html:
--------------------------------------------------------------------------------
1 |
2 | Hello World!
3 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/ButtonActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | public class ButtonActivity extends AppCompatActivity {
11 |
12 | private Button mBtn3;
13 | private TextView mTv1;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_button);
19 | mBtn3 = (Button) findViewById(R.id.btn_3);
20 | mBtn3.setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View v) {
23 | Toast.makeText(ButtonActivity.this,"btn3被点击了",Toast.LENGTH_SHORT).show();
24 | }
25 | });
26 |
27 | mTv1 = (TextView) findViewById(R.id.tv_1);
28 | mTv1.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | Toast.makeText(ButtonActivity.this,"tv1被点击了",Toast.LENGTH_SHORT).show();
32 | }
33 | });
34 | }
35 |
36 | public void showToast(View view){
37 | Toast.makeText(this,"btn4被点击了",Toast.LENGTH_SHORT).show();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/CheckBoxActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.widget.CheckBox;
6 | import android.widget.CompoundButton;
7 | import android.widget.Switch;
8 | import android.widget.Toast;
9 |
10 | public class CheckBoxActivity extends AppCompatActivity {
11 |
12 | private CheckBox mCb5,mCb6;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_check_box);
18 | mCb5 = (CheckBox) findViewById(R.id.cb_5);
19 | mCb6 = (CheckBox) findViewById(R.id.cb_6);
20 |
21 | mCb5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
22 | @Override
23 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
24 | Toast.makeText(CheckBoxActivity.this,isChecked?"5选中":"5未选中",Toast.LENGTH_SHORT).show();
25 | }
26 | });
27 |
28 | mCb6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
29 | @Override
30 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
31 | Toast.makeText(CheckBoxActivity.this,isChecked?"6选中":"6未选中",Toast.LENGTH_SHORT).show();
32 | }
33 | });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/CustomDialogActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.Button;
7 |
8 | import com.skypan.helloworld.util.ToastUtil;
9 | import com.skypan.helloworld.widget.CustomDialog;
10 |
11 | public class CustomDialogActivity extends AppCompatActivity {
12 |
13 | private Button mBtnDialog;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_custom);
19 | mBtnDialog = (Button) findViewById(R.id.btn_custom_dialog);
20 | mBtnDialog.setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View v) {
23 | CustomDialog customDialog = new CustomDialog(CustomDialogActivity.this);
24 | customDialog.setTitle("提示").setMessage("确认删除此项?")
25 | .setCancel("取消", new CustomDialog.IOnCancelListener() {
26 | @Override
27 | public void onCancel(CustomDialog dialog) {
28 | ToastUtil.showMsg(CustomDialogActivity.this,"cancel...");
29 | }
30 | }).setConfirm("确认", new CustomDialog.IOnConfirmListener() {
31 | @Override
32 | public void onConfirm(CustomDialog dialog) {
33 | ToastUtil.showMsg(CustomDialogActivity.this,"confirm...");
34 | }
35 | }).show();
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/DialogActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AlertDialog;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.Toast;
13 |
14 | import com.skypan.helloworld.util.ToastUtil;
15 |
16 | public class DialogActivity extends AppCompatActivity {
17 |
18 | private Button mBtnDialog1, mBtnDialog2, mBtnDialog3, mBtnDialog4,mBtnDialog5;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_dialog);
24 | mBtnDialog1 = (Button) findViewById(R.id.btn_dialog1);
25 | mBtnDialog2 = (Button) findViewById(R.id.btn_dialog2);
26 | mBtnDialog3 = (Button) findViewById(R.id.btn_dialog3);
27 | mBtnDialog4 = (Button) findViewById(R.id.btn_dialog4);
28 | mBtnDialog5 = (Button) findViewById(R.id.btn_dialog5);
29 | OnClick onClick = new OnClick();
30 | mBtnDialog1.setOnClickListener(onClick);
31 | mBtnDialog2.setOnClickListener(onClick);
32 | mBtnDialog3.setOnClickListener(onClick);
33 | mBtnDialog4.setOnClickListener(onClick);
34 | mBtnDialog5.setOnClickListener(onClick);
35 | }
36 |
37 | class OnClick implements View.OnClickListener {
38 | @Override
39 | public void onClick(View v) {
40 | switch (v.getId()) {
41 | case R.id.btn_dialog1:
42 | AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this);
43 | builder.setTitle("请回答").setMessage("你觉得课程如何?")
44 | .setIcon(R.drawable.icon_user)
45 | .setPositiveButton("棒", new DialogInterface.OnClickListener() {
46 | @Override
47 | public void onClick(DialogInterface dialog, int which) {
48 | ToastUtil.showMsg(DialogActivity.this, "你很诚实");
49 | }
50 | }).setNeutralButton("还行", new DialogInterface.OnClickListener() {
51 | @Override
52 | public void onClick(DialogInterface dialog, int which) {
53 | ToastUtil.showMsg(DialogActivity.this, "你再瞅瞅~");
54 | }
55 | }).setNegativeButton("不好", new DialogInterface.OnClickListener() {
56 | @Override
57 | public void onClick(DialogInterface dialog, int which) {
58 | ToastUtil.showMsg(DialogActivity.this, "睁眼说瞎话");
59 | }
60 | }).show();
61 | break;
62 | case R.id.btn_dialog2:
63 | final String[] array2 = new String[]{"男", "女"};
64 | AlertDialog.Builder builder2 = new AlertDialog.Builder(DialogActivity.this);
65 | builder2.setTitle("选择性别").setItems(array2, new DialogInterface.OnClickListener() {
66 | @Override
67 | public void onClick(DialogInterface dialog, int which) {
68 | ToastUtil.showMsg(DialogActivity.this, array2[which]);
69 | }
70 | }).show();
71 | break;
72 | case R.id.btn_dialog3:
73 | final String[] array3 = new String[]{"男", "女"};
74 | AlertDialog.Builder builder3 = new AlertDialog.Builder(DialogActivity.this);
75 | builder3.setTitle("选择性别").setSingleChoiceItems(array3, 1, new DialogInterface.OnClickListener() {
76 | @Override
77 | public void onClick(DialogInterface dialog, int which) {
78 | ToastUtil.showMsg(DialogActivity.this, array3[which]);
79 | dialog.dismiss();
80 | }
81 | }).setCancelable(false).show();
82 | break;
83 | case R.id.btn_dialog4:
84 | final String[] array4 = new String[]{"唱歌", "跳舞","写代码"};
85 | boolean[] isSelected = new boolean[]{false,false,true};
86 | AlertDialog.Builder builder4 = new AlertDialog.Builder(DialogActivity.this);
87 | builder4.setTitle("选择兴趣").setMultiChoiceItems(array4, isSelected, new DialogInterface.OnMultiChoiceClickListener() {
88 | @Override
89 | public void onClick(DialogInterface dialog, int which, boolean isChecked) {
90 | ToastUtil.showMsg(DialogActivity.this,array4[which]+":"+isChecked);
91 | }
92 | }).setPositiveButton("确定", new DialogInterface.OnClickListener() {
93 | @Override
94 | public void onClick(DialogInterface dialog, int which) {
95 | //
96 | }
97 | }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
98 | @Override
99 | public void onClick(DialogInterface dialog, int which) {
100 |
101 | }
102 | }).show();
103 | break;
104 | case R.id.btn_dialog5:
105 | AlertDialog.Builder builder5 = new AlertDialog.Builder(DialogActivity.this);
106 | View view = LayoutInflater.from(DialogActivity.this).inflate(R.layout.layout_dialog,null);
107 | EditText etUserName = (EditText) view.findViewById(R.id.et_username);
108 | EditText etPassWord = (EditText) view.findViewById(R.id.et_password);
109 | Button btnLogin = (Button) view.findViewById(R.id.btn_login);
110 | btnLogin.setOnClickListener(new View.OnClickListener() {
111 | @Override
112 | public void onClick(View v) {
113 | //
114 | }
115 | });
116 | builder5.setTitle("请先登录").setView(view).show();
117 | break;
118 | }
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/EditTextActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.text.Editable;
6 | import android.text.TextWatcher;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.CheckBox;
11 | import android.widget.EditText;
12 | import android.widget.RadioButton;
13 | import android.widget.Toast;
14 |
15 | public class EditTextActivity extends AppCompatActivity {
16 |
17 | private Button mBtnLogin;
18 | private EditText mEtUserName;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_edit_text);
24 | mBtnLogin = (Button) findViewById(R.id.btn_login);
25 | mBtnLogin.setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | Toast.makeText(EditTextActivity.this,"登录成功!",Toast.LENGTH_SHORT).show();
29 | }
30 | });
31 | mEtUserName = (EditText) findViewById(R.id.et_1);
32 | mEtUserName.addTextChangedListener(new TextWatcher() {
33 | @Override
34 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
35 |
36 | }
37 |
38 | @Override
39 | public void onTextChanged(CharSequence s, int start, int before, int count) {
40 | Log.d("edittext",s.toString());
41 | }
42 |
43 | @Override
44 | public void afterTextChanged(Editable s) {
45 |
46 | }
47 | });
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/ImageViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.widget.ImageView;
6 |
7 | import com.bumptech.glide.Glide;
8 |
9 | public class ImageViewActivity extends AppCompatActivity {
10 |
11 | private ImageView mIv4;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_image_view);
17 | mIv4 = (ImageView) findViewById(R.id.iv_4);
18 | Glide.with(this).load("https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png").into(mIv4);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/LifeCycleActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.util.Log;
7 |
8 | /**
9 | * Created by skypan on 2017/8/27.
10 | */
11 |
12 | public class LifeCycleActivity extends AppCompatActivity {
13 | @Override
14 | protected void onCreate(@Nullable Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_test);
17 | Log.d("LifeCycle","----onCreate----");
18 | }
19 |
20 | @Override
21 | protected void onStart() {
22 | super.onStart();
23 | Log.d("LifeCycle","----onStart----");
24 | }
25 |
26 | @Override
27 | protected void onResume() {
28 | super.onResume();
29 | Log.d("LifeCycle","----onResume----");
30 | }
31 |
32 | @Override
33 | protected void onPause() {
34 | super.onPause();
35 | Log.d("LifeCycle","----onPause----");
36 |
37 | }
38 |
39 | @Override
40 | protected void onStop() {
41 | super.onStop();
42 | Log.d("LifeCycle","----onStop----");
43 | }
44 |
45 | @Override
46 | protected void onRestart() {
47 | super.onRestart();
48 | Log.d("LifeCycle","----onRestart----");
49 | }
50 |
51 | @Override
52 | protected void onDestroy() {
53 | super.onDestroy();
54 | Log.d("LifeCycle","----onDestroy----");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | private Button mBtnUI;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 | mBtnUI = (Button) findViewById(R.id.btn_ui);
18 | OnClick onClick = new OnClick();
19 | mBtnUI.setOnClickListener(onClick);
20 | }
21 |
22 | class OnClick implements View.OnClickListener{
23 | @Override
24 | public void onClick(View v) {
25 | Intent intent = null;
26 | switch (v.getId()){
27 | case R.id.btn_ui:
28 | intent = new Intent(MainActivity.this,UIActivity.class);
29 | break;
30 | }
31 | startActivity(intent);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/PopupWindowActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.PopupWindow;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.skypan.helloworld.util.ToastUtil;
13 |
14 | public class PopupWindowActivity extends AppCompatActivity {
15 |
16 | private Button mBtnPop;
17 | private PopupWindow mPop;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_popup_window);
23 | mBtnPop = (Button) findViewById(R.id.btn_pop);
24 | mBtnPop.setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | View view = getLayoutInflater().inflate(R.layout.layout_pop,null);
28 | TextView textView = (TextView) view.findViewById(R.id.tv_good);
29 | textView.setOnClickListener(new View.OnClickListener() {
30 | @Override
31 | public void onClick(View v) {
32 | mPop.dismiss();
33 | //do something...
34 | ToastUtil.showMsg(PopupWindowActivity.this,"好");
35 | }
36 | });
37 | mPop = new PopupWindow(view,mBtnPop.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
38 | mPop.setOutsideTouchable(true);
39 | mPop.setFocusable(true);
40 | mPop.showAsDropDown(mBtnPop);
41 | }
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/ProgressActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.app.Dialog;
4 | import android.app.ProgressDialog;
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.os.Message;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.ProgressBar;
13 |
14 | import com.skypan.helloworld.util.ToastUtil;
15 |
16 | public class ProgressActivity extends AppCompatActivity {
17 |
18 | private ProgressBar mPb3;
19 | private Button mBtnStart,mBtnProgressDialog1,mBtnProgressDialog2;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_progress);
25 | mPb3 = (ProgressBar) findViewById(R.id.pb3);
26 | mBtnStart = (Button) findViewById(R.id.btn_start);
27 | mBtnProgressDialog1 = (Button) findViewById(R.id.btn_progress_dialog1);
28 | mBtnProgressDialog2 = (Button) findViewById(R.id.btn_progress_dialog2);
29 | mBtnStart.setOnClickListener(new View.OnClickListener() {
30 | @Override
31 | public void onClick(View v) {
32 | handler.sendEmptyMessage(0);
33 | }
34 | });
35 | mBtnProgressDialog1.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | ProgressDialog progressDialog = new ProgressDialog(ProgressActivity.this);
39 | progressDialog.setTitle("提示");
40 | progressDialog.setMessage("正在加载");
41 | progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
42 | @Override
43 | public void onCancel(DialogInterface dialog) {
44 | ToastUtil.showMsg(ProgressActivity.this,"cancel...");
45 | }
46 | });
47 | progressDialog.setCancelable(false);
48 | progressDialog.show();
49 | }
50 | });
51 | mBtnProgressDialog2.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | ProgressDialog progressDialog = new ProgressDialog(ProgressActivity.this);
55 | progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
56 | progressDialog.setTitle("提示");
57 | progressDialog.setMessage("正在下载...");
58 | progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "棒", new DialogInterface.OnClickListener() {
59 | @Override
60 | public void onClick(DialogInterface dialog, int which) {
61 | //
62 | }
63 | });
64 | progressDialog.show();
65 | }
66 | });
67 | }
68 |
69 | Handler handler = new Handler(){
70 | @Override
71 | public void handleMessage(Message msg) {
72 | super.handleMessage(msg);
73 | if(mPb3.getProgress() < 100){
74 | handler.postDelayed(runnable,500);
75 | }else{
76 | ToastUtil.showMsg(ProgressActivity.this,"加载完成");
77 | }
78 | }
79 | };
80 |
81 | Runnable runnable = new Runnable() {
82 | @Override
83 | public void run() {
84 | mPb3.setProgress(mPb3.getProgress()+5);
85 | handler.sendEmptyMessage(0);
86 | }
87 | };
88 | }
89 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/RadioButtonActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.support.annotation.IdRes;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.widget.RadioButton;
7 | import android.widget.RadioGroup;
8 | import android.widget.Toast;
9 |
10 | public class RadioButtonActivity extends AppCompatActivity {
11 |
12 | private RadioGroup mRg1;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_radio_button);
18 | mRg1 = (RadioGroup) findViewById(R.id.rg_1);
19 | mRg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
20 | @Override
21 | public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
22 | RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
23 | Toast.makeText(RadioButtonActivity.this,radioButton.getText(),Toast.LENGTH_SHORT).show();
24 | }
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/TextViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.graphics.Paint;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.text.Html;
7 | import android.widget.TextView;
8 |
9 | public class TextViewActivity extends AppCompatActivity {
10 |
11 | private TextView mTv4;
12 | private TextView mTv5;
13 | private TextView mTv6;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_text_view);
19 | mTv4 = (TextView) findViewById(R.id.tv_4);
20 | mTv4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
21 | mTv4.getPaint().setAntiAlias(true);//去除锯齿
22 |
23 | mTv5 = (TextView) findViewById(R.id.tv_5);
24 | mTv5.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线
25 |
26 | mTv6 = (TextView) findViewById(R.id.tv_6);
27 | mTv6.setText(Html.fromHtml("天哥在奔跑"));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/ToastActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.skypan.helloworld.util.ToastUtil;
14 |
15 | public class ToastActivity extends AppCompatActivity {
16 |
17 | private Button mBtnToast1,mBtnToast2,mBtnToast3,mBtnToast4;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_toast);
23 | mBtnToast1 = (Button) findViewById(R.id.btn_toast_1);
24 | mBtnToast2 = (Button) findViewById(R.id.btn_toast_2);
25 | mBtnToast3 = (Button) findViewById(R.id.btn_toast_3);
26 | mBtnToast4 = (Button) findViewById(R.id.btn_toast_4);
27 | OnClick onClick = new OnClick();
28 | mBtnToast1.setOnClickListener(onClick);
29 | mBtnToast2.setOnClickListener(onClick);
30 | mBtnToast3.setOnClickListener(onClick);
31 | mBtnToast4.setOnClickListener(onClick);
32 | }
33 |
34 | class OnClick implements View.OnClickListener{
35 | @Override
36 | public void onClick(View v) {
37 | switch (v.getId()){
38 | case R.id.btn_toast_1:
39 | Toast.makeText(getApplicationContext(),"Toast",Toast.LENGTH_LONG).show();
40 | break;
41 | case R.id.btn_toast_2:
42 | Toast toastCenter = Toast.makeText(getApplicationContext(),"居中Toast",Toast.LENGTH_LONG);
43 | toastCenter.setGravity(Gravity.CENTER,0,0);
44 | toastCenter.show();
45 | break;
46 | case R.id.btn_toast_3:
47 | Toast toastCustom = new Toast(getApplicationContext());
48 | LayoutInflater inflater = LayoutInflater.from(ToastActivity.this);
49 | View view = inflater.inflate(R.layout.layout_toast,null);
50 | ImageView imageView = (ImageView) view.findViewById(R.id.iv_toast);
51 | TextView textView = (TextView) view.findViewById(R.id.tv_toast);
52 | imageView.setImageResource(R.drawable.icon_smile);
53 | textView.setText("自定义Toast");
54 | toastCustom.setView(view);
55 | toastCustom.setDuration(Toast.LENGTH_LONG);
56 | toastCustom.show();
57 | break;
58 | case R.id.btn_toast_4:
59 | ToastUtil.showMsg(getApplicationContext(),"包装过的Toast");
60 | break;
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/UIActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.skypan.helloworld.fragment.ContainerActivity;
10 | import com.skypan.helloworld.gridview.GridViewActivity;
11 | import com.skypan.helloworld.jump.AActivity;
12 | import com.skypan.helloworld.listview.ListViewActivity;
13 | import com.skypan.helloworld.recyclerview.RecyclerViewActivity;
14 |
15 | public class UIActivity extends AppCompatActivity {
16 |
17 | private Button mBtnTextView;
18 | private Button mBtnButton;
19 | private Button mBtnEditText;
20 | private Button mBtnRadioButton;
21 | private Button mBtnCheckBox;
22 | private Button mBtnImageView;
23 | private Button mBtnListView;
24 | private Button mBtnGridView;
25 | private Button mBtnLifeCycle;
26 | private Button mBtnJump;
27 | private Button mBtnFragment;
28 | private Button mBtnRv;
29 | private Button mBtnWebView;
30 | private Button mBtnToast;
31 | private Button mBtnDialog;
32 | private Button mBtnProgress;
33 | private Button mBtnCustomDialog;
34 | private Button mBtnPop;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_ui);
40 | mBtnTextView = (Button) findViewById(R.id.btn_textview);
41 | mBtnButton = (Button) findViewById(R.id.btn_button);
42 | mBtnEditText = (Button) findViewById(R.id.btn_edittext);
43 | mBtnRadioButton = (Button) findViewById(R.id.btn_radiobutton);
44 | mBtnCheckBox = (Button) findViewById(R.id.btn_checkbox);
45 | mBtnImageView = (Button) findViewById(R.id.btn_imageview);
46 | mBtnListView = (Button) findViewById(R.id.btn_listview);
47 | mBtnGridView = (Button) findViewById(R.id.btn_gridview);
48 | mBtnLifeCycle = (Button) findViewById(R.id.btn_lifecycle);
49 | mBtnJump = (Button) findViewById(R.id.btn_jump);
50 | mBtnFragment = (Button) findViewById(R.id.btn_fragment);
51 | mBtnRv = (Button) findViewById(R.id.btn_recyclerview);
52 | mBtnWebView = (Button) findViewById(R.id.btn_webview);
53 | mBtnToast = (Button) findViewById(R.id.btn_toast);
54 | mBtnDialog = (Button) findViewById(R.id.btn_dialog);
55 | mBtnProgress = (Button) findViewById(R.id.btn_progress);
56 | mBtnCustomDialog = (Button) findViewById(R.id.btn_custom_dialog);
57 | mBtnPop = (Button) findViewById(R.id.btn_pop);
58 | setListeners();
59 | }
60 |
61 | private void setListeners() {
62 | OnClick onClick = new OnClick();
63 | mBtnTextView.setOnClickListener(onClick);
64 | mBtnButton.setOnClickListener(onClick);
65 | mBtnEditText.setOnClickListener(onClick);
66 | mBtnRadioButton.setOnClickListener(onClick);
67 | mBtnCheckBox.setOnClickListener(onClick);
68 | mBtnImageView.setOnClickListener(onClick);
69 | mBtnListView.setOnClickListener(onClick);
70 | mBtnGridView.setOnClickListener(onClick);
71 | mBtnLifeCycle.setOnClickListener(onClick);
72 | mBtnJump.setOnClickListener(onClick);
73 | mBtnFragment.setOnClickListener(onClick);
74 | mBtnRv.setOnClickListener(onClick);
75 | mBtnWebView.setOnClickListener(onClick);
76 | mBtnToast.setOnClickListener(onClick);
77 | mBtnDialog.setOnClickListener(onClick);
78 | mBtnProgress.setOnClickListener(onClick);
79 | mBtnCustomDialog.setOnClickListener(onClick);
80 | mBtnPop.setOnClickListener(onClick);
81 | }
82 |
83 | private class OnClick implements View.OnClickListener {
84 |
85 | @Override
86 | public void onClick(View v) {
87 | Intent intent = null;
88 | switch (v.getId()) {
89 | case R.id.btn_textview:
90 | //跳转到TextView演示界面
91 | intent = new Intent(UIActivity.this, TextViewActivity.class);
92 | break;
93 | case R.id.btn_button:
94 | //跳转到Button演示界面
95 | intent = new Intent(UIActivity.this, ButtonActivity.class);
96 | break;
97 | case R.id.btn_edittext:
98 | //跳转到EditText演示界面
99 | intent = new Intent(UIActivity.this, EditTextActivity.class);
100 | break;
101 | case R.id.btn_radiobutton:
102 | //跳转到RadioButton演示界面
103 | intent = new Intent(UIActivity.this, RadioButtonActivity.class);
104 | break;
105 | case R.id.btn_checkbox:
106 | //跳转到CheckBox演示界面
107 | intent = new Intent(UIActivity.this, CheckBoxActivity.class);
108 | break;
109 | case R.id.btn_imageview:
110 | //跳转到ImageView演示界面
111 | intent = new Intent(UIActivity.this, ImageViewActivity.class);
112 | break;
113 | case R.id.btn_listview:
114 | //跳转到ListView演示界面
115 | intent = new Intent(UIActivity.this, ListViewActivity.class);
116 | break;
117 | case R.id.btn_gridview:
118 | //跳转到GridView演示界面
119 | intent = new Intent(UIActivity.this, GridViewActivity.class);
120 | break;
121 | case R.id.btn_lifecycle:
122 | //跳转到LifeCycle演示界面
123 | intent = new Intent(UIActivity.this, LifeCycleActivity.class);
124 | break;
125 | case R.id.btn_jump:
126 | //跳转到AActivity演示界面
127 | intent = new Intent(UIActivity.this, AActivity.class);
128 | break;
129 | case R.id.btn_fragment:
130 | //跳转到Fragment演示界面
131 | intent = new Intent(UIActivity.this, ContainerActivity.class);
132 | break;
133 | case R.id.btn_recyclerview:
134 | //跳转到RecyclerView演示界面
135 | intent = new Intent(UIActivity.this, RecyclerViewActivity.class);
136 | break;
137 | case R.id.btn_webview:
138 | //跳转到WebView演示界面
139 | intent = new Intent(UIActivity.this, WebViewActivity.class);
140 | break;
141 | case R.id.btn_toast:
142 | //跳转到Toast演示界面
143 | intent = new Intent(UIActivity.this, ToastActivity.class);
144 | break;
145 | case R.id.btn_dialog:
146 | //跳转到Dialog演示界面
147 | intent = new Intent(UIActivity.this, DialogActivity.class);
148 | break;
149 | case R.id.btn_progress:
150 | //跳转到Progress演示界面
151 | intent = new Intent(UIActivity.this, ProgressActivity.class);
152 | break;
153 | case R.id.btn_custom_dialog:
154 | //跳转到自定义Dialog演示界面
155 | intent = new Intent(UIActivity.this, CustomDialogActivity.class);
156 | break;
157 | case R.id.btn_pop:
158 | //跳转到PopupWindow演示界面
159 | intent = new Intent(UIActivity.this, PopupWindowActivity.class);
160 | break;
161 | }
162 | startActivity(intent);
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import android.graphics.Bitmap;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.util.Log;
7 | import android.view.KeyEvent;
8 | import android.webkit.WebChromeClient;
9 | import android.webkit.WebResourceRequest;
10 | import android.webkit.WebView;
11 | import android.webkit.WebViewClient;
12 |
13 | public class WebViewActivity extends AppCompatActivity {
14 |
15 | private WebView mWvMain;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_web_view);
21 | mWvMain = (WebView) findViewById(R.id.wv);
22 | //加载本地HTML
23 | // mWvMain.loadUrl("file:///android_asset/test.html");
24 | //加载网络URL
25 | mWvMain.getSettings().setJavaScriptEnabled(true);
26 | mWvMain.setWebViewClient(new MyWebViewClient());
27 | mWvMain.setWebChromeClient(new MyWebChromeClient());
28 | // mWvMain.addJavascriptInterface();
29 | mWvMain.loadUrl("https://m.baidu.com");
30 |
31 | }
32 |
33 | class MyWebViewClient extends WebViewClient{
34 | @Override
35 | public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
36 | view.loadUrl(request.getUrl().toString());
37 | return true;
38 | }
39 |
40 | @Override
41 | public void onPageStarted(WebView view, String url, Bitmap favicon) {
42 | super.onPageStarted(view, url, favicon);
43 | Log.d("WebView","onPageStarted...");
44 | }
45 |
46 | @Override
47 | public void onPageFinished(WebView view, String url) {
48 | super.onPageFinished(view, url);
49 | Log.d("WebView","onPageFinished...");
50 | // mWvMain.loadUrl("javascript:alert('hello')");
51 | mWvMain.evaluateJavascript("javascript:alert('hello')",null);
52 | }
53 | }
54 |
55 | class MyWebChromeClient extends WebChromeClient{
56 | @Override
57 | public void onProgressChanged(WebView view, int newProgress) {
58 | super.onProgressChanged(view, newProgress);
59 | }
60 |
61 | @Override
62 | public void onReceivedTitle(WebView view, String title) {
63 | super.onReceivedTitle(view, title);
64 | setTitle(title);
65 | }
66 | }
67 |
68 | @Override
69 | public boolean onKeyDown(int keyCode, KeyEvent event) {
70 | if(keyCode == KeyEvent.KEYCODE_BACK && mWvMain.canGoBack()){
71 | mWvMain.goBack();
72 | return true;
73 | }
74 | return super.onKeyDown(keyCode, event);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/fragment/AFragment.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.fragment;
2 |
3 | import android.app.Fragment;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Button;
12 | import android.widget.TextView;
13 |
14 | import com.skypan.helloworld.R;
15 |
16 | /**
17 | * Created by skypan on 2017/8/30.
18 | */
19 |
20 | public class AFragment extends Fragment {
21 |
22 | private TextView mTvTitle;
23 | private Button mBtnChange,mBtnReset,mBtnMessage;
24 | private BFragment bFragment;
25 | private IOnMessageClick listener;
26 |
27 | public static AFragment newInstance(String title){
28 | AFragment fragment = new AFragment();
29 | Bundle bundle = new Bundle();
30 | bundle.putString("title",title);
31 | fragment.setArguments(bundle);
32 | return fragment;
33 | }
34 |
35 | public interface IOnMessageClick{
36 | void onClick(String text);
37 | }
38 |
39 | @Override
40 | public void onAttach(Context context) {
41 | super.onAttach(context);
42 | try {
43 | listener = (IOnMessageClick) context;
44 | }catch (ClassCastException e){
45 | throw new ClassCastException("Activity 必须实现 IOnMessageClick接口");
46 | }
47 | }
48 |
49 | @Nullable
50 | @Override
51 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
52 | View view = inflater.inflate(R.layout.fragment_a,container,false);
53 | Log.d("AFragment","----onCreateView----");
54 | return view;
55 | }
56 |
57 | @Override
58 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
59 | super.onViewCreated(view, savedInstanceState);
60 | //
61 | mTvTitle = (TextView) view.findViewById(R.id.tv_title);
62 | mBtnChange = (Button) view.findViewById(R.id.btn_change);
63 | mBtnReset = (Button) view.findViewById(R.id.btn_reset);
64 | mBtnMessage = (Button) view.findViewById(R.id.btn_message);
65 | mBtnMessage.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | // ((ContainerActivity)getActivity()).setData("你好");
69 | listener.onClick("你好");
70 | }
71 | });
72 | mBtnChange.setOnClickListener(new View.OnClickListener() {
73 | @Override
74 | public void onClick(View v) {
75 | if(bFragment == null){
76 | bFragment = new BFragment();
77 | }
78 | Fragment fragment = getFragmentManager().findFragmentByTag("a");
79 | if(fragment != null){
80 | getFragmentManager().beginTransaction().hide(fragment).add(R.id.fl_container,bFragment).addToBackStack(null).commitAllowingStateLoss();
81 | }else{
82 | getFragmentManager().beginTransaction().replace(R.id.fl_container,bFragment).addToBackStack(null).commitAllowingStateLoss();
83 | }
84 | }
85 | });
86 | mBtnReset.setOnClickListener(new View.OnClickListener() {
87 | @Override
88 | public void onClick(View v) {
89 | mTvTitle.setText("我是新文字");
90 | }
91 | });
92 | if(getArguments() != null){
93 | mTvTitle.setText(getArguments().getString("title"));
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/fragment/BFragment.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.fragment;
2 |
3 | import android.app.Fragment;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | /**
14 | * Created by skypan on 2017/8/30.
15 | */
16 |
17 | public class BFragment extends Fragment {
18 |
19 | private TextView mTvTitle;
20 |
21 | @Nullable
22 | @Override
23 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
24 | View view = inflater.inflate(R.layout.fragment_b,container,false);
25 | return view;
26 | }
27 |
28 | @Override
29 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
30 | super.onViewCreated(view, savedInstanceState);
31 | //
32 | mTvTitle = (TextView) view.findViewById(R.id.tv_title);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/fragment/ContainerActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.TextView;
6 |
7 | import com.skypan.helloworld.R;
8 |
9 | public class ContainerActivity extends AppCompatActivity implements AFragment.IOnMessageClick{
10 |
11 | private AFragment aFragment;
12 | private TextView mTvTitle;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_container);
18 | mTvTitle = (TextView) findViewById(R.id.tv_title);
19 |
20 | //实例化AFragment
21 | aFragment = AFragment.newInstance("我是参数");
22 | //把AFragment添加到Activity中,记得调用commit
23 | getFragmentManager().beginTransaction().add(R.id.fl_container,aFragment,"a").commitAllowingStateLoss();
24 | }
25 |
26 | public void setData(String text){
27 | mTvTitle.setText(text);
28 | }
29 |
30 | @Override
31 | public void onClick(String text) {
32 | mTvTitle.setText(text);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/gridview/GridViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.gridview;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.GridView;
9 | import android.widget.Toast;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | /**
14 | * Created by skypan on 2017/8/26.
15 | */
16 |
17 | public class GridViewActivity extends AppCompatActivity {
18 |
19 | private GridView mGv;
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_gridview);
25 | mGv = (GridView) findViewById(R.id.gv);
26 | mGv.setAdapter(new MyGridViewAdapter(GridViewActivity.this));
27 | mGv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
28 | @Override
29 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
30 | Toast.makeText(GridViewActivity.this,"点击 pos:"+position,Toast.LENGTH_SHORT).show();
31 | }
32 | });
33 | mGv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
34 | @Override
35 | public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
36 | Toast.makeText(GridViewActivity.this,"长按 pos:"+position,Toast.LENGTH_SHORT).show();
37 | return true;
38 | }
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/gridview/MyGridViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.gridview;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.skypan.helloworld.R;
13 |
14 | /**
15 | * Created by skypan on 2017/8/26.
16 | */
17 |
18 | public class MyGridViewAdapter extends BaseAdapter {
19 |
20 | private Context mContext;
21 | private LayoutInflater mLayoutInflater;
22 |
23 | public MyGridViewAdapter(Context context){
24 | this.mContext = context;
25 | mLayoutInflater = LayoutInflater.from(context);
26 | }
27 |
28 | @Override
29 | public int getCount() {
30 | return 10;
31 | }
32 |
33 | @Override
34 | public Object getItem(int position) {
35 | return null;
36 | }
37 |
38 | @Override
39 | public long getItemId(int position) {
40 | return 0;
41 | }
42 |
43 | static class ViewHolder{
44 | public ImageView imageView;
45 | public TextView textView;
46 | }
47 |
48 | @Override
49 | public View getView(int position, View convertView, ViewGroup parent) {
50 | ViewHolder holder = null;
51 | if(convertView == null){
52 | convertView = mLayoutInflater.inflate(R.layout.layout_grid_item,null);
53 | holder = new ViewHolder();
54 | holder.imageView = (ImageView) convertView.findViewById(R.id.iv_grid);
55 | holder.textView = (TextView) convertView.findViewById(R.id.tv_title);
56 | convertView.setTag(holder);
57 | }else{
58 | holder = (ViewHolder) convertView.getTag();
59 | }
60 | //赋值
61 | holder.textView.setText("花");
62 | Glide.with(mContext).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503734793030&di=10ea8e49217f7a2054f4febf94a164af&imgtype=0&src=http%3A%2F%2Fpic.58pic.com%2F58pic%2F15%2F24%2F57%2F34s58PICQEq_1024.jpg").into(holder.imageView);
63 | return convertView;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/jump/AActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.jump;
2 |
3 | import android.content.Intent;
4 | import android.content.pm.ActivityInfo;
5 | import android.content.pm.PackageManager;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.Toast;
13 |
14 | import com.skypan.helloworld.R;
15 |
16 | /**
17 | * Created by skypan on 2017/8/28.
18 | */
19 |
20 | public class AActivity extends AppCompatActivity {
21 |
22 | private Button mBtnJump;
23 | private Button mBtnJump2;
24 |
25 | @Override
26 | protected void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_a);
29 | Log.d("AActivity","----onCreate----");
30 | Log.d("AActivity","taskid:"+getTaskId()+" ,hash:"+hashCode());
31 | logtaskName();
32 | mBtnJump = (Button) findViewById(R.id.jump);
33 | mBtnJump2 = (Button) findViewById(R.id.jump_2);
34 | mBtnJump2.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | Intent intent = new Intent(AActivity.this, AActivity.class);
38 | startActivity(intent);
39 | }
40 | });
41 | mBtnJump.setOnClickListener(new View.OnClickListener() {
42 | @Override
43 | public void onClick(View v) {
44 | //显式1
45 | Intent intent = new Intent(AActivity.this, BActivity.class);
46 | Bundle bundle = new Bundle();
47 | bundle.putString("name", "天哥");
48 | bundle.putInt("number", 88);
49 | intent.putExtras(bundle);
50 | startActivity(intent);
51 | // startActivityForResult(intent, 0);
52 |
53 | //显式2
54 | // Intent intent = new Intent();
55 | // intent.setClass(AActivity.this,BActivity.class);
56 | // startActivity(intent);
57 |
58 | //显式3
59 | // Intent intent = new Intent();
60 | // intent.setClassName(AActivity.this,"com.skypan.helloworld.jump.BActivity");
61 | // startActivity(intent);
62 |
63 | //显式4
64 | // Intent intent = new Intent();
65 | // intent.setComponent(new ComponentName(AActivity.this,"com.skypan.helloworld.jump.BActivity"));
66 | // startActivity(intent);
67 |
68 | //隐式
69 | // Intent intent = new Intent();
70 | // intent.setAction("com.skypan.test.BActivity");
71 | // startActivity(intent);
72 | }
73 | });
74 |
75 | }
76 |
77 | @Override
78 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
79 | super.onActivityResult(requestCode, resultCode, data);
80 | Toast.makeText(AActivity.this, data.getExtras().getString("title"), Toast.LENGTH_LONG).show();
81 | }
82 |
83 | @Override
84 | protected void onNewIntent(Intent intent) {
85 | super.onNewIntent(intent);
86 | Log.d("AActivity","----onNewIntent----");
87 | Log.d("AActivity","taskid:"+getTaskId()+" ,hash:"+hashCode());
88 | logtaskName();
89 | }
90 |
91 | private void logtaskName(){
92 | try {
93 | ActivityInfo info = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
94 | Log.d("AActivity",info.taskAffinity);
95 | } catch (PackageManager.NameNotFoundException e) {
96 | e.printStackTrace();
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/jump/BActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.jump;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.content.pm.PackageManager;
7 | import android.os.Bundle;
8 | import android.support.annotation.Nullable;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.TextView;
14 |
15 | import com.skypan.helloworld.R;
16 |
17 | /**
18 | * Created by skypan on 2017/8/28.
19 | */
20 |
21 | public class BActivity extends AppCompatActivity {
22 |
23 | private TextView mTvTitle;
24 | private Button mBtnFinish,mBtnJump;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_b);
30 | Log.d("BActivity","----onNewIntent----");
31 | Log.d("BActivity","taskid:"+getTaskId()+" ,hash:"+hashCode());
32 | logtaskName();
33 | mTvTitle = (TextView) findViewById(R.id.tv_title);
34 | mBtnFinish = (Button) findViewById(R.id.btn_finish);
35 | mBtnJump = (Button) findViewById(R.id.btn_2);
36 | mBtnJump.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 | Intent intent = new Intent(BActivity.this,AActivity.class);
40 | startActivity(intent);
41 | }
42 | });
43 | Bundle bundle = getIntent().getExtras();
44 | String name = bundle.getString("name");
45 | int number = bundle.getInt("number");
46 |
47 | mTvTitle.setText(name+","+number);
48 |
49 | mBtnFinish.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | Intent intent = new Intent();
53 | Bundle bundle1 = new Bundle();
54 | bundle1.putString("title","我回来了");
55 | intent.putExtras(bundle1);
56 | setResult(Activity.RESULT_OK,intent);
57 | finish();
58 | }
59 | });
60 | }
61 |
62 | @Override
63 | protected void onNewIntent(Intent intent) {
64 | super.onNewIntent(intent);
65 | Log.d("BActivity","----onNewIntent----");
66 | Log.d("BActivity","taskid:"+getTaskId()+" ,hash:"+hashCode());
67 | logtaskName();
68 | }
69 |
70 | private void logtaskName(){
71 | try {
72 | ActivityInfo info = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
73 | Log.d("BActivity",info.taskAffinity);
74 | } catch (PackageManager.NameNotFoundException e) {
75 | e.printStackTrace();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/listview/ListViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.listview;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.ListView;
9 | import android.widget.Toast;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | /**
14 | * Created by skypan on 2017/8/26.
15 | */
16 |
17 | public class ListViewActivity extends Activity {
18 |
19 | private ListView mLv1;
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_listview);
25 | mLv1 = (ListView) findViewById(R.id.lv_1);
26 | mLv1.setAdapter(new MyListAdapter(ListViewActivity.this));
27 | mLv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
28 | @Override
29 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
30 | Toast.makeText(ListViewActivity.this,"点击 pos:"+position,Toast.LENGTH_SHORT).show();
31 | //跳转
32 | }
33 | });
34 |
35 | mLv1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
36 | @Override
37 | public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
38 | Toast.makeText(ListViewActivity.this,"长按 pos:"+position,Toast.LENGTH_SHORT).show();
39 | return true;
40 | }
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/listview/MyListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.listview;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.skypan.helloworld.R;
13 |
14 | /**
15 | * Created by skypan on 2017/8/26.
16 | */
17 |
18 | public class MyListAdapter extends BaseAdapter {
19 |
20 | private Context mContext;
21 | private LayoutInflater mLayoutInflater;
22 |
23 | public MyListAdapter(Context context){
24 | this.mContext = context;
25 | mLayoutInflater = LayoutInflater.from(context);
26 | }
27 |
28 | @Override
29 | public int getCount() {
30 | return 10;
31 | }
32 |
33 | @Override
34 | public Object getItem(int position) {
35 | return null;
36 | }
37 |
38 | @Override
39 | public long getItemId(int position) {
40 | return 0;
41 | }
42 |
43 | static class ViewHolder{
44 | public ImageView imageView;
45 | public TextView tvTitle,tvTime,tvContent;
46 | }
47 |
48 | @Override
49 | public View getView(int position, View convertView, ViewGroup parent) {
50 | ViewHolder holder = null;
51 | if(convertView == null){
52 | convertView = mLayoutInflater.inflate(R.layout.layout_list_item,null);
53 | holder = new ViewHolder();
54 | holder.imageView = (ImageView) convertView.findViewById(R.id.iv);
55 | holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_title);
56 | holder.tvTime = (TextView) convertView.findViewById(R.id.tv_time);
57 | holder.tvContent = (TextView) convertView.findViewById(R.id.tv_content);
58 | convertView.setTag(holder);
59 | }else{
60 | holder = (ViewHolder) convertView.getTag();
61 | }
62 | //给控件赋值
63 | holder.tvTitle.setText("这是标题");
64 | holder.tvTime.setText("2088-08-08");
65 | holder.tvContent.setText("这是内容");
66 | Glide.with(mContext).load("https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png").into(holder.imageView);
67 | return convertView;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/GridAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | /**
14 | * Created by skypan on 2017/9/2.
15 | */
16 |
17 | public class GridAdapter extends RecyclerView.Adapter {
18 |
19 | private Context mContext;
20 | private OnItemClickListener mListener;
21 |
22 | public GridAdapter(Context context, OnItemClickListener listener){
23 | this.mContext = context;
24 | this.mListener = listener;
25 | }
26 |
27 | @Override
28 | public GridAdapter.LinearViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
29 |
30 | return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_grid_recyclerview_item,parent,false));
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(GridAdapter.LinearViewHolder holder, final int position) {
35 | holder.textView.setText("Hello");
36 | holder.itemView.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 | mListener.onClick(position);
40 | }
41 | });
42 | }
43 |
44 | @Override
45 | public int getItemCount() {
46 | return 80;
47 | }
48 |
49 | class LinearViewHolder extends RecyclerView.ViewHolder {
50 |
51 | private TextView textView;
52 |
53 | public LinearViewHolder(View itemView) {
54 | super(itemView);
55 | textView = (TextView) itemView.findViewById(R.id.tv_title);
56 | }
57 | }
58 |
59 | public interface OnItemClickListener{
60 | void onClick(int pos);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/GridRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.GridLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.widget.Toast;
8 |
9 | import com.skypan.helloworld.R;
10 |
11 | public class GridRecyclerViewActivity extends AppCompatActivity {
12 |
13 | private RecyclerView mRvGrid;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_grid_recycler_view);
19 | mRvGrid = (RecyclerView) findViewById(R.id.rv_grid);
20 | mRvGrid.setLayoutManager(new GridLayoutManager(GridRecyclerViewActivity.this,3));
21 | mRvGrid.setAdapter(new GridAdapter(GridRecyclerViewActivity.this, new GridAdapter.OnItemClickListener() {
22 | @Override
23 | public void onClick(int pos) {
24 | Toast.makeText(GridRecyclerViewActivity.this,"click:"+pos,Toast.LENGTH_SHORT).show();
25 | }
26 | }));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/HorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.skypan.helloworld.R;
11 |
12 | /**
13 | * Created by skypan on 2017/9/2.
14 | */
15 |
16 | public class HorAdapter extends RecyclerView.Adapter {
17 |
18 | private Context mContext;
19 | private OnItemClickListener mListener;
20 |
21 | public HorAdapter(Context context, OnItemClickListener listener){
22 | this.mContext = context;
23 | this.mListener = listener;
24 | }
25 |
26 | @Override
27 | public HorAdapter.LinearViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
28 |
29 | return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_hor_item,parent,false));
30 | }
31 |
32 | @Override
33 | public void onBindViewHolder(HorAdapter.LinearViewHolder holder, final int position) {
34 | holder.textView.setText("Hello");
35 | holder.itemView.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | mListener.onClick(position);
39 | }
40 | });
41 | }
42 |
43 | @Override
44 | public int getItemCount() {
45 | return 30;
46 | }
47 |
48 | class LinearViewHolder extends RecyclerView.ViewHolder {
49 |
50 | private TextView textView;
51 |
52 | public LinearViewHolder(View itemView) {
53 | super(itemView);
54 | textView = (TextView) itemView.findViewById(R.id.tv_title);
55 | }
56 | }
57 |
58 | public interface OnItemClickListener{
59 | void onClick(int pos);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/HorRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | public class HorRecyclerViewActivity extends AppCompatActivity {
14 |
15 | private RecyclerView mRvHor;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_hor_recycler_view);
21 | mRvHor = (RecyclerView) findViewById(R.id.rv_hor);
22 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(HorRecyclerViewActivity.this);
23 | linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
24 | mRvHor.setLayoutManager(linearLayoutManager);
25 | mRvHor.addItemDecoration(new MyDecoration());
26 | mRvHor.setAdapter(new HorAdapter(HorRecyclerViewActivity.this, new HorAdapter.OnItemClickListener() {
27 | @Override
28 | public void onClick(int pos) {
29 | Toast.makeText(HorRecyclerViewActivity.this,"click:"+pos,Toast.LENGTH_SHORT).show();
30 | }
31 | }));
32 | }
33 |
34 | class MyDecoration extends RecyclerView.ItemDecoration{
35 | @Override
36 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
37 | super.getItemOffsets(outRect, view, parent, state);
38 | outRect.set(0,0,getResources().getDimensionPixelOffset(R.dimen.dividerHeight),0);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/LinearAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.skypan.helloworld.R;
13 |
14 | /**
15 | * Created by skypan on 2017/8/31.
16 | */
17 |
18 | public class LinearAdapter extends RecyclerView.Adapter {
19 |
20 | private Context mContext;
21 | private OnItemClickListener mListener;
22 |
23 | public LinearAdapter(Context context,OnItemClickListener listener){
24 | this.mContext = context;
25 | this.mListener = listener;
26 | }
27 |
28 | @Override
29 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
30 | if(viewType == 0){
31 | return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_linear_item,parent,false));
32 | }else{
33 | return new LinearViewHolder2(LayoutInflater.from(mContext).inflate(R.layout.layout_linear_item_2,parent,false));
34 | }
35 | }
36 |
37 | @Override
38 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
39 | if(getItemViewType(position) == 0){
40 | ((LinearViewHolder)holder).textView.setText("Hello World!");
41 | }else{
42 | ((LinearViewHolder2)holder).textView.setText("天哥在奔跑");
43 | }
44 | holder.itemView.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View v) {
47 | mListener.onClick(position);
48 | }
49 | });
50 | }
51 |
52 | @Override
53 | public int getItemViewType(int position) {
54 | if(position % 2 == 0){
55 | return 0;
56 | }else{
57 | return 1;
58 | }
59 | }
60 |
61 | @Override
62 | public int getItemCount() {
63 | return 30;
64 | }
65 |
66 | class LinearViewHolder extends RecyclerView.ViewHolder {
67 |
68 | private TextView textView;
69 |
70 | public LinearViewHolder(View itemView) {
71 | super(itemView);
72 | textView = (TextView) itemView.findViewById(R.id.tv_title);
73 | }
74 | }
75 |
76 | class LinearViewHolder2 extends RecyclerView.ViewHolder {
77 |
78 | private TextView textView;
79 | private ImageView imageView;
80 |
81 | public LinearViewHolder2(View itemView) {
82 | super(itemView);
83 | textView = (TextView) itemView.findViewById(R.id.tv_title);
84 | imageView = (ImageView) itemView.findViewById(R.id.iv_image);
85 | }
86 | }
87 |
88 | public interface OnItemClickListener{
89 | void onClick(int pos);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/LinearRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.graphics.Rect;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.KeyEvent;
9 | import android.view.View;
10 | import android.webkit.WebView;
11 | import android.widget.Toast;
12 |
13 | import com.skypan.helloworld.R;
14 |
15 | public class LinearRecyclerViewActivity extends AppCompatActivity {
16 |
17 | private RecyclerView mRvMain;
18 | private WebView webView;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_linear_recycler_view);
24 | mRvMain = (RecyclerView) findViewById(R.id.rv_main);
25 | mRvMain.setLayoutManager(new LinearLayoutManager(LinearRecyclerViewActivity.this));
26 | mRvMain.addItemDecoration(new MyDecoration());
27 | mRvMain.setAdapter(new LinearAdapter(LinearRecyclerViewActivity.this, new LinearAdapter.OnItemClickListener() {
28 | @Override
29 | public void onClick(int pos) {
30 | Toast.makeText(LinearRecyclerViewActivity.this, "click " + pos, Toast.LENGTH_SHORT).show();
31 | }
32 | }));
33 | }
34 |
35 | @Override
36 | public boolean onKeyDown(int keyCode, KeyEvent event) {
37 | if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
38 | webView.goBack();
39 | return true;
40 | }
41 | return super.onKeyDown(keyCode, event);
42 | }
43 |
44 | class MyDecoration extends RecyclerView.ItemDecoration {
45 | @Override
46 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
47 | super.getItemOffsets(outRect, view, parent, state);
48 | outRect.set(0, 0, 0, getResources().getDimensionPixelOffset(R.dimen.dividerHeight));
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/PuRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.support.v7.widget.StaggeredGridLayoutManager;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | public class PuRecyclerViewActivity extends AppCompatActivity {
14 |
15 | private RecyclerView mRvPu;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_pu_recycler_view);
21 | mRvPu = (RecyclerView) findViewById(R.id.rv_pu);
22 | mRvPu.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
23 | mRvPu.addItemDecoration(new MyDecoration());
24 | mRvPu.setAdapter(new StaggeredGridAdapter(PuRecyclerViewActivity.this, new StaggeredGridAdapter.OnItemClickListener() {
25 | @Override
26 | public void onClick(int pos) {
27 | Toast.makeText(PuRecyclerViewActivity.this,"click:"+pos,Toast.LENGTH_SHORT).show();
28 | }
29 | }));
30 | }
31 |
32 | class MyDecoration extends RecyclerView.ItemDecoration{
33 | @Override
34 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
35 | super.getItemOffsets(outRect, view, parent, state);
36 | int gap = getResources().getDimensionPixelSize(R.dimen.dividerHeight2);
37 | outRect.set(gap,gap,gap,gap);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.skypan.helloworld.R;
10 |
11 | public class RecyclerViewActivity extends AppCompatActivity {
12 |
13 | private Button mBtnLinear,mBtnHor,mBtnGrid,mBtnPu;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_recycler_view);
19 | mBtnLinear = (Button) findViewById(R.id.btn_linear);
20 | mBtnHor = (Button) findViewById(R.id.btn_hor);
21 | mBtnGrid = (Button) findViewById(R.id.btn_grid);
22 | mBtnPu = (Button) findViewById(R.id.btn_pu);
23 | mBtnLinear.setOnClickListener(new View.OnClickListener() {
24 | @Override
25 | public void onClick(View v) {
26 | Intent intent = new Intent(RecyclerViewActivity.this,LinearRecyclerViewActivity.class);
27 | startActivity(intent);
28 | }
29 | });
30 | mBtnHor.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | Intent intent = new Intent(RecyclerViewActivity.this,HorRecyclerViewActivity.class);
34 | startActivity(intent);
35 | }
36 | });
37 | mBtnGrid.setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | Intent intent = new Intent(RecyclerViewActivity.this,GridRecyclerViewActivity.class);
41 | startActivity(intent);
42 | }
43 | });
44 | mBtnPu.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View v) {
47 | Intent intent = new Intent(RecyclerViewActivity.this,PuRecyclerViewActivity.class);
48 | startActivity(intent);
49 | }
50 | });
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/recyclerview/StaggeredGridAdapter.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.skypan.helloworld.R;
12 |
13 | /**
14 | * Created by skypan on 2017/9/2.
15 | */
16 |
17 | public class StaggeredGridAdapter extends RecyclerView.Adapter {
18 |
19 | private Context mContext;
20 | private OnItemClickListener mListener;
21 |
22 | public StaggeredGridAdapter(Context context, OnItemClickListener listener){
23 | this.mContext = context;
24 | this.mListener = listener;
25 | }
26 |
27 | @Override
28 | public StaggeredGridAdapter.LinearViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
29 |
30 | return new LinearViewHolder(LayoutInflater.from(mContext).inflate(R.layout.layout_staggered_grid_recyclerview_item,parent,false));
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(StaggeredGridAdapter.LinearViewHolder holder, final int position) {
35 | if(position % 2 != 0){
36 | holder.imageView.setImageResource(R.drawable.image1);
37 | }else{
38 | holder.imageView.setImageResource(R.drawable.image2);
39 | }
40 | holder.itemView.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | mListener.onClick(position);
44 | }
45 | });
46 | }
47 |
48 | @Override
49 | public int getItemCount() {
50 | return 30;
51 | }
52 |
53 | class LinearViewHolder extends RecyclerView.ViewHolder {
54 |
55 | private ImageView imageView;
56 |
57 | public LinearViewHolder(View itemView) {
58 | super(itemView);
59 | imageView = (ImageView) itemView.findViewById(R.id.iv);
60 | }
61 | }
62 |
63 | public interface OnItemClickListener{
64 | void onClick(int pos);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/util/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.util;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by skypan on 2017/9/5.
8 | */
9 |
10 | public class ToastUtil {
11 | public static Toast mToast;
12 | public static void showMsg(Context context,String msg){
13 | if(mToast == null){
14 | mToast = Toast.makeText(context,msg,Toast.LENGTH_LONG);
15 | }else{
16 | mToast.setText(msg);
17 | }
18 | mToast.show();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skypan/helloworld/widget/CustomDialog.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld.widget;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.graphics.Point;
6 | import android.os.Bundle;
7 | import android.support.annotation.NonNull;
8 | import android.text.TextUtils;
9 | import android.view.Display;
10 | import android.view.View;
11 | import android.view.WindowManager;
12 | import android.widget.TextView;
13 |
14 | import com.skypan.helloworld.R;
15 |
16 | /**
17 | * Created by skypan on 2017/9/8.
18 | */
19 |
20 | public class CustomDialog extends Dialog implements View.OnClickListener{
21 |
22 | private TextView mTvTitle,mTvMessage,mTvCancel,mTvConfirm;
23 |
24 | private String title,message,cancel,confirm;
25 |
26 | private IOnCancelListener cancelListener;
27 |
28 | private IOnConfirmListener confirmListener;
29 |
30 | public CustomDialog(@NonNull Context context) {
31 | super(context);
32 | }
33 |
34 | public CustomDialog(@NonNull Context context,int themeId) {
35 | super(context,themeId);
36 | }
37 |
38 | public CustomDialog setTitle(String title) {
39 | this.title = title;
40 | return this;
41 | }
42 |
43 | public CustomDialog setMessage(String message) {
44 | this.message = message;
45 | return this;
46 | }
47 |
48 | public CustomDialog setCancel(String cancel,IOnCancelListener listener) {
49 | this.cancel = cancel;
50 | this.cancelListener = listener;
51 | return this;
52 | }
53 |
54 | public CustomDialog setConfirm(String confirm,IOnConfirmListener listener) {
55 | this.confirm = confirm;
56 | this.confirmListener = listener;
57 | return this;
58 | }
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.layout_custom_dialog);
64 | //设置宽度
65 | WindowManager m = getWindow().getWindowManager();
66 | Display d = m.getDefaultDisplay();
67 | WindowManager.LayoutParams p = getWindow().getAttributes();
68 | Point size = new Point();
69 | d.getSize(size);
70 | p.width = (int)(size.x * 0.8); //设置dialog的宽度为当前手机屏幕的宽度*0.8
71 | getWindow().setAttributes(p);
72 |
73 | mTvTitle = (TextView) findViewById(R.id.tv_title);
74 | mTvMessage = (TextView) findViewById(R.id.tv_message);
75 | mTvCancel = (TextView) findViewById(R.id.tv_cancel);
76 | mTvConfirm = (TextView) findViewById(R.id.tv_confirm);
77 | if(!TextUtils.isEmpty(title)){
78 | mTvTitle.setText(title);
79 | }
80 | if(!TextUtils.isEmpty(message)){
81 | mTvMessage.setText(message);
82 | }
83 | if(!TextUtils.isEmpty(cancel)){
84 | mTvCancel.setText(cancel);
85 | }
86 | if(!TextUtils.isEmpty(confirm)){
87 | mTvConfirm.setText(confirm);
88 | }
89 | mTvCancel.setOnClickListener(this);
90 | mTvConfirm.setOnClickListener(this);
91 | }
92 |
93 | @Override
94 | public void onClick(View v) {
95 | switch (v.getId()){
96 | case R.id.tv_cancel:
97 | if(cancelListener != null){
98 | cancelListener.onCancel(this);
99 | }
100 | dismiss();
101 | break;
102 | case R.id.tv_confirm:
103 | if(confirmListener != null){
104 | confirmListener.onConfirm(this);
105 | }
106 | dismiss();
107 | break;
108 | }
109 | }
110 |
111 | public interface IOnCancelListener{
112 | void onCancel(CustomDialog dialog);
113 | }
114 |
115 | public interface IOnConfirmListener{
116 | void onConfirm(CustomDialog dialog);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/bg_dropdown.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/bg_dropdown.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/bg_iron_man.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/bg_iron_man.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_arrow_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_arrow_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_checkbox_false.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_checkbox_false.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_checkbox_true.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_checkbox_true.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_password.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_password.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_progress.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_smile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_smile.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/icon_user.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/image1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/drawable-xxhdpi/image2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn2.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn3.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_checkbox.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_custom_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_username.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_orange.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_orange_radiobutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
11 |
12 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
15 |
25 |
26 |
36 |
37 |
48 |
49 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_check_box.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
33 |
34 |
42 |
43 |
51 |
52 |
58 |
64 |
65 |
74 |
75 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
19 |
25 |
31 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
21 |
22 |
38 |
39 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_grid_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gridview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_hor_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
24 |
25 |
35 |
36 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_linear_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_listview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_popup_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
31 |
32 |
41 |
42 |
48 |
49 |
55 |
56 |
63 |
64 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pu_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_radio_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
20 |
27 |
28 |
29 |
36 |
47 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
24 |
25 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
15 |
25 |
26 |
36 |
37 |
45 |
46 |
54 |
55 |
63 |
64 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
16 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_ui.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
17 |
18 |
24 |
25 |
31 |
32 |
38 |
39 |
45 |
46 |
52 |
53 |
59 |
60 |
66 |
67 |
73 |
74 |
80 |
81 |
87 |
88 |
94 |
95 |
101 |
102 |
108 |
109 |
115 |
116 |
122 |
123 |
129 |
130 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
26 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_custom_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
29 |
33 |
34 |
38 |
39 |
48 |
49 |
53 |
54 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
20 |
21 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_grid_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_grid_recyclerview_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_hor_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_linear_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_linear_item_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
16 |
21 |
28 |
29 |
37 |
38 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_pop.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
23 |
24 |
33 |
34 |
38 |
39 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_staggered_grid_recyclerview_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
18 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #000000
7 | #D5D5D5
8 | #808080
9 | #FFFFFF
10 | #00000000
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1dp
4 | 5dp
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloWorld
3 | 天哥在奔跑
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
15 |
16 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/test/java/com/skypan/helloworld/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.skypan.helloworld;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skypan-yes/AndroidCourse/bc102d9737cca12c2f49757474673c4fcd96b08d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 22 21:35:35 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------