├── .classpath
├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── socks
│ │ └── androiddemo
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── socks
│ │ └── androiddemo
│ │ ├── base
│ │ ├── BaseActivity.java
│ │ ├── Initialable.java
│ │ └── MyApplication.java
│ │ ├── task
│ │ └── TaskLoader.java
│ │ ├── test
│ │ └── TestClass.java
│ │ ├── ui
│ │ ├── AllActivity.java
│ │ ├── AnimatorActivity.java
│ │ ├── ApkFileInfoActivity.java
│ │ ├── BitmapShaderActivity.java
│ │ ├── Camera3DActivity.java
│ │ ├── CanvasActivity.java
│ │ ├── ColorMatrixActivity.java
│ │ ├── ConfirmActivity.java
│ │ ├── FllowerActivity.java
│ │ ├── FloatingActionButtonActivity.java
│ │ ├── FocusActivity.java
│ │ ├── FragmentsActivity.java
│ │ ├── IntentActivity.java
│ │ ├── LoadActivity.java
│ │ ├── MatrixActivity.java
│ │ ├── MenuActivity.java
│ │ ├── MuService.java
│ │ ├── MyIntentService.java
│ │ ├── NotifycationActivity.java
│ │ ├── OtherActivity.java
│ │ ├── PointViewActivity.java
│ │ ├── ReflectionActivity.java
│ │ ├── ShaderActivity.java
│ │ ├── SpannableActivity.java
│ │ ├── SparseDemo.java
│ │ └── UtilsActivity.java
│ │ ├── utils
│ │ ├── MeasureUtil.java
│ │ ├── cache
│ │ │ └── DiskLruCache.java
│ │ └── logger
│ │ │ ├── LogLevel.java
│ │ │ ├── Logger.java
│ │ │ └── WakeLocker.java
│ │ └── view
│ │ ├── BitmapShaderView.java
│ │ ├── CanvasView.java
│ │ ├── ColorEvaluator.java
│ │ ├── ConfirmView.java
│ │ ├── FllowerView.java
│ │ ├── InnerListview.java
│ │ ├── LightingColorFilterView.java
│ │ ├── PathView.java
│ │ ├── Point.java
│ │ ├── PointEvaluator.java
│ │ ├── PointView.java
│ │ ├── ShaderView.java
│ │ ├── TextPaintView.java
│ │ └── Titanic.java
│ └── res
│ ├── drawable
│ ├── grediat.xml
│ ├── ic_heart.png
│ ├── sophie.gif
│ └── wave.png
│ ├── layout
│ ├── activity_all.xml
│ ├── activity_animator.xml
│ ├── activity_bitmap_shader.xml
│ ├── activity_camera_3d.xml
│ ├── activity_canvas.xml
│ ├── activity_color_matrix.xml
│ ├── activity_confirm.xml
│ ├── activity_fllower.xml
│ ├── activity_floating_button.xml
│ ├── activity_focus.xml
│ ├── activity_half_width.xml
│ ├── activity_intent.xml
│ ├── activity_load.xml
│ ├── activity_main.xml
│ ├── activity_notifycation.xml
│ ├── activity_other.xml
│ ├── activity_pointview.xml
│ ├── activity_shader.xml
│ ├── activity_spannable.xml
│ ├── activity_test_transform_matrix.xml
│ ├── activity_utils.xml
│ └── item_activitys.xml
│ ├── menu
│ ├── menu_intent.xml
│ ├── menu_load.xml
│ ├── menu_main.xml
│ ├── menu_test_transform_matrix.xml
│ └── menu_utils.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.classpath
2 | *.project
3 | *.txt
4 | *.swp
5 | .DS_Store
6 | .idea/
7 | .gradle/
8 | build/
9 | app/build/
10 | *.iml
11 | app/app.iml
12 | local.properties
13 | app/flavors.gradle
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | AndroidDemo
--------------------------------------------------------------------------------
/.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/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | localhost
154 | 5050
155 |
156 |
157 |
158 |
159 |
160 |
161 | 1443519311032
162 |
163 | 1443519311032
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AndroidDemo
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidDemo
2 | 凯子哥御用的API测试Demo集合,
3 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | *.classpath
2 | *.project
3 | *.txt
4 | *.swp
5 | .DS_Store
6 | .idea/
7 | .gradle/
8 | build/
9 | app/build/
10 | *.iml
11 | app/app.iml
12 | local.properties
13 | app/flavors.gradle
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '23.0.1'
6 | defaultConfig {
7 | applicationId "com.socks.androiddemo"
8 | minSdkVersion 14
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | productFlavors {
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile 'com.android.support:support-v4:23.0.0'
26 | compile 'com.android.support:appcompat-v7:23.0.0'
27 | compile 'com.android.support:design:23.0.1'
28 | }
29 |
--------------------------------------------------------------------------------
/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/zhaokaiqiang/Develop/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/socks/androiddemo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
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/java/com/socks/androiddemo/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.base;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | public class BaseActivity extends AppCompatActivity implements Initialable {
8 |
9 | protected Context context;
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | context = this;
15 | }
16 |
17 | @Override
18 | public void initView() {
19 |
20 | }
21 |
22 | @Override
23 | public void initDate() {
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/base/Initialable.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.base;
2 |
3 | /**
4 | * ��ʼ���ӿ�
5 | *
6 | * @ClassName: Initialable
7 | * @author ZhaoKaiQiang
8 | * @date 2015-3-27 ����11:23:11
9 | */
10 | public interface Initialable {
11 |
12 | void initView();
13 |
14 | void initDate();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/base/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.base;
2 |
3 | import android.app.Application;
4 |
5 | import com.socks.androiddemo.utils.logger.LogLevel;
6 | import com.socks.androiddemo.utils.logger.Logger;
7 |
8 | public class MyApplication extends Application {
9 |
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 | Logger.init("debugTAG").setLogLevel(LogLevel.FULL).hideThreadInfo();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/task/TaskLoader.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.task;
2 |
3 | import android.content.AsyncTaskLoader;
4 | import android.content.Context;
5 |
6 | /**
7 | * Created by zhaokaiqiang on 15/3/31.
8 | */
9 | public class TaskLoader extends AsyncTaskLoader {
10 |
11 | public TaskLoader(Context context) {
12 | super(context);
13 | }
14 |
15 | @Override
16 | public Object loadInBackground() {
17 | return null;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/test/TestClass.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.test;
2 |
3 | import android.test.AndroidTestCase;
4 | import android.util.Log;
5 |
6 | import java.io.ByteArrayOutputStream;
7 | import java.io.IOException;
8 | import java.util.zip.GZIPOutputStream;
9 |
10 | /**
11 | * Created by zhaokaiqiang on 15/3/29.
12 | */
13 | public class TestClass extends AndroidTestCase {
14 |
15 | public void testCompress() throws IOException {
16 | Log.d("TAG", compress("123456789123"));
17 | }
18 |
19 | public static String compress(String str) throws IOException {
20 | if (str == null || str.length() == 0) {
21 | return str;
22 | }
23 | ByteArrayOutputStream out = new ByteArrayOutputStream();
24 | GZIPOutputStream gzip = new GZIPOutputStream(out);
25 | gzip.write(str.getBytes());
26 | gzip.close();
27 | return out.toString("UTF-8");
28 | }
29 |
30 |
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/AllActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.AdapterView;
9 | import android.widget.AdapterView.OnItemClickListener;
10 | import android.widget.BaseAdapter;
11 | import android.widget.ListView;
12 | import android.widget.TextView;
13 |
14 | import com.socks.androiddemo.R.id;
15 | import com.socks.androiddemo.R.layout;
16 | import com.socks.androiddemo.base.BaseActivity;
17 |
18 | import java.util.ArrayList;
19 |
20 | public class AllActivity extends BaseActivity {
21 |
22 | private ListView lv;
23 | private AllActivityAdapter adater;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(layout.activity_all);
29 | lv = (ListView) findViewById(id.lv);
30 | adater = new AllActivityAdapter();
31 | lv.setAdapter(adater);
32 | lv.setOnItemClickListener(new OnItemClickListener() {
33 |
34 | @Override
35 | public void onItemClick(AdapterView> parent, View view,
36 | int position, long id) {
37 | startActivity(new Intent(AllActivity.this, adater.getItem(
38 | position).getActivityClass()));
39 | }
40 | });
41 |
42 | }
43 |
44 | private class AllActivityAdapter extends BaseAdapter {
45 |
46 | private ArrayList activityModels;
47 |
48 | public AllActivityAdapter() {
49 | activityModels = new ArrayList();
50 | activityModels.add(new ActivityModel("SpannbleString",
51 | SpannableActivity.class));
52 | activityModels.add(new ActivityModel("Notification",
53 | NotifycationActivity.class));
54 | activityModels.add(new ActivityModel("OtherActivity",
55 | OtherActivity.class));
56 | activityModels.add(new ActivityModel("IntentActivity",
57 | IntentActivity.class));
58 | activityModels.add(new ActivityModel("UtilsActivity",
59 | UtilsActivity.class));
60 | activityModels.add(new ActivityModel("ReflectionActivity",
61 | ReflectionActivity.class));
62 | activityModels.add(new ActivityModel("FocusActivity",
63 | FocusActivity.class));
64 | activityModels.add(new ActivityModel("MenuActivity",
65 | MenuActivity.class));
66 | activityModels.add(new ActivityModel("AnimatorActivity",
67 | AnimatorActivity.class));
68 | activityModels.add(new ActivityModel("PointViewActivity",
69 | PointViewActivity.class));
70 | activityModels.add(new ActivityModel("Camera3DActivity",
71 | Camera3DActivity.class));
72 | activityModels.add(new ActivityModel("MatrixActivity",
73 | MatrixActivity.class));
74 | activityModels.add(new ActivityModel("ApkFileInfoActivity",
75 | ApkFileInfoActivity.class));
76 | activityModels.add(new ActivityModel("BitmapShaderActivity",
77 | BitmapShaderActivity.class));
78 | activityModels.add(new ActivityModel("ColorMatrixActivity",
79 | ColorMatrixActivity.class));
80 | activityModels.add(new ActivityModel("FllowerActivity",
81 | FllowerActivity.class));
82 | activityModels.add(new ActivityModel("ConfirmActivity",
83 | ConfirmActivity.class));
84 | activityModels.add(new ActivityModel("ShaderActivity",
85 | ShaderActivity.class));
86 | activityModels.add(new ActivityModel("CanvasActivity",
87 | CanvasActivity.class));
88 | activityModels.add(new ActivityModel("FloatingActionButtonActivity",
89 | FloatingActionButtonActivity.class));
90 | }
91 |
92 | @Override
93 | public int getCount() {
94 | return activityModels.size();
95 | }
96 |
97 | @Override
98 | public ActivityModel getItem(int position) {
99 | return activityModels.get(position);
100 | }
101 |
102 | @Override
103 | public long getItemId(int position) {
104 | return 0;
105 | }
106 |
107 | @Override
108 | public View getView(int position, View convertView, ViewGroup parent) {
109 |
110 | ViewHolder viewHolder;
111 | ActivityModel model = activityModels.get(position);
112 |
113 | if (convertView == null) {
114 |
115 | convertView = getLayoutInflater().inflate(
116 | layout.item_activitys, parent, false);
117 | viewHolder = new ViewHolder();
118 | viewHolder.tv_title = (TextView) convertView
119 | .findViewById(id.tv_title);
120 | convertView.setTag(viewHolder);
121 | } else {
122 | viewHolder = (ViewHolder) convertView.getTag();
123 | }
124 |
125 | viewHolder.tv_title.setText(model.getTitle());
126 |
127 | return convertView;
128 | }
129 |
130 | }
131 |
132 | private static class ViewHolder {
133 | TextView tv_title;
134 | }
135 |
136 | private class ActivityModel {
137 |
138 | private String title;
139 | private Class extends Activity> activityClass;
140 |
141 | public ActivityModel(String title,
142 | Class extends Activity> activityClass) {
143 | this.title = title;
144 | this.activityClass = activityClass;
145 | }
146 |
147 | public String getTitle() {
148 | return title;
149 | }
150 |
151 | public Class extends Activity> getActivityClass() {
152 | return activityClass;
153 | }
154 |
155 | }
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/AnimatorActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.animation.ValueAnimator;
5 | import android.app.Activity;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Button;
10 |
11 | import com.socks.androiddemo.R;
12 |
13 | /**
14 | * Created by zhaokaiqiang on 15/8/16.
15 | */
16 | public class AnimatorActivity extends Activity {
17 |
18 |
19 | private Button btn_one;
20 | private Button btn_two;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_animator);
26 |
27 | btn_one = (Button) findViewById(R.id.btn_one);
28 | btn_two = (Button) findViewById(R.id.btn_two);
29 |
30 | }
31 |
32 | public void startValue(View view) {
33 | ValueAnimator animator = ValueAnimator.ofFloat(0, 50);
34 | animator.setDuration(2000);
35 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
36 | @Override
37 | public void onAnimationUpdate(ValueAnimator animation) {
38 |
39 | float values = (float) animation.getAnimatedValue();
40 | Log.d("AnimatorActivity", "values = " + values);
41 | btn_one.setTextSize(values);
42 | }
43 | });
44 | animator.start();
45 | }
46 |
47 | public void startObject(View view) {
48 | ObjectAnimator animator = ObjectAnimator.ofFloat(btn_two, "textSize", 0f, 50f);
49 | animator.setDuration(2000);
50 | animator.start();
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/ApkFileInfoActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.PackageManager;
5 | import android.os.Bundle;
6 | import android.os.Environment;
7 | import android.util.Log;
8 |
9 | import com.socks.androiddemo.base.BaseActivity;
10 |
11 | import java.io.File;
12 |
13 | /**
14 | * Created by zhaokaiqiang on 15/8/26.
15 | */
16 | public class ApkFileInfoActivity extends BaseActivity {
17 |
18 | private static final String TAG = "ApkFileInfoActivity";
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 |
25 | File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
26 | File apkFile = new File(file, "提分初中.apk");
27 | PackageManager packageManager = getPackageManager();
28 | PackageInfo info = packageManager.getPackageArchiveInfo(apkFile.getPath(), PackageManager.GET_ACTIVITIES);
29 |
30 | if (info != null) {
31 | Log.d(TAG, "提分初中.apk packageName =" + info.packageName);
32 | }
33 |
34 | File otherFile = new File(file, "巴朵游戏.apk");
35 | PackageInfo otherInfo = packageManager.getPackageArchiveInfo(otherFile.getPath(), PackageManager.GET_ACTIVITIES);
36 |
37 | if (otherInfo != null) {
38 | Log.d(TAG, "巴朵游戏.apk packageName =" + otherInfo.packageName);
39 | Log.d(TAG, "巴朵游戏.apk versionCode =" + otherInfo.versionCode);
40 | Log.d(TAG, "巴朵游戏.apk versionName =" + otherInfo.versionName);
41 |
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/BitmapShaderActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.socks.androiddemo.R;
6 | import com.socks.androiddemo.base.BaseActivity;
7 | import com.socks.androiddemo.view.BitmapShaderView;
8 | import com.socks.androiddemo.view.Titanic;
9 |
10 | /**
11 | * Created by zhaokaiqiang on 15/9/7.
12 | */
13 | public class BitmapShaderActivity extends BaseActivity {
14 |
15 | private BitmapShaderView shaderView;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_bitmap_shader);
21 | shaderView = (BitmapShaderView) findViewById(R.id.shader);
22 | new Titanic().start(shaderView);
23 |
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/Camera3DActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Camera;
7 | import android.graphics.Matrix;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.widget.ImageView;
11 | import android.widget.SeekBar;
12 | import android.widget.TextView;
13 |
14 | import com.socks.androiddemo.R;
15 | import com.socks.androiddemo.base.BaseActivity;
16 |
17 | /**
18 | * Created by zhaokaiqiang on 15/8/24.
19 | */
20 | public class Camera3DActivity extends BaseActivity implements SeekBar.OnSeekBarChangeListener {
21 |
22 | private static final String TAG = "Camera3DActivity";
23 |
24 | private SeekBar sb_rotate_x;
25 | private TextView tv_rotate_x;
26 | private ImageView img_rorate_x;
27 |
28 | private SeekBar sb_rotate_y;
29 | private TextView tv_rotate_y;
30 | private ImageView img_rorate_y;
31 |
32 | private SeekBar sb_rotate_z;
33 | private TextView tv_rotate_z;
34 | private ImageView img_rorate_z;
35 |
36 | private ImageView img_rotate_xyz;
37 |
38 | private SeekBar sb_translate_x;
39 | private TextView tv_translate_x;
40 | private ImageView img_translate_x;
41 |
42 | private SeekBar sb_translate_y;
43 | private TextView tv_translate_y;
44 | private ImageView img_translate_y;
45 |
46 | private SeekBar sb_translate_z;
47 | private TextView tv_translate_z;
48 | private ImageView img_translate_z;
49 |
50 | private ImageView img_translate_xyz;
51 |
52 | private Camera mCamera;
53 | private Matrix mMatrix;
54 |
55 | private static Bitmap mBitmap;
56 |
57 | private Bitmap temBitmap;
58 |
59 | private int rotateX;
60 | private int rotateY;
61 | private int rotateZ;
62 |
63 | private int width;
64 | private int height;
65 |
66 | @Override
67 | protected void onCreate(Bundle savedInstanceState) {
68 | super.onCreate(savedInstanceState);
69 | setContentView(R.layout.activity_camera_3d);
70 |
71 | sb_rotate_x = (SeekBar) findViewById(R.id.sb_rotate_x);
72 | img_rorate_x = (ImageView) findViewById(R.id.img_rorate_x);
73 | tv_rotate_x = (TextView) findViewById(R.id.tv_rotate_x);
74 |
75 | sb_rotate_y = (SeekBar) findViewById(R.id.sb_rotate_y);
76 | img_rorate_y = (ImageView) findViewById(R.id.img_rorate_y);
77 | tv_rotate_y = (TextView) findViewById(R.id.tv_rotate_y);
78 |
79 | sb_rotate_z = (SeekBar) findViewById(R.id.sb_rotate_z);
80 | img_rorate_z = (ImageView) findViewById(R.id.img_rorate_z);
81 | tv_rotate_z = (TextView) findViewById(R.id.tv_rotate_z);
82 |
83 | img_rotate_xyz = (ImageView) findViewById(R.id.img_rorate_xyz);
84 |
85 | sb_translate_x = (SeekBar) findViewById(R.id.sb_translate_x);
86 | tv_translate_x = (TextView) findViewById(R.id.tv_translate_x);
87 | img_translate_x = (ImageView) findViewById(R.id.img_translate_x);
88 |
89 | sb_translate_y = (SeekBar) findViewById(R.id.sb_translate_y);
90 | tv_translate_y = (TextView) findViewById(R.id.tv_translate_y);
91 | img_translate_y = (ImageView) findViewById(R.id.img_translate_y);
92 |
93 | sb_translate_z = (SeekBar) findViewById(R.id.sb_translate_z);
94 | tv_translate_z = (TextView) findViewById(R.id.tv_translate_z);
95 | img_translate_z = (ImageView) findViewById(R.id.img_translate_z);
96 |
97 | sb_rotate_x.setOnSeekBarChangeListener(this);
98 | sb_rotate_y.setOnSeekBarChangeListener(this);
99 | sb_rotate_z.setOnSeekBarChangeListener(this);
100 | sb_translate_x.setOnSeekBarChangeListener(this);
101 | sb_translate_y.setOnSeekBarChangeListener(this);
102 | sb_translate_z.setOnSeekBarChangeListener(this);
103 |
104 | init();
105 | }
106 |
107 | private void init() {
108 | mCamera = new Camera();
109 | mMatrix = new Matrix();
110 | mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
111 | width = mBitmap.getWidth();
112 | height = mBitmap.getHeight();
113 | }
114 |
115 | @Override
116 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
117 |
118 | if (seekBar == sb_rotate_x) {
119 | rotate_x(progress);
120 | tv_rotate_x.setText(Integer.toString(progress));
121 | } else if (seekBar == sb_rotate_y) {
122 | rotate_y(progress);
123 | tv_rotate_y.setText(Integer.toString(progress));
124 | } else if (seekBar == sb_rotate_z) {
125 | rotate_z(progress);
126 | tv_rotate_z.setText(Integer.toString(progress));
127 | } else if (seekBar == sb_translate_x) {
128 | tv_translate_x.setText("" + (progress - 500));
129 | translateX(progress - 500);
130 | // locationX(progress - 500);
131 | } else if (seekBar == sb_translate_z) {
132 | tv_translate_z.setText("" + (progress - 200));
133 | translateZ(progress - 200);
134 | } else if (seekBar == sb_translate_y) {
135 | tv_translate_y.setText("" + (progress - 100));
136 | translateY(progress - 100);
137 | }
138 |
139 | }
140 |
141 | private void rotate_x(int progress) {
142 |
143 | rotateX = progress;
144 | rotateXYZ();
145 |
146 | mCamera.save();
147 | mCamera.rotateX(progress);
148 | mCamera.getMatrix(mMatrix);
149 |
150 | mMatrix.preTranslate(-(img_rorate_x.getWidth() / 2), -(img_rorate_x.getHeight() / 2));
151 | mMatrix.postTranslate((img_rorate_x.getWidth() / 2), (img_rorate_x.getHeight() / 2));
152 |
153 | try {
154 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
155 | } catch (Exception e) {
156 | e.printStackTrace();
157 | }
158 | mCamera.restore();
159 | mMatrix.reset();
160 |
161 | if (temBitmap != null) {
162 | img_rorate_x.setImageBitmap(temBitmap);
163 | }
164 |
165 | }
166 |
167 | private void rotate_y(int progress) {
168 |
169 | rotateY = progress;
170 | rotateXYZ();
171 |
172 | mCamera.save();
173 | mCamera.rotateY(progress);
174 | mCamera.getMatrix(mMatrix);
175 |
176 | try {
177 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
178 | } catch (Exception e) {
179 | e.printStackTrace();
180 | }
181 | mCamera.restore();
182 | mMatrix.reset();
183 |
184 | if (temBitmap != null) {
185 | img_rorate_y.setImageBitmap(temBitmap);
186 | }
187 |
188 | }
189 |
190 | private void rotate_z(int progress) {
191 |
192 | rotateZ = progress;
193 | rotateXYZ();
194 |
195 | mCamera.save();
196 | mCamera.rotateZ(progress);
197 | mCamera.getMatrix(mMatrix);
198 |
199 | try {
200 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
201 | } catch (Exception e) {
202 | e.printStackTrace();
203 | }
204 | mCamera.restore();
205 | mMatrix.reset();
206 |
207 | if (temBitmap != null) {
208 | img_rorate_z.setImageBitmap(temBitmap);
209 | }
210 |
211 | }
212 |
213 | private void rotateXYZ() {
214 |
215 | mCamera.save();
216 | mCamera.rotateX(rotateX);
217 | mCamera.rotateY(rotateY);
218 | mCamera.rotateZ(rotateZ);
219 | mCamera.getMatrix(mMatrix);
220 |
221 | try {
222 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
223 | } catch (Exception e) {
224 | e.printStackTrace();
225 | }
226 | mCamera.restore();
227 | mMatrix.reset();
228 |
229 | if (temBitmap != null) {
230 | img_rotate_xyz.setImageBitmap(temBitmap);
231 | }
232 |
233 | }
234 |
235 | @TargetApi(16)
236 | private void translateX(float progress) {
237 | Log.d(TAG, "x = " + mCamera.getLocationX() + " y = " + mCamera.getLocationY() + " z = " + mCamera.getLocationZ());
238 | mCamera.save();
239 | mCamera.translate(progress, 0, 0);
240 | mCamera.getMatrix(mMatrix);
241 | try {
242 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
243 | } catch (Exception e) {
244 | e.printStackTrace();
245 | }
246 | Log.d(TAG, "x = " + mCamera.getLocationX() + " y = " + mCamera.getLocationY() + " z = " + mCamera.getLocationZ());
247 | mCamera.restore();
248 | mMatrix.reset();
249 |
250 | if (temBitmap != null) {
251 | img_translate_x.setImageBitmap(temBitmap);
252 | }
253 | }
254 |
255 | private void translateY(float progress) {
256 | mCamera.save();
257 | mCamera.translate(0, progress, 0);
258 | Log.d(TAG, "translateY--" + progress);
259 | mCamera.getMatrix(mMatrix);
260 | try {
261 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
262 | } catch (Exception e) {
263 | e.printStackTrace();
264 | }
265 | mCamera.restore();
266 | mMatrix.reset();
267 |
268 | if (temBitmap != null) {
269 | img_translate_y.setImageBitmap(temBitmap);
270 | }
271 | }
272 |
273 | @TargetApi(16)
274 | private void translateZ(float progress) {
275 |
276 | mCamera.save();
277 | mCamera.translate(progress, progress, progress);
278 | mCamera.getMatrix(mMatrix);
279 | try {
280 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
281 | } catch (Exception e) {
282 | e.printStackTrace();
283 | }
284 | mCamera.restore();
285 | mMatrix.reset();
286 |
287 | if (temBitmap != null) {
288 | img_translate_z.setImageBitmap(temBitmap);
289 |
290 | }
291 | }
292 |
293 | @TargetApi(16)
294 | private void locationX(float progress) {
295 |
296 | mCamera.save();
297 | mCamera.translate(0, 0, progress);
298 | // mCamera.setLocation(progress,0,0);
299 | mCamera.getMatrix(mMatrix);
300 | try {
301 | temBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, mMatrix, true);
302 | } catch (Exception e) {
303 | e.printStackTrace();
304 | }
305 | Log.d(TAG, "x = " + mCamera.getLocationX() + " y = " + mCamera.getLocationY() + " z = " + mCamera.getLocationZ());
306 | mCamera.restore();
307 | mMatrix.reset();
308 |
309 | if (temBitmap != null) {
310 | img_translate_x.setImageBitmap(temBitmap);
311 |
312 | }
313 | }
314 |
315 |
316 | @Override
317 | public void onStartTrackingTouch(SeekBar seekBar) {
318 |
319 | }
320 |
321 | @Override
322 | public void onStopTrackingTouch(SeekBar seekBar) {
323 |
324 | }
325 | }
326 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/CanvasActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.socks.androiddemo.R;
6 | import com.socks.androiddemo.base.BaseActivity;
7 |
8 | /**
9 | * Created by zhaokaiqiang on 15/9/7.
10 | */
11 | public class CanvasActivity extends BaseActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_canvas);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/ColorMatrixActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.graphics.Canvas;
6 | import android.graphics.ColorMatrix;
7 | import android.graphics.ColorMatrixColorFilter;
8 | import android.graphics.Paint;
9 | import android.os.Bundle;
10 | import android.widget.ImageView;
11 |
12 | import com.socks.androiddemo.R;
13 | import com.socks.androiddemo.base.BaseActivity;
14 |
15 | /**
16 | * Created by zhaokaiqiang on 15/9/7.
17 | */
18 | public class ColorMatrixActivity extends BaseActivity {
19 |
20 | private ImageView img_new;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_color_matrix);
26 | img_new = (ImageView) findViewById(R.id.img_new);
27 |
28 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.sophie);
29 | img_new.setImageBitmap(getGreyBitmap(bitmap));
30 | }
31 |
32 | private Bitmap getGreyBitmap(Bitmap bitmap) {
33 | Bitmap bmp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
34 | Canvas canvas = new Canvas(bmp);
35 | Paint paint = new Paint();
36 | ColorMatrix matrix = new ColorMatrix();
37 | //饱和度设置为0则为灰度图
38 | matrix.setSaturation(0);
39 | paint.setColorFilter(new ColorMatrixColorFilter(matrix));
40 | canvas.drawBitmap(bitmap, 0, 0, paint);
41 | return bmp;
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/ConfirmActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import com.socks.androiddemo.R;
8 | import com.socks.androiddemo.view.ConfirmView;
9 |
10 | public class ConfirmActivity extends AppCompatActivity {
11 |
12 | private ConfirmView confirmView;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_confirm);
18 |
19 | confirmView = (ConfirmView) findViewById(R.id.confirm_view);
20 | }
21 |
22 | public void progressing(View view) {
23 | confirmView.animatedWithState(ConfirmView.State.Progressing);
24 | }
25 |
26 | public void fail(View view) {
27 | confirmView.animatedWithState(ConfirmView.State.Fail);
28 | }
29 |
30 | public void success(View view) {
31 | confirmView.animatedWithState(ConfirmView.State.Success);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/FllowerActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import com.socks.androiddemo.R;
8 | import com.socks.androiddemo.view.FllowerView;
9 |
10 | public class FllowerActivity extends AppCompatActivity {
11 |
12 | private FllowerView fllower;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_fllower);
18 |
19 | fllower = (FllowerView) findViewById(R.id.fllower);
20 | }
21 |
22 | public void show(View view) {
23 | fllower.startAnimation();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/FloatingActionButtonActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 |
6 | import com.socks.androiddemo.R;
7 | import com.socks.androiddemo.base.BaseActivity;
8 |
9 |
10 | public class FloatingActionButtonActivity extends BaseActivity {
11 |
12 | private FloatingActionButton button;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_floating_button);
18 | button = (FloatingActionButton) findViewById(R.id.btn);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/FocusActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.content.res.Resources;
4 | import android.os.Bundle;
5 | import android.text.Html;
6 | import android.widget.EditText;
7 | import android.widget.TextView;
8 |
9 | import com.socks.androiddemo.R;
10 | import com.socks.androiddemo.base.BaseActivity;
11 |
12 | /**
13 | * Created by zhaokaiqiang on 15/5/21.
14 | */
15 | public class FocusActivity extends BaseActivity {
16 |
17 | private EditText et;
18 |
19 | private TextView textView;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_focus);
25 |
26 | et = (EditText) findViewById(R.id.et);
27 | textView = (TextView) findViewById(R.id.tv);
28 |
29 | Resources res = getResources();
30 | String text = String.format(res.getString(R.string.welcome_messages), "赵凯强", 10);
31 | CharSequence styledText = Html.fromHtml(text);
32 |
33 | textView.setText(styledText);
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/FragmentsActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.os.PersistableBundle;
5 | import android.support.v7.app.ActionBarActivity;
6 |
7 | /**
8 | * Created by zhaokaiqiang on 15/5/18.
9 | */
10 | public class FragmentsActivity extends ActionBarActivity{
11 |
12 | @Override
13 | public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
14 | super.onCreate(savedInstanceState, persistentState);
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/IntentActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.provider.AlarmClock;
6 | import android.support.v7.app.ActionBarActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import com.socks.androiddemo.R;
12 |
13 | public class IntentActivity extends ActionBarActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_intent);
19 | }
20 |
21 | @Override
22 | public void onTrimMemory(int level) {
23 | super.onTrimMemory(level);
24 |
25 | }
26 |
27 | @Override
28 | protected void onSaveInstanceState(Bundle outState) {
29 | super.onSaveInstanceState(outState);
30 | Log.d("TAG","onSaveInstanceState");
31 | }
32 |
33 | @Override
34 | protected void onRestoreInstanceState(Bundle savedInstanceState) {
35 | super.onRestoreInstanceState(savedInstanceState);
36 | Log.d("TAG","onRestoreInstanceState");
37 | }
38 |
39 | public void createAlarm(View view) {
40 | Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
41 | .putExtra(AlarmClock.EXTRA_MESSAGE, "createAlarm")
42 | .putExtra(AlarmClock.EXTRA_HOUR, 14)
43 | .putExtra(AlarmClock.EXTRA_MINUTES, 10);
44 | if (intent.resolveActivity(getPackageManager()) != null) {
45 | startActivity(intent);
46 | }
47 | }
48 |
49 | public void startTimer(View view) {
50 | Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER)
51 | .putExtra(AlarmClock.EXTRA_MESSAGE, "Timer'")
52 | .putExtra(AlarmClock.EXTRA_LENGTH, 60)
53 | .putExtra(AlarmClock.EXTRA_SKIP_UI, true);
54 | if (intent.resolveActivity(getPackageManager()) != null) {
55 | startActivity(intent);
56 | } else {
57 | Toast.makeText(this, "No Activity", Toast.LENGTH_SHORT).show();
58 | }
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/LoadActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBarActivity;
5 |
6 | import com.socks.androiddemo.R;
7 |
8 | public class LoadActivity extends ActionBarActivity {
9 |
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_load);
15 |
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/MatrixActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.Canvas;
8 | import android.graphics.Matrix;
9 | import android.os.Bundle;
10 | import android.util.Log;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.View.OnTouchListener;
14 | import android.view.Window;
15 | import android.view.WindowManager;
16 | import android.widget.ImageView;
17 |
18 | import com.socks.androiddemo.R;
19 |
20 | public class MatrixActivity extends Activity implements OnTouchListener {
21 |
22 | private static final String TAG = "TransformMatrixActivity";
23 |
24 | private TransformMatrixView view;
25 |
26 | @Override
27 | public void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | requestWindowFeature(Window.FEATURE_NO_TITLE);
30 | this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
31 |
32 | view = new TransformMatrixView(this);
33 | view.setScaleType(ImageView.ScaleType.MATRIX);
34 | view.setOnTouchListener(this);
35 |
36 | setContentView(view);
37 | }
38 |
39 | class TransformMatrixView extends ImageView {
40 | private Bitmap bitmap;
41 | private Matrix matrix;
42 |
43 | public TransformMatrixView(Context context) {
44 | super(context);
45 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.sophie);
46 | matrix = new Matrix();
47 | }
48 |
49 | @Override
50 | protected void onDraw(Canvas canvas) {
51 | super.onDraw(canvas);
52 | // 画出原图像
53 | canvas.drawBitmap(bitmap, 0, 0, null);
54 | // 画出变换后的图像
55 | canvas.drawBitmap(bitmap, matrix, null);
56 | }
57 |
58 | @Override
59 | public void setImageMatrix(Matrix matrix) {
60 | this.matrix.set(matrix);
61 | super.setImageMatrix(matrix);
62 | }
63 |
64 | public Bitmap getImageBitmap() {
65 | return bitmap;
66 | }
67 | }
68 |
69 | public boolean onTouch(View v, MotionEvent e) {
70 | if (e.getAction() == MotionEvent.ACTION_UP) {
71 | Matrix matrix = new Matrix();
72 |
73 | // // 1. 平移
74 | // matrix.postTranslate(view.getImageBitmap().getWidth(), view.getImageBitmap().getHeight());
75 | // // 在x方向平移view.getImageBitmap().getWidth(),在y轴方向view.getImageBitmap().getHeight()
76 | // view.setImageMatrix(matrix);
77 |
78 | // // 2. 旋转(围绕图像的中心点)
79 | // matrix.setRotate(45f, view.getImageBitmap().getWidth() / 2f, view.getImageBitmap().getHeight() / 2f);
80 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
81 | // matrix.postTranslate(view.getImageBitmap().getWidth() * 1.5f, 0f);
82 | // view.setImageMatrix(matrix);
83 |
84 |
85 | // 3. 旋转(围绕坐标原点) + 平移(效果同2)
86 | // matrix.setRotate(45f);
87 | // matrix.preTranslate(-1f * view.getImageBitmap().getWidth() / 2f, -1f * view.getImageBitmap().getHeight() / 2f);
88 | // matrix.postTranslate((float)view.getImageBitmap().getWidth() / 2f, (float)view.getImageBitmap().getHeight() / 2f);
89 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
90 | // matrix.postTranslate((float)view.getImageBitmap().getWidth() * 1.5f, 0f);
91 | // view.setImageMatrix(matrix);
92 |
93 |
94 | // 4. 缩放
95 | // matrix.setScale(2f, 2f);
96 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
97 | // matrix.postTranslate(view.getImageBitmap().getWidth(), view.getImageBitmap().getHeight());
98 | // view.setImageMatrix(matrix);
99 |
100 |
101 | // 5. 错切 - 水平
102 | // matrix.setSkew(1f, 0f);
103 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
104 | // matrix.postTranslate(view.getImageBitmap().getWidth(), 0f);
105 | // view.setImageMatrix(matrix);
106 |
107 |
108 | // // 6. 错切 - 垂直
109 | // matrix.setSkew(0f, 0.5f);
110 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
111 | // matrix.postTranslate(0f, view.getImageBitmap().getHeight());
112 | // view.setImageMatrix(matrix);
113 |
114 |
115 | // 7. 错切 - 水平 + 垂直
116 | // matrix.setSkew(0.5f, 0.5f);
117 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
118 | // matrix.postTranslate(0f, view.getImageBitmap().getHeight());
119 | // view.setImageMatrix(matrix);
120 |
121 | // // 8. 对称 (水平对称)
122 | float matrix_values[] = {1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f};
123 | matrix.setValues(matrix_values);
124 | // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
125 | matrix.postTranslate(0f, view.getImageBitmap().getHeight() * 2f);
126 | view.setImageMatrix(matrix);
127 |
128 | // // 9. 对称 - 垂直
129 | // float matrix_values[] = {-1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f};
130 | // matrix.setValues(matrix_values);
131 | //
132 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
133 | // matrix.postTranslate(view.getImageBitmap().getWidth() * 2f, 0f);
134 | // view.setImageMatrix(matrix);
135 |
136 | // // 10. 对称(对称轴为直线y = x)
137 | // float matrix_values[] = {0f, -1f, 0f, -1f, 0f, 0f, 0f, 0f, 1f};
138 | // matrix.setValues(matrix_values);
139 | //
140 | // // 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
141 | // matrix.postTranslate(view.getImageBitmap().getHeight() + view.getImageBitmap().getWidth(),
142 | // view.getImageBitmap().getHeight() + view.getImageBitmap().getWidth());
143 | // view.setImageMatrix(matrix);
144 |
145 | // 下面的代码是为了查看matrix中的元素
146 | float[] matrixValues = new float[9];
147 | matrix.getValues(matrixValues);
148 | for(int i = 0; i < 3; ++i)
149 | {
150 | String temp = new String();
151 | for(int j = 0; j < 3; ++j)
152 | {
153 | temp += matrixValues[3 * i + j ] + "\t";
154 | }
155 | Log.e(TAG, temp);
156 | }
157 |
158 | view.invalidate();
159 | }
160 | return true;
161 | }
162 | }
163 |
164 | //下面给出上述代码中,各种变换的具体结果及其对应的相关变换矩阵
165 | //1.平移
166 | //
167 | //输出的结果:
168 | //
169 | //请对照第一部分中的“一、平移变换”所讲的情形,考察上述矩阵的正确性。
170 | //
171 | //2.旋转(围绕图像的中心点)
172 | //
173 | //输出的结果:
174 | //
175 | //它实际上是
176 | //matrix.setRotate(45f,view.getImageBitmap().getWidth()/2f,view.getImageBitmap().getHeight()/2f);
177 | //matrix.postTranslate(view.getImageBitmap().getWidth()*1.5f,0f);
178 | //这两条语句综合作用的结果。根据第一部分中“二、旋转变换”里面关于围绕某点旋转的公式,
179 | //matrix.setRotate(45f,view.getImageBitmap().getWidth()/2f,view.getImageBitmap().getHeight()/2f);
180 | //所产生的转换矩阵就是:
181 | //
182 | //而matrix.postTranslate(view.getImageBitmap().getWidth()*1.5f,0f);的意思就是在上述矩阵的左边再乘以下面的矩阵:
183 | //
184 | //关于post是左乘这一点,我们在前面的理论部分曾经提及过,后面我们还会专门讨论这个问题。
185 | //
186 | //所以它实际上就是:
187 | //
188 | //出去计算上的精度误差,我们可以看到我们计算出来的结果,和程序直接输出的结果是一致的。
189 | //
190 | //3.旋转(围绕坐标原点旋转,在加上两次平移,效果同2)
191 | //
192 | //根据第一部分中“二、旋转变换”里面关于围绕某点旋转的解释,不难知道:
193 | //matrix.setRotate(45f,view.getImageBitmap().getWidth()/2f,view.getImageBitmap().getHeight()/2f);
194 | //等价于
195 | //matrix.setRotate(45f);
196 | //matrix.preTranslate(-1f*view.getImageBitmap().getWidth()/2f,-1f*view.getImageBitmap().getHeight()/2f);
197 | //matrix.postTranslate((float)view.getImageBitmap().getWidth()/2f,(float)view.getImageBitmap().getHeight()/2f);
198 | //
199 | //其中matrix.setRotate(45f)对应的矩阵是:
200 | //
201 | //matrix.preTranslate(-1f*view.getImageBitmap().getWidth()/2f,-1f*view.getImageBitmap().getHeight()/2f)对应的矩阵是:
202 | //
203 | //由于是preTranslate,是先乘,也就是右乘,即它应该出现在matrix.setRotate(45f)所对应矩阵的右侧。
204 | //
205 | //matrix.postTranslate((float)view.getImageBitmap().getWidth()/2f,(float)view.getImageBitmap().getHeight()/2f)对应的矩阵是:
206 | //
207 | //这次由于是postTranslate,是后乘,也就是左乘,即它应该出现在matrix.setRotate(45f)所对应矩阵的左侧。
208 | //
209 | //所以综合起来,
210 | //matrix.setRotate(45f);
211 | //matrix.preTranslate(-1f*view.getImageBitmap().getWidth()/2f,-1f*view.getImageBitmap().getHeight()/2f);
212 | //matrix.postTranslate((float)view.getImageBitmap().getWidth()/2f,(float)view.getImageBitmap().getHeight()/2f);
213 | //对应的矩阵就是:
214 | //
215 | //这和下面这个矩阵(围绕图像中心顺时针旋转45度)其实是一样的:
216 | //
217 | //因此,此处变换后的图像和2中变换后的图像时一样的。
218 | //
219 | //4.缩放变换
220 | //
221 | //程序所输出的两个矩阵分别是:
222 | //
223 | //其中第二个矩阵,其实是下面两个矩阵相乘的结果:
224 | //
225 | //大家可以对照第一部分中的“三、缩放变换”和“一、平移变换”说法,自行验证结果。
226 | //
227 | //5.错切变换(水平错切)
228 | //
229 | //代码所输出的两个矩阵分别是:
230 | //
231 | //其中,第二个矩阵其实是下面两个矩阵相乘的结果:
232 | //
233 | //大家可以对照第一部分中的“四、错切变换”和“一、平移变换”的相关说法,自行验证结果。
234 | //
235 | //6.错切变换(垂直错切)
236 | //
237 | //代码所输出的两个矩阵分别是:
238 | //
239 | //其中,第二个矩阵其实是下面两个矩阵相乘的结果:
240 | //
241 | //大家可以对照第一部分中的“四、错切变换”和“一、平移变换”的相关说法,自行验证结果。
242 | //
243 | //7.错切变换(水平+垂直错切)
244 | //
245 | //代码所输出的两个矩阵分别是:
246 | //
247 | //其中,后者是下面两个矩阵相乘的结果:
248 | //
249 | //大家可以对照第一部分中的“四、错切变换”和“一、平移变换”的相关说法,自行验证结果。
250 | //
251 | //8.对称变换(水平对称)
252 | //
253 | //代码所输出的两个各矩阵分别是:
254 | //
255 | //其中,后者是下面两个矩阵相乘的结果:
256 | //
257 | //大家可以对照第一部分中的“五、对称变换”和“一、平移变换”的相关说法,自行验证结果。
258 | //
259 | //9.对称变换(垂直对称)
260 | //
261 | //代码所输出的两个矩阵分别是:
262 | //
263 | //其中,后者是下面两个矩阵相乘的结果:
264 | //
265 | //大家可以对照第一部分中的“五、对称变换”和“一、平移变换”的相关说法,自行验证结果。
266 | //
267 | //10.对称变换(对称轴为直线y=x)
268 | //
269 | //代码所输出的两个矩阵分别是:
270 | //
271 | //其中,后者是下面两个矩阵相乘的结果:
272 | //
273 | //大家可以对照第一部分中的“五、对称变换”和“一、平移变换”的相关说法,自行验证结果。
274 | //
275 | //11.关于先乘和后乘的问题
276 | //由于矩阵的乘法运算不满足交换律,我们在前面曾经多次提及先乘、后乘的问题,即先乘就是矩阵运算中右乘,后乘就是矩阵运算中的左乘。其实先乘、后乘的概念是针对变换操作的时间先后而言的,左乘、右乘是针对矩阵运算的左右位置而言的。以第一部分“二、旋转变换”中围绕某点旋转的情况为例:
277 | //
278 | //越靠近原图像中像素的矩阵,越先乘,越远离原图像中像素的矩阵,越后乘。事实上,图像处理时,矩阵的运算是从右边往左边方向进行运算的。这就形成了越在右边的矩阵(右乘),越先运算(先乘),反之亦然。
279 | //
280 | //当然,在实际中,如果首先指定了一个matrix,比如我们先setRotate(
),即指定了上面变换矩阵中,中间的那个矩阵,那么后续的矩阵到底是pre还是post运算,都是相对这个中间矩阵而言的。
281 | //
282 | //所有这些,其实都是很自然的事情。
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/MenuActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.view.Menu;
5 | import android.view.MenuItem;
6 |
7 | import com.socks.androiddemo.R;
8 | import com.socks.androiddemo.base.BaseActivity;
9 |
10 | /**
11 | * Created by zhaokaiqiang on 15/5/21.
12 | */
13 | public class MenuActivity extends BaseActivity{
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 |
18 | }
19 |
20 |
21 | @Override
22 | public boolean onCreateOptionsMenu(Menu menu) {
23 | getMenuInflater().inflate(R.menu.menu_intent, menu);
24 |
25 | return super.onCreateOptionsMenu(menu);
26 | }
27 |
28 | public void onGroupItemClick(MenuItem item) {
29 | // One of the group items (using the onClick attribute) was clicked
30 | // The item parameter passed here indicates which item it is
31 | // All other menu item clicks are handled by onOptionsItemSelected()
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/MuService.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.Handler;
6 | import android.os.IBinder;
7 | import android.os.Looper;
8 | import android.os.Message;
9 |
10 | /**
11 | * Created by zhaokaiqiang on 15/5/18.
12 | */
13 | public class MuService extends Service {
14 |
15 |
16 | private class ServiceHandler extends Handler {
17 |
18 | public ServiceHandler(Looper looper) {
19 | super(looper);
20 | }
21 |
22 | @Override
23 | public void handleMessage(Message msg) {
24 | super.handleMessage(msg);
25 | }
26 | }
27 |
28 | ;
29 |
30 |
31 | @Override
32 | public IBinder onBind(Intent intent) {
33 | return null;
34 | }
35 |
36 | @Override
37 | public void onCreate() {
38 | super.onCreate();
39 | }
40 |
41 | @Override
42 | public int onStartCommand(Intent intent, int flags, int startId) {
43 | return super.onStartCommand(intent, flags, startId);
44 | }
45 |
46 |
47 | @Override
48 | public void onDestroy() {
49 | super.onDestroy();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/MyIntentService.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.IntentService;
4 | import android.content.Intent;
5 |
6 | /**
7 | * Created by zhaokaiqiang on 15/5/18.
8 | */
9 | public class MyIntentService extends IntentService {
10 |
11 | public MyIntentService(String name) {
12 | super(name);
13 | }
14 |
15 | @Override
16 | protected void onHandleIntent(Intent intent) {
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/NotifycationActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.NotificationManager;
4 | import android.app.PendingIntent;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.graphics.BitmapFactory;
8 | import android.os.Bundle;
9 | import android.support.v4.app.NotificationCompat;
10 | import android.support.v4.app.TaskStackBuilder;
11 | import android.view.View;
12 |
13 | import com.socks.androiddemo.R;
14 | import com.socks.androiddemo.base.BaseActivity;
15 |
16 | public class NotifycationActivity extends BaseActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_notifycation);
22 | }
23 |
24 | public void click(View view) {
25 |
26 | switch (view.getId()) {
27 | case R.id.btn_one: {
28 | NotificationCompat.Builder mBuilder =
29 | new NotificationCompat.Builder(context)
30 | .setSmallIcon(R.mipmap.ic_launcher)
31 | .setContentTitle("BTN-ONE")
32 | .setContentText("First Notification")
33 | .setAutoCancel(true);
34 |
35 | Intent resultIntent = new Intent(context, OtherActivity.class);
36 |
37 | PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
38 | resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
39 | mBuilder.setContentIntent(resultPendingIntent);
40 | NotificationManager mNotifyMgr =
41 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
42 | mNotifyMgr.notify(0, mBuilder.build());
43 | }
44 | break;
45 | case R.id.btn_two: {
46 |
47 | NotificationCompat.Builder mBuilder =
48 | new NotificationCompat.Builder(this)
49 | .setSmallIcon(R.mipmap.ic_launcher)
50 | .setContentTitle("BTN-TWO")
51 | .setContentText("Hello World!").setAutoCancel(true)
52 | .setStyle(new NotificationCompat.BigPictureStyle()
53 | .setBigContentTitle("BigContentTitle")
54 | .setSummaryText("SummaryTextSummaryText")
55 | .bigPicture(BitmapFactory.decodeResource(getResources(),
56 | R.mipmap.ic_launcher)));
57 |
58 | Intent resultIntent = new Intent(this, OtherActivity.class);
59 | resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
60 |
61 | TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
62 | stackBuilder.addParentStack(OtherActivity.class);
63 | stackBuilder.addNextIntent(resultIntent);
64 |
65 | PendingIntent resultPendingIntent =
66 | stackBuilder.getPendingIntent(
67 | 0, PendingIntent.FLAG_UPDATE_CURRENT
68 | );
69 |
70 | mBuilder.setContentIntent(resultPendingIntent);
71 | NotificationManager mNotificationManager =
72 | (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
73 | mNotificationManager.notify(1, mBuilder.build());
74 | }
75 | break;
76 | case R.id.btn_three: {
77 | NotificationCompat.Builder mBuilder =
78 | new NotificationCompat.Builder(this)
79 | .setSmallIcon(R.mipmap.ic_launcher)
80 | .setContentTitle("MultyLineStyle")
81 | .setContentText("Hello World!").setAutoCancel(true);
82 |
83 | NotificationCompat.InboxStyle inboxStyle =
84 | new NotificationCompat.InboxStyle();
85 | String[] events = new String[5];
86 | inboxStyle.setBigContentTitle("Event tracker details:");
87 | for (int i = 0; i < events.length; i++) {
88 | inboxStyle.addLine("Test It !");
89 | }
90 | mBuilder.setStyle(inboxStyle);
91 | Intent resultIntent = new Intent(context, OtherActivity.class);
92 |
93 | PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
94 | resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
95 | mBuilder.setContentIntent(resultPendingIntent);
96 |
97 | NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.mipmap
98 | .ic_launcher, "click",resultPendingIntent).build();
99 |
100 | mBuilder.addAction(action);
101 |
102 | NotificationManager mNotificationManager =
103 | (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
104 | mNotificationManager.notify(2, mBuilder.build());
105 | }
106 | break;
107 | }
108 |
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/OtherActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 | import android.os.Environment;
5 |
6 | import com.socks.androiddemo.R;
7 | import com.socks.androiddemo.base.BaseActivity;
8 |
9 |
10 | public class OtherActivity extends BaseActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_other);
16 |
17 | getExternalCacheDir();
18 | getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
19 |
20 | getCacheDir();
21 | getFilesDir();
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/PointViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | import com.socks.androiddemo.R;
7 |
8 | /**
9 | * Created by zhaokaiqiang on 15/8/16.
10 | */
11 | public class PointViewActivity extends Activity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_pointview);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/ReflectionActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.LinearGradient;
7 | import android.graphics.Matrix;
8 | import android.graphics.Paint;
9 | import android.graphics.PorterDuff;
10 | import android.graphics.PorterDuffXfermode;
11 | import android.graphics.Shader;
12 | import android.os.Bundle;
13 | import android.view.Gravity;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.FrameLayout;
17 | import android.widget.ImageView;
18 | import android.widget.TextView;
19 |
20 | import com.socks.androiddemo.base.BaseActivity;
21 |
22 | public class ReflectionActivity extends BaseActivity {
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 |
28 | final FrameLayout root = new FrameLayout(this);
29 | setContentView(root);
30 |
31 | final TextView textView = new TextView(this);
32 | textView.setText("test");
33 | textView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
34 | textView.setTextColor(Color.WHITE);
35 | textView.setTextSize(40);
36 | textView.setGravity(Gravity.CENTER_HORIZONTAL);
37 | textView.setBackgroundColor(Color.RED);
38 | textView.setPadding(100, 20, 100, 20);
39 |
40 | final int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
41 | textView.measure(measureSpec, measureSpec);
42 | textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
43 | final Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
44 | final Canvas c = new Canvas(b);
45 | textView.draw(c);
46 |
47 | final ImageView imageView = new ImageView(this);
48 | imageView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
49 | imageView.setImageBitmap(createReflection(b, 1, 10));
50 | root.addView(imageView);
51 | }
52 |
53 | private Bitmap createReflection(Bitmap original, float percentage, int gap) {
54 |
55 | final int reflectionHeight = (int) (original.getHeight() * percentage);
56 | Bitmap bitmapWithReflection = Bitmap.createBitmap(original.getWidth(), (original.getHeight() + reflectionHeight + gap), Bitmap.Config.ARGB_8888);
57 | Canvas canvas = new Canvas(bitmapWithReflection);
58 |
59 | // original image
60 | canvas.drawBitmap(original, 0, 0, null);
61 | // gap drawing
62 | final Paint transparentPaint = new Paint();
63 | transparentPaint.setARGB(0, 255, 255, 255);
64 | canvas.drawRect(0, original.getHeight(), original.getWidth(), original.getHeight() + gap, transparentPaint);
65 | // reflection
66 | final Matrix matrix = new Matrix();
67 | matrix.preScale(1, -1);
68 | canvas.drawBitmap(Bitmap.createBitmap(original, 0, original.getHeight() - reflectionHeight, original.getWidth(), reflectionHeight, matrix, false), 0, original.getHeight() + gap, null);
69 | // reflection shading
70 | final Paint fadePaint = new Paint();
71 | fadePaint.setShader(new LinearGradient(0, original.getHeight(), 0, original.getHeight() + reflectionHeight + gap, 0x70ffffff, 0x00ffffff, Shader.TileMode.CLAMP));
72 | fadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
73 | canvas.drawRect(0, original.getHeight(), original.getWidth(), bitmapWithReflection.getHeight() + gap, fadePaint);
74 |
75 | original.recycle();
76 | return bitmapWithReflection;
77 | }
78 |
79 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/ShaderActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.socks.androiddemo.R;
6 | import com.socks.androiddemo.base.BaseActivity;
7 |
8 | /**
9 | * Created by zhaokaiqiang on 15/9/7.
10 | */
11 | public class ShaderActivity extends BaseActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_shader);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/SpannableActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.graphics.Typeface;
4 | import android.os.Bundle;
5 | import android.text.Spannable;
6 | import android.text.SpannableString;
7 | import android.text.method.LinkMovementMethod;
8 | import android.text.style.StyleSpan;
9 | import android.widget.TextView;
10 |
11 | import com.socks.androiddemo.R;
12 | import com.socks.androiddemo.base.BaseActivity;
13 |
14 | public class SpannableActivity extends BaseActivity {
15 |
16 | private TextView tv;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_spannable);
22 | initView();
23 | initDate();
24 | }
25 |
26 | @Override
27 | public void initView() {
28 | tv = (TextView) findViewById(R.id.tv);
29 | }
30 |
31 | @Override
32 | public void initDate() {
33 | String sp = "12345";
34 | SpannableString spannableString = new SpannableString(sp);
35 | StyleSpan styleSpan = new StyleSpan(Typeface.BOLD_ITALIC);
36 | spannableString.setSpan(styleSpan, 0, sp.length(),
37 | Spannable.SPAN_INCLUSIVE_INCLUSIVE);
38 | tv.setText(spannableString);
39 | tv.setMovementMethod(LinkMovementMethod.getInstance());
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/SparseDemo.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | /**
4 | * Created by zhaokaiqiang on 15/8/18.
5 | */
6 | public class SparseDemo {
7 |
8 | public static void main(String[] args) {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/ui/UtilsActivity.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.graphics.Rect;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.os.Handler;
11 | import android.telephony.TelephonyManager;
12 | import android.view.View;
13 | import android.view.Window;
14 | import android.view.inputmethod.InputMethodManager;
15 | import android.widget.EditText;
16 |
17 | import com.socks.androiddemo.R;
18 |
19 |
20 | public class UtilsActivity extends Activity {
21 |
22 | private Handler handler = new Handler();
23 |
24 | private EditText editText;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_utils);
30 |
31 | editText = (EditText) findViewById(R.id.btn_wake);
32 |
33 | Intent intent = new Intent();
34 | intent.setAction(Intent.ACTION_CALL);
35 | if (intent.resolveActivity(getPackageManager()) != null) {
36 |
37 | }
38 |
39 | }
40 |
41 |
42 | public static String getNetworkOperator(Context context) {
43 | TelephonyManager telephonyManager = (TelephonyManager) context
44 | .getSystemService(Context.TELEPHONY_SERVICE);
45 | return telephonyManager.getNetworkOperator();
46 | }
47 |
48 | @Override
49 | public void onWindowFocusChanged(boolean hasFocus) {
50 | super.onWindowFocusChanged(hasFocus);
51 | editText.setText(getNetworkOperator(this));
52 |
53 | }
54 |
55 | public static int getNetworkType(Context context) {
56 | TelephonyManager telephonyManager = (TelephonyManager) context
57 | .getSystemService(Context.TELEPHONY_SERVICE);
58 | return telephonyManager.getNetworkType();
59 | }
60 |
61 | public static int getTopBarHeight(Activity activity) {
62 | return activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT)
63 | .getTop();
64 | }
65 |
66 | @TargetApi(Build.VERSION_CODES.CUPCAKE)
67 | public static void hideSoftInput(Activity activity) {
68 | View view = activity.getWindow().peekDecorView();
69 | if (view != null) {
70 | InputMethodManager inputmanger = (InputMethodManager) activity
71 | .getSystemService(Context.INPUT_METHOD_SERVICE);
72 | inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
73 | }
74 | }
75 |
76 | @TargetApi(Build.VERSION_CODES.CUPCAKE)
77 | public static int getStatusBarHeight(Activity activity) {
78 | Rect frame = new Rect();
79 | activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
80 | return frame.top;
81 | }
82 |
83 | @TargetApi(Build.VERSION_CODES.CUPCAKE)
84 | public static void showSoftInput(Context context, EditText edit) {
85 | edit.setFocusable(true);
86 | edit.setFocusableInTouchMode(true);
87 | edit.requestFocus();
88 | InputMethodManager inputManager = (InputMethodManager) context
89 | .getSystemService(Context.INPUT_METHOD_SERVICE);
90 | inputManager.showSoftInput(edit, 0);
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/utils/MeasureUtil.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.utils;
2 |
3 | import android.content.Context;
4 | import android.util.DisplayMetrics;
5 | import android.view.WindowManager;
6 |
7 | /**
8 | * Created by zhaokaiqiang on 15/9/14.
9 | */
10 | public class MeasureUtil {
11 | public static int[] getScreenSize(Context context) {
12 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
13 | DisplayMetrics metrics = new DisplayMetrics();
14 | windowManager.getDefaultDisplay().getMetrics(metrics);
15 | int[] screenSize = new int[]{metrics.widthPixels, metrics.heightPixels};
16 | return screenSize;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/utils/logger/LogLevel.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.utils.logger;
2 |
3 | /**
4 | * @author Orhan Obut
5 | */
6 | public enum LogLevel {
7 |
8 | /**
9 | * Prints all logs
10 | */
11 | FULL,
12 |
13 | /**
14 | * No log will be printed
15 | */
16 | NONE
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/utils/logger/Logger.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.utils.logger;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | import android.text.TextUtils;
8 | import android.util.Log;
9 |
10 | /**
11 | * Logger is a wrapper of {@link android.util.Log}
12 | * But more pretty, simple and powerful
13 | *
14 | * @author Orhan Obut
15 | */
16 | public final class Logger {
17 |
18 | /**
19 | * Android's max limit for a log entry is ~4076 bytes,
20 | * so 4000 bytes is used as chunk size since default charset
21 | * is UTF-8
22 | */
23 | private static final int CHUNK_SIZE = 4000;
24 |
25 | /**
26 | * It is used for json pretty print
27 | */
28 | private static final int JSON_INDENT = 4;
29 |
30 | /**
31 | * In order to prevent readability, max method count is restricted with 5
32 | */
33 | private static final int MAX_METHOD_COUNT = 5;
34 |
35 | /**
36 | * It is used to determine log settings such as method count, thread info visibility
37 | */
38 | private static final Settings settings = new Settings();
39 |
40 | /**
41 | * Drawing toolbox
42 | */
43 | private static final char TOP_LEFT_CORNER = '╔';
44 | private static final char BOTTOM_LEFT_CORNER = '╚';
45 | private static final char MIDDLE_CORNER = '╟';
46 | private static final char HORIZONTAL_DOUBLE_LINE = '║';
47 | private static final String DOUBLE_DIVIDER = "════════════════════════════════════════════";
48 | private static final String SINGLE_DIVIDER = "────────────────────────────────────────────";
49 | private static final String TOP_BORDER = TOP_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER;
50 | private static final String BOTTOM_BORDER = BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER;
51 | private static final String MIDDLE_BORDER = MIDDLE_CORNER + SINGLE_DIVIDER + SINGLE_DIVIDER;
52 |
53 | /**
54 | * TAG is used for the Log, the name is a little different
55 | * in order to differentiate the logs easily with the filter
56 | */
57 | private static String TAG = "PRETTYLOGGER";
58 |
59 | //no instance
60 | private Logger() {
61 | }
62 |
63 | /**
64 | * It is used to get the settings object in order to change settings
65 | *
66 | * @return the settings object
67 | */
68 | public static Settings init() {
69 | return settings;
70 | }
71 |
72 | /**
73 | * It is used to change the tag
74 | *
75 | * @param tag is the given string which will be used in Logger
76 | */
77 | public static Settings init(String tag) {
78 | if (tag == null) {
79 | throw new NullPointerException("tag may not be null");
80 | }
81 | if (tag.trim().length() == 0) {
82 | throw new IllegalStateException("tag may not be empty");
83 | }
84 | Logger.TAG = tag;
85 | return settings;
86 | }
87 |
88 | public static void d(String message) {
89 | d(TAG, message);
90 | }
91 |
92 | public static void d(String tag, String message) {
93 | d(tag, message, settings.methodCount);
94 | }
95 |
96 | public static void d(String message, int methodCount) {
97 | d(TAG, message, methodCount);
98 | }
99 |
100 | public static void d(String tag, String message, int methodCount) {
101 | validateMethodCount(methodCount);
102 | log(Log.DEBUG, tag, message, methodCount);
103 | }
104 |
105 | public static void e(String message) {
106 | e(TAG, message);
107 | }
108 |
109 | public static void e(String tag, String message) {
110 | e(tag, message, null, settings.methodCount);
111 | }
112 |
113 | public static void e(Exception e) {
114 | e(TAG, null, e, settings.methodCount);
115 | }
116 |
117 | public static void e(String tag, Exception e) {
118 | e(tag, null, e, settings.methodCount);
119 | }
120 |
121 | public static void e(String message, int methodCount) {
122 | validateMethodCount(methodCount);
123 | e(message, null, methodCount);
124 | }
125 |
126 | public static void e(String tag, String message, int methodCount) {
127 | validateMethodCount(methodCount);
128 | e(tag, message, null, methodCount);
129 | }
130 |
131 | public static void e(String tag, String message, Exception e) {
132 | e(tag, message, e, settings.methodCount);
133 | }
134 |
135 | public static void e(String tag, String message, Exception e, int methodCount) {
136 | validateMethodCount(methodCount);
137 | if (e != null && message != null) {
138 | message += " : " + e.toString();
139 | }
140 | if (e != null && message == null) {
141 | message = e.toString();
142 | }
143 | if (message == null) {
144 | message = "No message/exception is set";
145 | }
146 | log(Log.ERROR, tag, message, methodCount);
147 | }
148 |
149 | public static void w(String message) {
150 | w(TAG, message);
151 | }
152 |
153 | public static void w(String tag, String message) {
154 | w(tag, message, settings.methodCount);
155 | }
156 |
157 | public static void w(String message, int methodCount) {
158 | w(TAG, message, methodCount);
159 | }
160 |
161 | public static void w(String tag, String message, int methodCount) {
162 | validateMethodCount(methodCount);
163 | log(Log.WARN, tag, message, methodCount);
164 | }
165 |
166 | public static void i(String message) {
167 | i(TAG, message);
168 | }
169 |
170 | public static void i(String tag, String message) {
171 | i(tag, message, settings.methodCount);
172 | }
173 |
174 | public static void i(String message, int methodCount) {
175 | i(TAG, message, methodCount);
176 | }
177 |
178 | public static void i(String tag, String message, int methodCount) {
179 | validateMethodCount(methodCount);
180 | log(Log.INFO, tag, message, methodCount);
181 | }
182 |
183 | public static void v(String message) {
184 | v(TAG, message);
185 | }
186 |
187 | public static void v(String tag, String message) {
188 | v(tag, message, settings.methodCount);
189 | }
190 |
191 | public static void v(String message, int methodCount) {
192 | v(TAG, message, methodCount);
193 | }
194 |
195 | public static void v(String tag, String message, int methodCount) {
196 | validateMethodCount(methodCount);
197 | log(Log.VERBOSE, tag, message, methodCount);
198 | }
199 |
200 | public static void wtf(String message) {
201 | wtf(TAG, message);
202 | }
203 |
204 | public static void wtf(String tag, String message) {
205 | wtf(tag, message, settings.methodCount);
206 | }
207 |
208 | public static void wtf(String message, int methodCount) {
209 | wtf(TAG, message, methodCount);
210 | }
211 |
212 | public static void wtf(String tag, String message, int methodCount) {
213 | validateMethodCount(methodCount);
214 | log(Log.ASSERT, tag, message, methodCount);
215 | }
216 |
217 | /**
218 | * Formats the json content and print it
219 | *
220 | * @param json the json content
221 | */
222 | public static void json(String json) {
223 | json(TAG, json);
224 | }
225 |
226 | public static void json(String tag, String json) {
227 | json(tag, json, settings.methodCount);
228 | }
229 |
230 | public static void json(String json, int methodCount) {
231 | json(TAG, json, methodCount);
232 | }
233 |
234 | /**
235 | * Formats the json content and print it
236 | *
237 | * @param json the json content
238 | * @param methodCount number of the method that will be printed
239 | */
240 | public static void json(String tag, String json, int methodCount) {
241 | validateMethodCount(methodCount);
242 | if (TextUtils.isEmpty(json)) {
243 | d(tag, "Empty/Null json content", methodCount);
244 | return;
245 | }
246 | try {
247 | if (json.startsWith("{")) {
248 | JSONObject jsonObject = new JSONObject(json);
249 | String message = jsonObject.toString(JSON_INDENT);
250 | d(tag, message, methodCount);
251 | return;
252 | }
253 | if (json.startsWith("[")) {
254 | JSONArray jsonArray = new JSONArray(json);
255 | String message = jsonArray.toString(JSON_INDENT);
256 | d(tag, message, methodCount);
257 | }
258 | } catch (JSONException e) {
259 | d(tag, e.getCause().getMessage() + "\n" + json, methodCount);
260 | }
261 | }
262 |
263 | /**
264 | * This method is synchronized in order to avoid messy of logs' order.
265 | */
266 | private synchronized static void log(int logType, String tag, String message, int methodCount) {
267 | if (settings.logLevel == LogLevel.NONE) {
268 | return;
269 | }
270 | logTopBorder(logType, tag);
271 | logHeaderContent(logType, tag, methodCount);
272 |
273 | //get bytes of message with system's default charset (which is UTF-8 for Android)
274 | byte[] bytes = message.getBytes();
275 | int length = bytes.length;
276 | if (length <= CHUNK_SIZE) {
277 | if (methodCount > 0) {
278 | logDivider(logType, tag);
279 | }
280 | logContent(logType, tag, message);
281 | logBottomBorder(logType, tag);
282 | return;
283 | }
284 | if (methodCount > 0) {
285 | logDivider(logType, tag);
286 | }
287 | for (int i = 0; i < length; i += CHUNK_SIZE) {
288 | int count = Math.min(length - i, CHUNK_SIZE);
289 | //create a new String with system's default charset (which is UTF-8 for Android)
290 | logContent(logType, tag, new String(bytes, i, count));
291 | }
292 | logBottomBorder(logType, tag);
293 | }
294 |
295 | private static void logTopBorder(int logType, String tag) {
296 | logChunk(logType, tag, TOP_BORDER);
297 | }
298 |
299 | private static void logHeaderContent(int logType, String tag, int methodCount) {
300 | StackTraceElement[] trace = Thread.currentThread().getStackTrace();
301 | if (settings.showThreadInfo) {
302 | logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " Thread: " + Thread.currentThread().getName());
303 | logDivider(logType, tag);
304 | }
305 | String level = "";
306 | for (int i = methodCount; i > 0; i--) {
307 | int stackIndex = i + 5;
308 | StringBuilder builder = new StringBuilder();
309 | builder.append("║ ")
310 | .append(level)
311 | .append(getSimpleClassName(trace[stackIndex].getClassName()))
312 | .append(".")
313 | .append(trace[stackIndex].getMethodName())
314 | .append(" ")
315 | .append(" (")
316 | .append(trace[stackIndex].getFileName())
317 | .append(":")
318 | .append(trace[stackIndex].getLineNumber())
319 | .append(")");
320 | level += " ";
321 | logChunk(logType, tag, builder.toString());
322 | }
323 | }
324 |
325 | private static void logBottomBorder(int logType, String tag) {
326 | logChunk(logType, tag, BOTTOM_BORDER);
327 | }
328 |
329 | private static void logDivider(int logType, String tag) {
330 | logChunk(logType, tag, MIDDLE_BORDER);
331 | }
332 |
333 | private static void logContent(int logType, String tag, String chunk) {
334 | String[] lines = chunk.split(System.getProperty("line.separator"));
335 | for (String line : lines) {
336 | logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " " + line);
337 | }
338 | }
339 |
340 | private static void logChunk(int logType, String tag, String chunk) {
341 | String finalTag = formatTag(tag);
342 | switch (logType) {
343 | case Log.ERROR:
344 | Log.e(finalTag, chunk);
345 | break;
346 | case Log.INFO:
347 | Log.i(finalTag, chunk);
348 | break;
349 | case Log.VERBOSE:
350 | Log.v(finalTag, chunk);
351 | break;
352 | case Log.WARN:
353 | Log.w(finalTag, chunk);
354 | break;
355 | case Log.ASSERT:
356 | Log.wtf(finalTag, chunk);
357 | break;
358 | case Log.DEBUG:
359 | // Fall through, log debug by default
360 | default:
361 | Log.d(finalTag, chunk);
362 | break;
363 | }
364 | }
365 |
366 | private static String getSimpleClassName(String name) {
367 | int lastIndex = name.lastIndexOf(".");
368 | return name.substring(lastIndex + 1);
369 | }
370 |
371 | private static void validateMethodCount(int methodCount) {
372 | if (methodCount < 0 || methodCount > MAX_METHOD_COUNT) {
373 | throw new IllegalStateException("methodCount must be > 0 and < 5");
374 | }
375 | }
376 |
377 | private static String formatTag(String tag) {
378 | if (!TextUtils.isEmpty(tag) && !TextUtils.equals(TAG, tag)) {
379 | return TAG + "-" + tag;
380 | }
381 | return TAG;
382 | }
383 |
384 | public static class Settings {
385 | int methodCount = 2;
386 | boolean showThreadInfo = true;
387 |
388 | /**
389 | * Determines how logs will printed
390 | */
391 | LogLevel logLevel = LogLevel.FULL;
392 |
393 | public Settings hideThreadInfo() {
394 | showThreadInfo = false;
395 | return this;
396 | }
397 |
398 | public Settings setMethodCount(int methodCount) {
399 | validateMethodCount(methodCount);
400 | this.methodCount = methodCount;
401 | return this;
402 | }
403 |
404 | public Settings setLogLevel(LogLevel logLevel) {
405 | this.logLevel = logLevel;
406 | return this;
407 | }
408 | }
409 |
410 |
411 | }
412 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/utils/logger/WakeLocker.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.utils.logger;
2 |
3 | import android.content.Context;
4 | import android.os.PowerManager;
5 |
6 | public abstract class WakeLocker {
7 | private static PowerManager.WakeLock wakeLock;
8 |
9 | public static void acquire(Context ctx) {
10 | if (wakeLock != null)
11 | wakeLock.release();
12 |
13 | PowerManager pm = (PowerManager) ctx
14 | .getSystemService(Context.POWER_SERVICE);
15 | // wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
16 | // PowerManager.ACQUIRE_CAUSES_WAKEUP |
17 | // PowerManager.ON_AFTER_RELEASE, "TAG");
18 | wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TAG");
19 | wakeLock.acquire();
20 | }
21 |
22 | public static void release() {
23 |
24 | synchronized (WakeLocker.class) {
25 | if (wakeLock != null) {
26 | try {
27 | wakeLock.release();
28 | } catch (Throwable th) {
29 | // ignoring this exception, probably wakeLock was already
30 | }
31 | }
32 | wakeLock = null;
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/BitmapShaderView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.ColorStateList;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapShader;
7 | import android.graphics.Canvas;
8 | import android.graphics.Matrix;
9 | import android.graphics.Shader;
10 | import android.graphics.drawable.Drawable;
11 | import android.util.AttributeSet;
12 | import android.widget.TextView;
13 |
14 | import com.socks.androiddemo.R;
15 |
16 | /**
17 | * Created by zhaokaiqiang on 15/9/7.
18 | */
19 | public class BitmapShaderView extends TextView {
20 |
21 | private Drawable mDrawable;
22 | private BitmapShader shader;
23 | private Matrix shaderMatrix;
24 | private float offsetY;
25 |
26 | public interface AnimationSetupCallback {
27 | public void onSetupAnimation(BitmapShaderView titanicTextView);
28 | }
29 |
30 | private AnimationSetupCallback animationSetupCallback;
31 | // wave shader coordinates
32 | private float maskX, maskY;
33 | // if true, the shader will display the wave
34 | private boolean sinking;
35 | // true after the first onSizeChanged
36 | private boolean setUp;
37 |
38 |
39 | private boolean setup = false;
40 |
41 | public BitmapShaderView(Context context) {
42 | super(context);
43 | init();
44 | }
45 |
46 | public BitmapShaderView(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | init();
49 | }
50 |
51 | public BitmapShaderView(Context context, AttributeSet attrs, int defStyleAttr) {
52 | super(context, attrs, defStyleAttr);
53 | init();
54 | }
55 |
56 | private void init() {
57 | shaderMatrix = new Matrix();
58 | }
59 |
60 | @Override
61 | public void setTextColor(int color) {
62 | super.setTextColor(color);
63 | createShader();
64 | }
65 |
66 | @Override
67 | public void setTextColor(ColorStateList colors) {
68 | super.setTextColor(colors);
69 | createShader();
70 | }
71 |
72 | @Override
73 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
74 | super.onSizeChanged(w, h, oldw, oldh);
75 | createShader();
76 | if (!setUp) {
77 | setUp = true;
78 | if (animationSetupCallback != null) {
79 | animationSetupCallback.onSetupAnimation(BitmapShaderView.this);
80 | }
81 | }
82 | }
83 |
84 | private void createShader() {
85 | if (mDrawable == null) {
86 | mDrawable = getResources().getDrawable(R.drawable.wave);
87 | }
88 |
89 | int waveW = mDrawable.getIntrinsicWidth();
90 | int waveH = mDrawable.getIntrinsicHeight();
91 |
92 | Bitmap bitmap = Bitmap.createBitmap(waveW, waveH, Bitmap.Config.ARGB_8888);
93 | Canvas canvas = new Canvas(bitmap);
94 | canvas.drawColor(getCurrentTextColor());
95 | mDrawable.setBounds(0, 0, waveW, waveH);
96 | mDrawable.draw(canvas);
97 | shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
98 | getPaint().setShader(shader);
99 | offsetY = (getHeight() - waveH) / 2;
100 |
101 | }
102 |
103 | public float getMaskX() {
104 | return maskX;
105 | }
106 |
107 | public void setMaskX(float maskX) {
108 | this.maskX = maskX;
109 | invalidate();
110 | }
111 |
112 | public float getMaskY() {
113 | return maskY;
114 | }
115 |
116 | public void setMaskY(float maskY) {
117 | this.maskY = maskY;
118 | invalidate();
119 | }
120 |
121 | public boolean isSinking() {
122 | return sinking;
123 | }
124 |
125 | public void setSinking(boolean sinking) {
126 | this.sinking = sinking;
127 | }
128 |
129 | public boolean isSetUp() {
130 | return setUp;
131 | }
132 |
133 | public AnimationSetupCallback getAnimationSetupCallback() {
134 | return animationSetupCallback;
135 | }
136 |
137 | public void setAnimationSetupCallback(AnimationSetupCallback animationSetupCallback) {
138 | this.animationSetupCallback = animationSetupCallback;
139 | }
140 |
141 | @Override
142 | protected void onDraw(Canvas canvas) {
143 |
144 | if (sinking && shader != null) {
145 |
146 | // first call after sinking, assign it to our paint
147 | if (getPaint().getShader() == null) {
148 | getPaint().setShader(shader);
149 | }
150 |
151 | // translate shader accordingly to maskX maskY positions
152 | // maskY is affected by the offset to vertically center the wave
153 | shaderMatrix.setTranslate(maskX, maskY + offsetY);
154 |
155 | // assign matrix to invalidate the shader
156 | shader.setLocalMatrix(shaderMatrix);
157 | } else {
158 | getPaint().setShader(null);
159 | }
160 |
161 | super.onDraw(canvas);
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/CanvasView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | /**
12 | * Created by zhaokaiqiang on 15/9/21.
13 | */
14 | public class CanvasView extends View {
15 |
16 | private static final float TOTAL_SQUARE_COUNT = 15;
17 | private Paint mPaint;
18 | private float mWidth;
19 | private float mHeight;
20 | private RectF mRect;
21 | private float mScale = 1;
22 |
23 | public CanvasView(Context context) {
24 | this(context, null);
25 | }
26 |
27 | public CanvasView(Context context, AttributeSet attrs) {
28 | this(context, attrs, 0);
29 | }
30 |
31 | public CanvasView(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | init();
34 | }
35 |
36 | private void init() {
37 | mPaint = new Paint();
38 | mPaint.setColor(Color.BLACK);
39 | mPaint.setStyle(Paint.Style.STROKE);
40 | mPaint.setStrokeWidth(10);
41 | }
42 |
43 | @Override
44 | protected void onDraw(Canvas canvas) {
45 |
46 | // mScale = 1;
47 | // while (mScale >= 0.1) {
48 | // mScale *= 0.9;
49 | // canvas.save();
50 | // canvas.scale(mScale, mScale, mWidth / 2, mHeight / 2);
51 | // canvas.drawRect(mRect, mPaint);
52 | // canvas.restore();
53 | // }
54 |
55 | for (int i = 0; i < TOTAL_SQUARE_COUNT; i++) {
56 | // 保存画布
57 | canvas.save();
58 | float fraction = (float) i / TOTAL_SQUARE_COUNT;
59 | // 将画布以正方形中心进行缩放
60 | canvas.scale(fraction, fraction, mWidth / 2, mWidth / 2);
61 | canvas.drawRect(mRect, mPaint);
62 | // 画布回滚
63 | canvas.restore();
64 | }
65 |
66 | }
67 |
68 | @Override
69 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
70 | super.onSizeChanged(w, h, oldw, oldh);
71 | mWidth = h > w ? w : h;
72 | mHeight = h > w ? h : w;
73 | mRect = new RectF(0, 0, mWidth, mWidth);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/ColorEvaluator.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.TypeEvaluator;
4 | import android.util.Log;
5 |
6 | /**
7 | * Created by zhaokaiqiang on 15/8/17.
8 | */
9 | public class ColorEvaluator implements TypeEvaluator {
10 |
11 | private int mCurrentRed = -1;
12 |
13 | private int mCurrentGreen = -1;
14 |
15 | private int mCurrentBlue = -1;
16 |
17 | @Override
18 | public Object evaluate(float fraction, Object startValue, Object endValue) {
19 | String startColor = (String) startValue;
20 | String endColor = (String) endValue;
21 | int startRed = Integer.parseInt(startColor.substring(1, 3), 16);
22 | int startGreen = Integer.parseInt(startColor.substring(3, 5), 16);
23 | int startBlue = Integer.parseInt(startColor.substring(5, 7), 16);
24 | int endRed = Integer.parseInt(endColor.substring(1, 3), 16);
25 | int endGreen = Integer.parseInt(endColor.substring(3, 5), 16);
26 | int endBlue = Integer.parseInt(endColor.substring(5, 7), 16);
27 | // 初始化颜色的值
28 | if (mCurrentRed == -1) {
29 | mCurrentRed = startRed;
30 | }
31 | if (mCurrentGreen == -1) {
32 | mCurrentGreen = startGreen;
33 | }
34 | if (mCurrentBlue == -1) {
35 | mCurrentBlue = startBlue;
36 | }
37 | // 计算初始颜色和结束颜色之间的差值
38 | int redDiff = Math.abs(startRed - endRed);
39 | int greenDiff = Math.abs(startGreen - endGreen);
40 | int blueDiff = Math.abs(startBlue - endBlue);
41 | int colorDiff = redDiff + greenDiff + blueDiff;
42 | if (mCurrentRed != endRed) {
43 | mCurrentRed = getCurrentColor(startRed, endRed, colorDiff, 0,
44 | fraction);
45 | Log.d("TAG", "mCurrentRed = " + mCurrentRed + " fraction = " + fraction);
46 | } else if (mCurrentGreen != endGreen) {
47 | mCurrentGreen = getCurrentColor(startGreen, endGreen, colorDiff,
48 | redDiff, fraction);
49 | Log.d("TAG", "mCurrentGreen = " + mCurrentGreen + " fraction = " + fraction);
50 | } else if (mCurrentBlue != endBlue) {
51 | mCurrentBlue = getCurrentColor(startBlue, endBlue, colorDiff,
52 | redDiff + greenDiff, fraction);
53 | Log.d("TAG", "mCurrentBlue = " + mCurrentBlue + " fraction = " + fraction);
54 | }
55 | // 将计算出的当前颜色的值组装返回
56 | String currentColor = "#" + getHexString(mCurrentRed)
57 | + getHexString(mCurrentGreen) + getHexString(mCurrentBlue);
58 | return currentColor;
59 | }
60 |
61 | /**
62 | * 根据fraction值来计算当前的颜色。
63 | */
64 | private int getCurrentColor(int startColor, int endColor, int colorDiff,
65 | int offset, float fraction) {
66 | int currentColor;
67 | if (startColor > endColor) {
68 | currentColor = (int) (startColor - (fraction * colorDiff - offset));
69 | if (currentColor < endColor) {
70 | currentColor = endColor;
71 | }
72 | } else {
73 | currentColor = (int) (startColor + (fraction * colorDiff - offset));
74 | if (currentColor > endColor) {
75 | currentColor = endColor;
76 | }
77 | }
78 | return currentColor;
79 | }
80 |
81 | /**
82 | * 将10进制颜色值转换成16进制。
83 | */
84 | private String getHexString(int value) {
85 | String hexString = Integer.toHexString(value);
86 | if (hexString.length() == 1) {
87 | hexString = "0" + hexString;
88 | }
89 | return hexString;
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/ConfirmView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.graphics.PathMeasure;
10 | import android.graphics.RectF;
11 | import android.os.Handler;
12 | import android.util.AttributeSet;
13 | import android.util.Log;
14 | import android.view.View;
15 | import android.view.animation.AccelerateDecelerateInterpolator;
16 | import android.view.animation.LinearInterpolator;
17 |
18 | import java.util.ArrayList;
19 |
20 | public class ConfirmView extends View {
21 |
22 | //绘制√和×及快速旋转弧形的动画时间
23 | private static final long NORMAL_ANIMATION_DURATION = 350L;
24 | //绘制正常弧形的动画时间
25 | private static final long NORMAL_ANGLE_ANIMATION_DURATION = 1000L;
26 | //绘制偏移角度的动画时间
27 | private static final long NORMAL_CIRCLE_ANIMATION_DURATION = 2000L;
28 | //绘制×需要的path数量
29 | private static final int PATH_SIZE_TWO = 2;
30 |
31 | public static final int STROKEN_WIDTH = 20;
32 |
33 | private int[] colors = {0xFF0099CC, 0xFF99CC00, 0xFFCC0099, 0xFFCC9900, 0xFF9900CC, 0xFF00CC99};
34 | private int colorCursor = 0;
35 |
36 | private State mCurrentState = State.Success;
37 |
38 | private Path mSuccessPath;
39 | private PathMeasure mPathMeasure;
40 | private ArrayList mRenderPaths;
41 | private Paint mPaint;
42 |
43 | private int mCenterX;
44 | private int mCenterY;
45 |
46 | private int mRadius;
47 | private int mSignRadius;
48 | private float mPhare;
49 | private float mStartAngle;
50 | private float mEndAngle;
51 | private float mCircleAngle;
52 | private RectF oval;
53 |
54 | private ValueAnimator mPhareAnimator;
55 | private ValueAnimator mStartAngleAnimator;
56 | private ValueAnimator mEndAngleAnimator;
57 | private ValueAnimator mCircleAnimator;
58 |
59 | public ConfirmView(Context context) {
60 | this(context, null);
61 | }
62 |
63 | public ConfirmView(Context context, AttributeSet attrs) {
64 | this(context, attrs, 0);
65 | }
66 |
67 | public ConfirmView(Context context, AttributeSet attrs, int defStyle) {
68 | super(context, attrs, defStyle);
69 |
70 | mSuccessPath = new Path();
71 | mPathMeasure = new PathMeasure(mSuccessPath, false);
72 | mRenderPaths = new ArrayList<>();
73 |
74 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
75 | mPaint.setStyle(Paint.Style.STROKE);
76 | mPaint.setColor(0xFF0099CC);
77 | mPaint.setStrokeWidth(STROKEN_WIDTH);
78 | mPaint.setStrokeCap(Paint.Cap.ROUND);
79 |
80 | oval = new RectF();
81 | }
82 |
83 |
84 | private void setPhare(float phare) {
85 | mPhare = phare;
86 | updatePhare();
87 | invalidate();
88 | }
89 |
90 | private void setStartAngle(float startAngle) {
91 | this.mStartAngle = startAngle;
92 | invalidate();
93 | }
94 |
95 | private void setEndAngle(float endAngle) {
96 | this.mEndAngle = endAngle;
97 | invalidate();
98 | }
99 |
100 | private void setCircleAngle(float circleAngle) {
101 | this.mCircleAngle = circleAngle;
102 | invalidate();
103 | }
104 |
105 | ///////////////////////////////////////////////////////////////////////////
106 | // Phare Animation
107 | ///////////////////////////////////////////////////////////////////////////
108 |
109 | public void startPhareAnimation() {
110 | if (mPhareAnimator == null) {
111 | mPhareAnimator = ValueAnimator.ofFloat(0.0F, 1.0F);
112 | mPhareAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
113 | @Override
114 | public void onAnimationUpdate(ValueAnimator animation) {
115 | float value = (Float) animation.getAnimatedValue();
116 | setPhare(value);
117 | }
118 | });
119 |
120 | mPhareAnimator.setDuration(NORMAL_ANIMATION_DURATION);
121 | mPhareAnimator.setInterpolator(new LinearInterpolator());
122 | }
123 | mPhare = 0;
124 | mPhareAnimator.start();
125 | }
126 |
127 | public void stopPhareAnimation() {
128 | if (mPhareAnimator != null) {
129 | mPhareAnimator.end();
130 | }
131 | }
132 |
133 | private void updatePhare() {
134 |
135 | if (mSuccessPath != null) {
136 |
137 | switch (mCurrentState) {
138 | case Success: {
139 | if (mPathMeasure.getSegment(0, mPhare * mPathMeasure.getLength(), mRenderPaths.get(0), true)) {
140 | mRenderPaths.get(0).rLineTo(0, 0);
141 | }
142 | }
143 | break;
144 | case Fail: {
145 | //i = 0,画一半,i=1,画另一半
146 | float seg = 1.0F / PATH_SIZE_TWO;
147 |
148 | for (int i = 0; i < PATH_SIZE_TWO; i++) {
149 | float offset = mPhare - seg * i;
150 | offset = offset < 0 ? 0 : offset;
151 | offset *= PATH_SIZE_TWO;
152 | Log.d("i:" + i + ",seg:" + seg, "offset:" + offset + ", mPhare:" + mPhare + ", size:" + PATH_SIZE_TWO);
153 | boolean success = mPathMeasure.getSegment(0, offset * mPathMeasure.getLength(), mRenderPaths.get(i), true);
154 |
155 | if (success) {
156 | mRenderPaths.get(i).rLineTo(0, 0);
157 | }
158 |
159 | mPathMeasure.nextContour();
160 | }
161 | mPathMeasure.setPath(mSuccessPath, false);
162 | }
163 | break;
164 | }
165 |
166 | }
167 | }
168 |
169 | ///////////////////////////////////////////////////////////////////////////
170 | // Progressing Circle
171 | ///////////////////////////////////////////////////////////////////////////
172 |
173 | public void startCircleAnimation() {
174 | if (mCircleAnimator == null || mStartAngleAnimator == null || mEndAngleAnimator == null) {
175 | initAngleAnimation();
176 | }
177 |
178 | mStartAngleAnimator.setDuration(NORMAL_ANGLE_ANIMATION_DURATION);
179 | mEndAngleAnimator.setDuration(NORMAL_ANGLE_ANIMATION_DURATION);
180 | mCircleAnimator.setDuration(NORMAL_CIRCLE_ANIMATION_DURATION);
181 | mStartAngleAnimator.start();
182 | mEndAngleAnimator.start();
183 | mCircleAnimator.start();
184 | }
185 |
186 |
187 | private void initAngleAnimation() {
188 |
189 | mStartAngleAnimator = ValueAnimator.ofFloat(0.0F, 1.0F);
190 | mEndAngleAnimator = ValueAnimator.ofFloat(0.0F, 1.0F);
191 | mCircleAnimator = ValueAnimator.ofFloat(0.0F, 1.0F);
192 |
193 | mStartAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
194 | @Override
195 | public void onAnimationUpdate(ValueAnimator animation) {
196 | float value = (Float) animation.getAnimatedValue();
197 | setStartAngle(value);
198 | }
199 | });
200 | mEndAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
201 | @Override
202 | public void onAnimationUpdate(ValueAnimator animation) {
203 | float value = (Float) animation.getAnimatedValue();
204 | setEndAngle(value);
205 | }
206 | });
207 |
208 | mStartAngleAnimator.addListener(new Animator.AnimatorListener() {
209 | @Override
210 | public void onAnimationStart(Animator animation) {
211 |
212 | if (mCurrentState == State.Progressing) {
213 | if (mEndAngleAnimator != null) {
214 | new Handler().postDelayed(new Runnable() {
215 | @Override
216 | public void run() {
217 | mEndAngleAnimator.start();
218 | }
219 | }, 400L);
220 | }
221 | }
222 | }
223 |
224 | @Override
225 | public void onAnimationEnd(Animator animation) {
226 | if (mCurrentState != State.Progressing && mEndAngleAnimator != null && !mEndAngleAnimator.isRunning() && !mEndAngleAnimator.isStarted()) {
227 | startPhareAnimation();
228 | }
229 | }
230 |
231 | @Override
232 | public void onAnimationCancel(Animator animation) {
233 | }
234 |
235 | @Override
236 | public void onAnimationRepeat(Animator animation) {
237 | }
238 | });
239 |
240 | mEndAngleAnimator.addListener(new Animator.AnimatorListener() {
241 | @Override
242 | public void onAnimationStart(Animator animation) {
243 |
244 | }
245 |
246 | @Override
247 | public void onAnimationEnd(Animator animation) {
248 | if (mStartAngleAnimator != null) {
249 | if (mCurrentState != State.Progressing) {
250 | mStartAngleAnimator.setDuration(NORMAL_ANIMATION_DURATION);
251 | }
252 | colorCursor++;
253 | if (colorCursor >= colors.length) colorCursor = 0;
254 | mPaint.setColor(colors[colorCursor]);
255 | mStartAngleAnimator.start();
256 | }
257 | }
258 |
259 | @Override
260 | public void onAnimationCancel(Animator animation) {
261 | }
262 |
263 | @Override
264 | public void onAnimationRepeat(Animator animation) {
265 | }
266 | });
267 |
268 | mCircleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
269 | @Override
270 | public void onAnimationUpdate(ValueAnimator animation) {
271 | float value = (float) animation.getAnimatedValue();
272 | setCircleAngle(value);
273 | }
274 | });
275 |
276 |
277 | mStartAngleAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
278 | mEndAngleAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
279 |
280 |
281 | mCircleAnimator.setInterpolator(new LinearInterpolator());
282 | mCircleAnimator.setRepeatCount(-1);
283 | }
284 |
285 | public void animatedWithState(State state) {
286 |
287 | if (mCurrentState != state) {
288 | mCurrentState = state;
289 | if (mPhareAnimator != null && mPhareAnimator.isRunning()) {
290 | stopPhareAnimation();
291 | }
292 | switch (state) {
293 | case Fail:
294 | case Success:
295 | updatePath();
296 | if (mCircleAnimator != null && mCircleAnimator.isRunning()) {
297 | mCircleAngle = (Float) mCircleAnimator.getAnimatedValue();
298 | mCircleAnimator.end();
299 | }
300 |
301 | if ((mStartAngleAnimator == null || !mStartAngleAnimator.isRunning() || !mStartAngleAnimator.isStarted()) &&
302 | (mEndAngleAnimator == null || !mEndAngleAnimator.isRunning() || !mEndAngleAnimator.isStarted())) {
303 | mStartAngle = 360;
304 | mEndAngle = 0;
305 | startPhareAnimation();
306 | }
307 |
308 | break;
309 | case Progressing:
310 | mCircleAngle = 0;
311 | startCircleAnimation();
312 | break;
313 | }
314 | }
315 |
316 | }
317 |
318 | private void updatePath() {
319 |
320 | int offset = (int) (mSignRadius * 0.15F);
321 | mRenderPaths.clear();
322 |
323 | switch (mCurrentState) {
324 | case Success:
325 | mSuccessPath.reset();
326 | mSuccessPath.moveTo(mCenterX - mSignRadius, mCenterY + offset);
327 | mSuccessPath.lineTo(mCenterX - offset, mCenterY + mSignRadius - offset);
328 | mSuccessPath.lineTo(mCenterX + mSignRadius, mCenterY - mSignRadius + offset);
329 | mRenderPaths.add(new Path());
330 | break;
331 | case Fail:
332 | mSuccessPath.reset();
333 | float failRadius = mSignRadius * 0.8F;
334 | mSuccessPath.moveTo(mCenterX - failRadius, mCenterY - failRadius);
335 | mSuccessPath.lineTo(mCenterX + failRadius, mCenterY + failRadius);
336 | mSuccessPath.moveTo(mCenterX + failRadius, mCenterY - failRadius);
337 | mSuccessPath.lineTo(mCenterX - failRadius, mCenterY + failRadius);
338 | for (int i = 0; i < PATH_SIZE_TWO; i++) {
339 | mRenderPaths.add(new Path());
340 | }
341 | break;
342 | default:
343 | mSuccessPath.reset();
344 | }
345 |
346 | mPathMeasure.setPath(mSuccessPath, false);
347 |
348 | }
349 |
350 |
351 | @Override
352 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
353 | super.onSizeChanged(w, h, oldw, oldh);
354 |
355 | mCenterX = w / 2;
356 | mCenterY = h / 2;
357 |
358 | mRadius = mCenterX > mCenterY ? mCenterY : mCenterX;
359 | mSignRadius = (int) (mRadius * 0.55F);
360 |
361 | int realRadius = mRadius - (STROKEN_WIDTH / 2);
362 |
363 | oval.left = mCenterX - realRadius;
364 | oval.top = mCenterY - realRadius;
365 | oval.right = mCenterX + realRadius;
366 | oval.bottom = mCenterY + realRadius;
367 |
368 | updatePath();
369 | }
370 |
371 | @Override
372 | public void onDraw(Canvas canvas) {
373 | super.onDraw(canvas);
374 |
375 | switch (mCurrentState) {
376 | case Fail:
377 | for (int i = 0; i < PATH_SIZE_TWO; i++) {
378 | Path p = mRenderPaths.get(i);
379 | if (p != null) {
380 | canvas.drawPath(p, mPaint);
381 | }
382 | }
383 | drawCircle(canvas);
384 | break;
385 | case Success:
386 | Path p = mRenderPaths.get(0);
387 | if (p != null) {
388 | canvas.drawPath(p, mPaint);
389 | }
390 | drawCircle(canvas);
391 | break;
392 | case Progressing:
393 | drawCircle(canvas);
394 | break;
395 | }
396 |
397 | }
398 |
399 | private void drawCircle(Canvas canvas) {
400 | float offsetAngle = mCircleAngle * 360;
401 | float startAngle = mEndAngle * 360;
402 | float sweepAngle = mStartAngle * 360;
403 |
404 | if (startAngle == 360)
405 | startAngle = 0;
406 | sweepAngle = sweepAngle - startAngle;
407 | startAngle += offsetAngle;
408 |
409 | if (sweepAngle < 0)
410 | sweepAngle = 1;
411 |
412 | canvas.drawArc(oval, startAngle, sweepAngle, false, mPaint);
413 | }
414 |
415 | public enum State {
416 | Success, Fail, Progressing
417 | }
418 | }
419 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/FllowerView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.graphics.Bitmap;
7 | import android.graphics.BitmapFactory;
8 | import android.graphics.Canvas;
9 | import android.graphics.Color;
10 | import android.graphics.Paint;
11 | import android.graphics.Path;
12 | import android.graphics.PathMeasure;
13 | import android.util.AttributeSet;
14 | import android.util.TypedValue;
15 | import android.view.View;
16 | import android.view.WindowManager;
17 | import android.view.animation.AccelerateInterpolator;
18 |
19 | import com.socks.androiddemo.R;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import java.util.Random;
24 |
25 | /**
26 | * Created by zhaokaiqiang on 15/9/15.
27 | */
28 | public class FllowerView extends View implements ValueAnimator.AnimatorUpdateListener {
29 |
30 | /**
31 | * 动画改变的属性值
32 | */
33 | private float phase1 = 0f;
34 | private float phase2 = 0f;
35 | private float phase3 = 0f;
36 |
37 | private int fllowerCount = 4;
38 |
39 | private int width = 0;
40 | private int height = 0;
41 |
42 | private List fllowers1 = new ArrayList<>();
43 | private List fllowers2 = new ArrayList<>();
44 | private List fllowers3 = new ArrayList<>();
45 |
46 | private int time = 4000;
47 | private int delay = 500;
48 |
49 | //曲线高度个数分割
50 | private int quadCount = 10;
51 | //曲度
52 | private float intensity = 0.2f;
53 |
54 | //曲线摇摆的幅度
55 | private int range = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics());
56 |
57 | private int top = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
58 |
59 | private Paint mPaint;
60 | private PathMeasure pathMeasure = null;
61 |
62 | private Bitmap mBitmap;
63 |
64 | public FllowerView(Context context) {
65 | super(context);
66 | init(context);
67 | }
68 |
69 | public FllowerView(Context context, AttributeSet attrs) {
70 | super(context, attrs);
71 | init(context);
72 | }
73 |
74 | private void init(Context context) {
75 | WindowManager wm = (WindowManager) context
76 | .getSystemService(Context.WINDOW_SERVICE);
77 | width = wm.getDefaultDisplay().getWidth();
78 | // height = wm.getDefaultDisplay().getHeight();
79 | height = (int) (wm.getDefaultDisplay().getHeight() * 3 / 2f);
80 |
81 | mPaint = new Paint();
82 | mPaint.setAntiAlias(true);
83 | mPaint.setStrokeWidth(2);
84 | mPaint.setColor(Color.BLUE);
85 | mPaint.setStyle(Paint.Style.STROKE);
86 |
87 | pathMeasure = new PathMeasure();
88 | mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_heart);
89 |
90 | builderFollower(fllowerCount, fllowers1);
91 | builderFollower(fllowerCount, fllowers2);
92 | builderFollower(fllowerCount, fllowers3);
93 |
94 | }
95 |
96 |
97 | /**
98 | * 创建花
99 | */
100 | private void builderFollower(int count, List fllowers) {
101 |
102 | int max = (int) (width * 3 / 4f);
103 | int min = (int) (width / 4f);
104 | Random random = new Random();
105 | for (int i = 0; i < count; i++) {
106 | int s = random.nextInt(max) % (max - min + 1) + min;
107 | Path path = new Path();
108 | CPoint cPoint = new CPoint(s, 0);
109 | List points = builderPath(cPoint);
110 | drawFllowerPath(path, points);
111 | Fllower fllower = new Fllower();
112 | fllower.setPath(path);
113 | fllowers.add(fllower);
114 | }
115 |
116 | }
117 |
118 | /**
119 | * 画曲线
120 | *
121 | * @param path
122 | * @param points
123 | */
124 | private void drawFllowerPath(Path path, List points) {
125 | if (points.size() > 1) {
126 | for (int j = 0; j < points.size(); j++) {
127 |
128 | CPoint point = points.get(j);
129 |
130 | if (j == 0) {
131 | CPoint next = points.get(j + 1);
132 | point.dx = ((next.x - point.x) * intensity);
133 | point.dy = ((next.y - point.y) * intensity);
134 | } else if (j == points.size() - 1) {
135 | CPoint prev = points.get(j - 1);
136 | point.dx = ((point.x - prev.x) * intensity);
137 | point.dy = ((point.y - prev.y) * intensity);
138 | } else {
139 | CPoint next = points.get(j + 1);
140 | CPoint prev = points.get(j - 1);
141 | point.dx = ((next.x - prev.x) * intensity);
142 | point.dy = ((next.y - prev.y) * intensity);
143 | }
144 |
145 | // create the cubic-spline path
146 | if (j == 0) {
147 | path.moveTo(point.x, point.y);
148 | } else {
149 | CPoint prev = points.get(j - 1);
150 | path.cubicTo(prev.x + prev.dx, (prev.y + prev.dy),
151 | point.x - point.dx, (point.y - point.dy),
152 | point.x, point.y);
153 | }
154 | }
155 | }
156 | }
157 |
158 |
159 | /**
160 | * 画路径
161 | *
162 | * @param point
163 | * @return
164 | */
165 | private List builderPath(CPoint point) {
166 | List points = new ArrayList();
167 | Random random = new Random();
168 | for (int i = 0; i < quadCount; i++) {
169 | if (i == 0) {
170 | points.add(point);
171 | } else {
172 | CPoint tmp = new CPoint(0, 0);
173 | if (random.nextInt(100) % 2 == 0) {
174 | tmp.x = point.x + random.nextInt(range);
175 | } else {
176 | tmp.x = point.x - random.nextInt(range);
177 | }
178 | tmp.y = (int) (height / (float) quadCount * i);
179 | points.add(tmp);
180 | }
181 | }
182 | return points;
183 | }
184 |
185 |
186 | @Override
187 | protected void onDraw(Canvas canvas) {
188 | super.onDraw(canvas);
189 |
190 | drawFllower(canvas, fllowers1);
191 | drawFllower(canvas, fllowers2);
192 | drawFllower(canvas, fllowers3);
193 |
194 | }
195 |
196 | /**
197 | * @param canvas
198 | * @param fllowers
199 | */
200 | private void drawFllower(Canvas canvas, List fllowers) {
201 | for (Fllower fllower : fllowers) {
202 | float[] pos = new float[2];
203 |
204 | // canvas.drawPath(fllower.getPath(), mPaint);
205 |
206 | pathMeasure.setPath(fllower.getPath(), false);
207 | pathMeasure.getPosTan(height * fllower.getValue(), pos, null);
208 | canvas.drawBitmap(mBitmap, pos[0], pos[1] - top, null);
209 | }
210 | }
211 |
212 | public void startAnimation() {
213 | ObjectAnimator mAnimator1 = ObjectAnimator.ofFloat(this, "phase1", 0f,
214 | 1f);
215 | mAnimator1.setDuration(time);
216 | mAnimator1.addUpdateListener(this);
217 | mAnimator1.setInterpolator(new AccelerateInterpolator());
218 |
219 | ObjectAnimator mAnimator2 = ObjectAnimator.ofFloat(this, "phase2", 0f,
220 | 1f);
221 | mAnimator2.setDuration(time);
222 | mAnimator2.addUpdateListener(this);
223 | mAnimator2.setInterpolator(new AccelerateInterpolator());
224 | mAnimator2.setStartDelay(delay);
225 |
226 | ObjectAnimator mAnimator3 = ObjectAnimator.ofFloat(this, "phase3", 0f,
227 | 1f);
228 | mAnimator3.setDuration(time);
229 | mAnimator3.addUpdateListener(this);
230 | mAnimator3.setInterpolator(new AccelerateInterpolator());
231 | mAnimator3.setStartDelay(delay * 2);
232 |
233 | mAnimator2.start();
234 | mAnimator1.start();
235 | mAnimator3.start();
236 | }
237 |
238 | private void updateValue(float value, List fllowers) {
239 | for (Fllower fllower : fllowers) {
240 | fllower.setValue(value);
241 | }
242 | }
243 |
244 | @Override
245 | public void onAnimationUpdate(ValueAnimator arg0) {
246 |
247 | updateValue(getPhase1(), fllowers1);
248 | updateValue(getPhase2(), fllowers2);
249 | updateValue(getPhase3(), fllowers3);
250 | invalidate();
251 | }
252 |
253 | public float getPhase1() {
254 | return phase1;
255 | }
256 |
257 | public void setPhase1(float phase1) {
258 | this.phase1 = phase1;
259 | }
260 |
261 | public float getPhase2() {
262 | return phase2;
263 | }
264 |
265 | public void setPhase2(float phase2) {
266 | this.phase2 = phase2;
267 | }
268 |
269 | public float getPhase3() {
270 | return phase3;
271 | }
272 |
273 | public void setPhase3(float phase3) {
274 | this.phase3 = phase3;
275 |
276 | }
277 |
278 | class CPoint {
279 |
280 | public float x = 0f;
281 | public float y = 0f;
282 |
283 | public float dx = 0f;
284 | public float dy = 0f;
285 |
286 | public CPoint(float x, float y) {
287 | this.x = x;
288 | this.y = y;
289 | }
290 | }
291 |
292 | public class Fllower {
293 |
294 | private Path mPath;
295 |
296 | private float value;
297 |
298 | public Path getPath() {
299 | return mPath;
300 | }
301 |
302 | public void setPath(Path mPath) {
303 | this.mPath = mPath;
304 | }
305 |
306 | public float getValue() {
307 | return value;
308 | }
309 |
310 | public void setValue(float value) {
311 | this.value = value;
312 | }
313 | }
314 |
315 |
316 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/InnerListview.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.MotionEvent;
6 | import android.widget.ListView;
7 |
8 | /**
9 | * Created by zhaokaiqiang on 15/8/21.
10 | */
11 | public class InnerListview extends ListView{
12 | public InnerListview(Context context) {
13 | super(context);
14 | }
15 |
16 | public InnerListview(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public InnerListview(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | }
23 |
24 | public InnerListview(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
25 | super(context, attrs, defStyleAttr, defStyleRes);
26 | }
27 |
28 | @Override
29 | public boolean onTouchEvent(MotionEvent ev) {
30 |
31 | getParent().requestDisallowInterceptTouchEvent(true);
32 |
33 | switch (ev.getAction()){
34 | case MotionEvent.ACTION_UP:
35 | getParent().requestDisallowInterceptTouchEvent(false);
36 | break;
37 | }
38 |
39 | return super.onTouchEvent(ev);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/LightingColorFilterView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.LightingColorFilter;
8 | import android.graphics.Paint;
9 | import android.util.AttributeSet;
10 | import android.widget.ImageView;
11 |
12 | import com.socks.androiddemo.R;
13 |
14 | /**
15 | * Created by zhaokaiqiang on 15/9/14.
16 | */
17 | public class LightingColorFilterView extends ImageView {
18 |
19 | private Paint mPaint;// 画笔
20 | private Bitmap bitmap;// 位图
21 |
22 | public LightingColorFilterView(Context context) {
23 | this(context, null);
24 | }
25 |
26 | public LightingColorFilterView(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 |
29 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
30 | mPaint.setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0x00FF00FF));
31 | bitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
32 |
33 | }
34 |
35 | @Override
36 | protected void onDraw(Canvas canvas) {
37 | canvas.drawBitmap(bitmap, 0, 0, mPaint);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/PathView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Path;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * Created by zhaokaiqiang on 15/9/21.
12 | */
13 | public class PathView extends View {
14 |
15 |
16 | private Paint mPaint;
17 | private Path mPath;
18 |
19 | public PathView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public PathView(Context context, AttributeSet attrs) {
24 | this(context, attrs, 0);
25 | }
26 |
27 | public PathView(Context context, AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | init();
30 | }
31 |
32 | private void init() {
33 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
34 | mPaint.setStyle(Paint.Style.FILL);
35 | mPath = new Path();
36 | }
37 |
38 | @Override
39 | protected void onDraw(Canvas canvas) {
40 | super.onDraw(canvas);
41 | mPath.addCircle(300,300,100, Path.Direction.CW);
42 | canvas.drawPath(mPath, mPaint);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/Point.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | /**
4 | * Created by zhaokaiqiang on 15/8/16.
5 | */
6 | public class Point {
7 |
8 | private float x;
9 |
10 | private float y;
11 |
12 | public Point(float x, float y) {
13 | this.x = x;
14 | this.y = y;
15 | }
16 |
17 | public float getX() {
18 | return x;
19 | }
20 |
21 | public float getY() {
22 | return y;
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/PointEvaluator.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.TypeEvaluator;
4 |
5 | /**
6 | * Created by zhaokaiqiang on 15/8/16.
7 | */
8 | public class PointEvaluator implements TypeEvaluator {
9 |
10 | @Override
11 | public Object evaluate(float fraction, Object startValue, Object endValue) {
12 | Point startPoint = (Point) startValue;
13 | Point endPoint = (Point) endValue;
14 | float x = startPoint.getX() + fraction * (endPoint.getX() - startPoint.getX());
15 | float y = startPoint.getY() + fraction * (endPoint.getY() - startPoint.getY());
16 | Point point = new Point(x, y);
17 | return point;
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/PointView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.content.Context;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 |
13 | /**
14 | * Created by zhaokaiqiang on 15/8/17.
15 | */
16 | public class PointView extends View {
17 |
18 | public static final float RADIUS = 50f;
19 |
20 | private Point currentPoint;
21 |
22 | private Paint mPaint;
23 |
24 | private String color;
25 |
26 | public PointView(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
29 | mPaint.setColor(Color.BLUE);
30 | }
31 |
32 | public String getColor() {
33 | return color;
34 | }
35 |
36 | public void setColor(String color) {
37 | this.color = color;
38 | mPaint.setColor(Color.parseColor(color));
39 | invalidate();
40 | }
41 |
42 | @Override
43 | protected void onDraw(Canvas canvas) {
44 | if (currentPoint == null) {
45 | currentPoint = new Point(RADIUS, RADIUS);
46 | drawCircle(canvas);
47 | startAnimation();
48 | } else {
49 | drawCircle(canvas);
50 | }
51 | }
52 |
53 | private void drawCircle(Canvas canvas) {
54 | float x = currentPoint.getX();
55 | float y = currentPoint.getY();
56 | canvas.drawCircle(x, y, RADIUS, mPaint);
57 | }
58 |
59 | private void startAnimation() {
60 | Point startPoint = new Point(RADIUS, RADIUS);
61 | Point endPoint = new Point(getWidth() - RADIUS, getHeight() - RADIUS);
62 | ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint);
63 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
64 | @Override
65 | public void onAnimationUpdate(ValueAnimator animation) {
66 | currentPoint = (Point) animation.getAnimatedValue();
67 | invalidate();
68 | }
69 | });
70 | ObjectAnimator anim2 = ObjectAnimator.ofObject(this, "color", new ColorEvaluator(),
71 | "#00FFFF", "#FF1100");
72 | AnimatorSet animSet = new AnimatorSet();
73 | animSet.play(anim).with(anim2);
74 | animSet.setDuration(5000);
75 | animSet.start();
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/ShaderView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.LinearGradient;
7 | import android.graphics.Paint;
8 | import android.graphics.Shader;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 |
12 | /**
13 | * Created by zhaokaiqiang on 15/9/17.
14 | */
15 | public class ShaderView extends View {
16 |
17 | private float mWidth;
18 | private float mHeight;
19 |
20 | private Paint mPaint;
21 |
22 | LinearGradient linearGradient;
23 |
24 | public ShaderView(Context context) {
25 | super(context);
26 | init();
27 | }
28 |
29 | public ShaderView(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | init();
32 | }
33 |
34 | public ShaderView(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | init();
37 | }
38 |
39 | private void init() {
40 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
41 | }
42 |
43 | @Override
44 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
45 | super.onSizeChanged(w, h, oldw, oldh);
46 | mWidth = w;
47 | mHeight = h;
48 | linearGradient = new LinearGradient(0, 0, 0, mHeight / 2,
49 | new int[]{Color.RED, Color.YELLOW},
50 | new float[]{0.2f, 0.8f}, Shader.TileMode.CLAMP);
51 | }
52 |
53 | @Override
54 | protected void onDraw(Canvas canvas) {
55 | mPaint.setShader(linearGradient);
56 | canvas.drawRect(0, 0, mWidth / 2, mHeight / 2, mPaint);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/TextPaintView.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.text.TextPaint;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 |
9 | /**
10 | * Created by zhaokaiqiang on 15/9/21.
11 | */
12 | public class TextPaintView extends View{
13 |
14 | private TextPaint mPaint;
15 |
16 | public TextPaintView(Context context) {
17 | super(context);
18 | }
19 |
20 | public TextPaintView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public TextPaintView(Context context, AttributeSet attrs, int defStyleAttr) {
25 | super(context, attrs, defStyleAttr);
26 | }
27 |
28 |
29 |
30 | @Override
31 | protected void onDraw(Canvas canvas) {
32 | super.onDraw(canvas);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/socks/androiddemo/view/Titanic.java:
--------------------------------------------------------------------------------
1 | package com.socks.androiddemo.view;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.os.Build;
8 | import android.view.animation.LinearInterpolator;
9 |
10 | /**
11 | * Titanic
12 | * User: romainpiel
13 | * Date: 14/03/2014
14 | * Time: 09:34
15 | */
16 | public class Titanic {
17 |
18 | private AnimatorSet animatorSet;
19 | private Animator.AnimatorListener animatorListener;
20 |
21 | public Animator.AnimatorListener getAnimatorListener() {
22 | return animatorListener;
23 | }
24 |
25 | public void setAnimatorListener(Animator.AnimatorListener animatorListener) {
26 | this.animatorListener = animatorListener;
27 | }
28 |
29 | public void start(final BitmapShaderView textView) {
30 |
31 | final Runnable animate = new Runnable() {
32 | @Override
33 | public void run() {
34 |
35 | textView.setSinking(true);
36 |
37 | // horizontal animation. 200 = wave.png width
38 | ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
39 | maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
40 | maskXAnimator.setDuration(1000);
41 | maskXAnimator.setStartDelay(0);
42 |
43 | int h = textView.getHeight();
44 |
45 | // vertical animation
46 | // maskY = 0 -> wave vertically centered
47 | // repeat mode REVERSE to go back and forth
48 | ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
49 | maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
50 | maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
51 | maskYAnimator.setDuration(10000);
52 | maskYAnimator.setStartDelay(0);
53 |
54 | // now play both animations together
55 | animatorSet = new AnimatorSet();
56 | animatorSet.playTogether(maskXAnimator, maskYAnimator);
57 | animatorSet.setInterpolator(new LinearInterpolator());
58 | animatorSet.addListener(new Animator.AnimatorListener() {
59 | @Override
60 | public void onAnimationStart(Animator animation) {
61 | }
62 |
63 | @Override
64 | public void onAnimationEnd(Animator animation) {
65 | textView.setSinking(false);
66 |
67 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
68 | textView.postInvalidate();
69 | } else {
70 | textView.postInvalidateOnAnimation();
71 | }
72 |
73 | animatorSet = null;
74 | }
75 |
76 | @Override
77 | public void onAnimationCancel(Animator animation) {
78 |
79 | }
80 |
81 | @Override
82 | public void onAnimationRepeat(Animator animation) {
83 |
84 | }
85 | });
86 |
87 |
88 | if (animatorListener != null) {
89 | animatorSet.addListener(animatorListener);
90 | }
91 |
92 | animatorSet.start();
93 | }
94 | };
95 |
96 | if (!textView.isSetUp()) {
97 | textView.setAnimationSetupCallback(new BitmapShaderView.AnimationSetupCallback() {
98 | @Override
99 | public void onSetupAnimation(final BitmapShaderView target) {
100 | animate.run();
101 | }
102 | });
103 | } else {
104 | animate.run();
105 | }
106 | }
107 |
108 | public void cancel() {
109 | if (animatorSet != null) {
110 | animatorSet.cancel();
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/grediat.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/drawable/ic_heart.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sophie.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/drawable/sophie.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/wave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/drawable/wave.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_all.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_animator.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bitmap_shader.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera_3d.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
12 |
13 |
18 |
19 |
25 |
26 |
32 |
33 |
40 |
41 |
42 |
43 |
48 |
49 |
55 |
56 |
62 |
63 |
70 |
71 |
72 |
73 |
78 |
79 |
85 |
86 |
92 |
93 |
100 |
101 |
102 |
103 |
106 |
107 |
112 |
113 |
119 |
120 |
124 |
125 |
126 |
127 |
132 |
133 |
139 |
140 |
144 |
145 |
146 |
147 |
152 |
153 |
159 |
160 |
164 |
165 |
166 |
167 |
168 |
169 |
173 |
174 |
180 |
181 |
185 |
186 |
187 |
188 |
193 |
194 |
200 |
201 |
209 |
210 |
217 |
218 |
219 |
220 |
225 |
226 |
232 |
233 |
241 |
242 |
249 |
250 |
251 |
252 |
257 |
258 |
264 |
265 |
273 |
274 |
281 |
282 |
283 |
284 |
287 |
288 |
293 |
294 |
300 |
301 |
304 |
305 |
306 |
307 |
312 |
313 |
319 |
320 |
324 |
325 |
326 |
327 |
332 |
333 |
339 |
340 |
344 |
345 |
346 |
347 |
348 |
352 |
353 |
359 |
360 |
364 |
365 |
366 |
367 |
368 |
369 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_canvas.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_color_matrix.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
17 |
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_confirm.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
11 |
12 |
17 |
18 |
23 |
24 |
29 |
30 |
31 |
32 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_fllower.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_floating_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_focus.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
9 |
10 |
13 |
14 |
17 |
18 |
19 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_half_width.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_intent.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_load.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_notifycation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_other.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pointview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_shader.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_spannable.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test_transform_matrix.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_utils.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_activitys.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_intent.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_load.xml:
--------------------------------------------------------------------------------
1 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_test_transform_matrix.xml:
--------------------------------------------------------------------------------
1 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_utils.xml:
--------------------------------------------------------------------------------
1 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidDemo
3 |
4 | Hello world!
5 | Settings
6 | UtilsActivity
7 | IntentActivity
8 | LoadActivity
9 |
10 | Welcome toAndroid!
11 |
12 |
13 | Hello, %1$s! You have <b>%2$d new messages</b>.
14 | TestTransformMatrixActivity
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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:1.1.0'
9 | // NOTE: Do not place your application dependencies here; they belong
10 | // in the individual module build.gradle files
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/gradle/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 27 14:14:41 CST 2015
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-2.2.1-bin.zip
7 |
--------------------------------------------------------------------------------
/gradle/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradle/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhaoKaiQiang/AndroidDemo/af5f0ac879dffe4db8ba43344218e57d3d9b9e04/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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-2.2.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------