├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── easycountdowntextureview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── camnter
│ │ └── easycountdowntextureview
│ │ └── EasyCountDownTextureView.java
│ └── res
│ └── values
│ └── attrs.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── samples
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── camnter
│ │ └── easycountdowntextureview
│ │ └── demo
│ │ ├── CompletedActivity.java
│ │ ├── MainActivity.java
│ │ ├── SettingActivity.java
│ │ ├── ShowActivity.java
│ │ └── adapter
│ │ └── MainAdapter.java
│ └── res
│ ├── layout
│ ├── activity_completed.xml
│ ├── activity_main.xml
│ ├── activity_setting.xml
│ ├── activity_show.xml
│ └── item_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ ├── bg_fruit.png
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── screenshot
├── easy_count_down_textureview.png
├── shouji_taobao.png
├── textureview_1.gif
└── textureview_2.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 |
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | /*/build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Intellij project files
30 | *.iml
31 | *.ipr
32 | *.iws
33 | .idea/
34 | #
35 | # # Mac
36 | .DS_Store
37 | apks/
38 |
39 | # jks
40 | *.jks
41 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | EasyCountDownTextureView
2 | ==
3 |
4 |
5 |
6 |  [](https://github.com/CaMnter/EasyCountDownTextureView/blob/master/LICENSE)
7 | 
8 | 
9 | [  ](https://bintray.com/camnter/maven/EasyCountDownTextureView/_latestVersion)
10 |
11 | **Easy count down by TextureView**
12 |
13 |
14 |
15 |
16 | ## Attention
17 |
18 | **minSdkVersion >= 14**
19 |
20 |
21 |
22 |
23 | ## Gradle
24 |
25 | ```gradle
26 | dependencies {
27 | compile 'com.camnter.easycountdowntextureview:easycountdowntextureview:1.6'
28 | }
29 | ```
30 |
31 |
32 |
33 |
34 | ## Attributes
35 |
36 | ```xml
37 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
73 | ```
74 |
75 |
76 |
77 |
78 | ## Easy use
79 |
80 | ```xml
81 |
86 |
87 |
93 |
94 |
100 |
101 |
102 | ```
103 |
104 |
105 |
106 | 
107 |
108 |
109 |
110 | ```xml
111 |
127 | ```
128 |
129 |
130 |
131 | 
132 |
133 |
134 |
135 |
136 | ## Performance
137 |
138 | Without scrolling, only time in the refreshing
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | ## License
147 |
148 | Copyright (C) 2016 CaMnter yuanyu.camnter@gmail.com
149 |
150 | Licensed under the Apache License, Version 2.0 (the "License");
151 | you may not use this file except in compliance with the License.
152 | You may obtain a copy of the License at
153 |
154 | http://www.apache.org/licenses/LICENSE-2.0
155 |
156 | Unless required by applicable law or agreed to in writing, software
157 | distributed under the License is distributed on an "AS IS" BASIS,
158 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159 | See the License for the specific language governing permissions and
160 | limitations under the License.
161 |
162 |
163 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/easycountdowntextureview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/easycountdowntextureview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 24
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 | }
20 |
21 | dependencies {
22 | compile 'com.android.support:support-annotations:25.0.1'
23 | }
24 |
25 | // ---------
26 |
27 | apply plugin: 'com.android.library'
28 | apply plugin: 'com.github.dcendents.android-maven'
29 | apply plugin: 'com.jfrog.bintray'
30 | // #CONFIG# // project version
31 | version = "1.6"
32 | // #CONFIG# // project homepage
33 | def siteUrl = 'https://github.com/camnter/EasyCountDownTextureView'
34 | // #CONFIG# // project git
35 | def gitUrl = 'https://github.com/camnter/EasyCountDownTextureView.git'
36 | // #CONFIG# // Maven Group ID for the artifact (package name is ok)
37 | group = "com.camnter.easycountdowntextureview"
38 |
39 | install {
40 | repositories.mavenInstaller {
41 | // This generates POM.xml with proper parameters
42 | pom {
43 | project {
44 | packaging 'aar'
45 | //
46 | name 'Easy count down TextureView For Android'
47 | url siteUrl
48 | licenses {
49 | license {
50 | name 'The Apache Software License, Version 2.0'
51 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
52 | }
53 | }
54 | developers {
55 | developer {
56 | //
57 | id 'CaMnter'
58 | //
59 | name 'YuanYuZhang'
60 | //
61 | email '421482590@qq.com'
62 | }
63 | }
64 | scm {
65 | connection gitUrl
66 | developerConnection gitUrl
67 | url siteUrl
68 | }
69 | }
70 | }
71 | }
72 | }
73 | task sourcesJar(type: Jar) {
74 | from android.sourceSets.main.java.srcDirs
75 | classifier = 'sources'
76 | }
77 |
78 |
79 | task javadoc(type: Javadoc) {
80 | source = android.sourceSets.main.java.srcDirs
81 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
82 | }
83 |
84 | task javadocJar(type: Jar, dependsOn: javadoc) {
85 | classifier = 'javadoc'
86 | from javadoc.destinationDir
87 | }
88 |
89 | artifacts {
90 | archives javadocJar
91 | archives sourcesJar
92 | }
93 |
94 |
95 |
96 | Properties properties = new Properties()
97 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
98 | bintray {
99 | user = properties.getProperty("bintray.user")
100 | key = properties.getProperty("bintray.apikey")
101 | configurations = ['archives']
102 | pkg {
103 | repo = "maven"
104 | name = "EasyCountDownTextureView" // project name in jcenter
105 | websiteUrl = siteUrl
106 | vcsUrl = gitUrl
107 | licenses = ["Apache-2.0"]
108 | publish = true
109 | }
110 | }
111 |
112 | // ---------------
113 |
--------------------------------------------------------------------------------
/easycountdowntextureview/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/CaMnter/Android/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/easycountdowntextureview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/easycountdowntextureview/src/main/java/com/camnter/easycountdowntextureview/EasyCountDownTextureView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 CaMnter yuanyu.camnter@gmail.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.camnter.easycountdowntextureview;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.content.res.TypedArray;
22 | import android.graphics.Canvas;
23 | import android.graphics.Color;
24 | import android.graphics.Paint;
25 | import android.graphics.RectF;
26 | import android.graphics.SurfaceTexture;
27 | import android.os.Build;
28 | import android.os.Handler;
29 | import android.os.Looper;
30 | import android.os.Message;
31 | import android.os.SystemClock;
32 | import android.support.annotation.NonNull;
33 | import android.support.annotation.Nullable;
34 | import android.util.AttributeSet;
35 | import android.util.DisplayMetrics;
36 | import android.util.Log;
37 | import android.util.TypedValue;
38 | import android.view.TextureView;
39 | import java.lang.ref.WeakReference;
40 | import java.util.Calendar;
41 | import java.util.Date;
42 | import java.util.Locale;
43 | import java.util.TimeZone;
44 |
45 | /**
46 | * Description:EasyCountDownTextureView
47 | * Created by:CaMnter
48 | * Time:2016-03-16 13:45
49 | */
50 | public class EasyCountDownTextureView extends TextureView
51 | implements TextureView.SurfaceTextureListener {
52 |
53 | private static final String TAG = EasyCountDownTextureView.class.getSimpleName();
54 |
55 | private static final String LESS_THAN_TEN_FORMAT = "%02d";
56 | private static final String COLON = ":";
57 |
58 | private static final int DEFAULT_COLOR_BACKGROUND = Color.BLACK;
59 | private static final int DEFAULT_COLOR_COLON = Color.BLACK;
60 | private static final int DEFAULT_COLOR_TIME = Color.WHITE;
61 | private static final int DEFAULT_COLOR_RECT_BORDER = Color.BLACK;
62 | private DisplayMetrics metrics;
63 |
64 | private static final int COUNT_DOWN_INTERVAL = 1000;
65 |
66 | private static final long ONE_SECOND = 1000L;
67 | private static final long ONE_MINUTE = 60 * ONE_SECOND;
68 | private static final long ONE_HOUR = 60 * ONE_MINUTE;
69 | private static final long ONE_DAY = 24 * ONE_HOUR;
70 |
71 | private volatile long millisInFuture = 0L;
72 |
73 | /**************
74 | * Default dp *
75 | **************/
76 | private static final float DEFAULT_BACKGROUND_PAINT_WIDTH = 0.01f;
77 | private static final float DEFAULT_COLON_PAINT_STROKE = 0.66f;
78 | private static final float DEFAULT_TIME_PAINT_STROKE = 0.77f;
79 | private static final float DEFAULT_ROUND_RECT_RADIUS = 2.66f;
80 | private static final float DEFAULT_RECT_WIDTH = 18.0f;
81 | private static final float DEFAULT_RECT_HEIGHT = 17.0f;
82 | private static final float DEFAULT_RECT_SPACING = 6.0f;
83 | private static final float DEFAULT_TIME_TEXT_SIZE = 13.0f;
84 | private static final float DEFAULT_COLON_TEXT_SIZE = 13.0f;
85 |
86 | // 66dp
87 | private static final float DEFAULT_VIEW_WIDTH = DEFAULT_RECT_WIDTH * 3 +
88 | DEFAULT_RECT_SPACING * 2;
89 | // 17dp
90 | private static final float DEFAULT_VIEW_HEIGHT = DEFAULT_RECT_HEIGHT;
91 |
92 | /**************
93 | * Default px *
94 | **************/
95 | private float rectWidth;
96 | private float rectHeight;
97 | private float rectSpacing;
98 | private float rectRadius;
99 | private boolean drawRectBorder = false;
100 |
101 | private float paddingLeft;
102 | private float paddingTop;
103 | private float paddingRight;
104 | private float paddingBottom;
105 |
106 | private float firstTranslateX;
107 | private float firstTranslateColonX;
108 | private float secondTranslateX;
109 | private float secondTranslateColonX;
110 |
111 | private int timeHour;
112 | private int timeMinute;
113 | private int timeSecond;
114 |
115 | private int viewWidth;
116 | private int viewHeight;
117 | private float defaultWrapContentWidth;
118 | private float defaultWrapContentHeight;
119 |
120 | private EasyThread easyThread;
121 |
122 | private final Locale locale = Locale.getDefault();
123 | private final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
124 |
125 | private Paint colonPaint;
126 | private Paint rectBorderPaint;
127 |
128 | private Paint timePaint;
129 | // for draw time
130 | private float timePaintBaseLine;
131 | // for draw colon
132 | private float timePaintBaseLineFixed;
133 |
134 | private Paint backgroundPaint;
135 | private RectF backgroundRectF;
136 |
137 | private volatile long lastRecordTime = 0L;
138 | private volatile boolean runningState = false;
139 |
140 | private boolean autoResume = true;
141 | private long pauseTime = 0L;
142 |
143 | private EasyCountDownListener easyCountDownListener;
144 |
145 |
146 | private static class MainHandler extends Handler {
147 |
148 | private static final int WHAT_COUNT_DOWN_COMPLETED = 0x26;
149 |
150 | private final WeakReference listenerReference;
151 |
152 |
153 | MainHandler(@NonNull final EasyCountDownListener easyCountDownListener) {
154 | super(Looper.getMainLooper());
155 | this.listenerReference = new WeakReference<>(easyCountDownListener);
156 | }
157 |
158 |
159 | /**
160 | * Handle system messages here.
161 | */
162 | @Override
163 | public void dispatchMessage(Message msg) {
164 | switch (msg.what) {
165 | case WHAT_COUNT_DOWN_COMPLETED:
166 | final EasyCountDownListener easyCountDownListener
167 | = this.listenerReference.get();
168 | if (easyCountDownListener == null) return;
169 | easyCountDownListener.onCountDownCompleted();
170 | break;
171 | }
172 | }
173 |
174 | }
175 |
176 |
177 | private MainHandler mainHandler;
178 |
179 |
180 | public EasyCountDownTextureView(Context context) {
181 | super(context);
182 | this.init(context, null);
183 | }
184 |
185 |
186 | public EasyCountDownTextureView(Context context, AttributeSet attrs) {
187 | super(context, attrs);
188 | this.init(context, attrs);
189 | }
190 |
191 |
192 | public EasyCountDownTextureView(Context context, AttributeSet attrs, int defStyleAttr) {
193 | super(context, attrs, defStyleAttr);
194 | this.init(context, attrs);
195 | }
196 |
197 |
198 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
199 | public EasyCountDownTextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
200 | super(context, attrs, defStyleAttr, defStyleRes);
201 | this.init(context, attrs);
202 | }
203 |
204 |
205 | private void init(Context context, AttributeSet attrs) {
206 | this.metrics = this.getResources().getDisplayMetrics();
207 | this.defaultWrapContentWidth = this.dp2px(DEFAULT_VIEW_WIDTH);
208 | this.defaultWrapContentHeight = this.dp2px(DEFAULT_VIEW_HEIGHT);
209 |
210 | this.setSurfaceTextureListener(this);
211 | this.setOpaque(false);
212 |
213 | TypedArray typedArray = context.obtainStyledAttributes(attrs,
214 | R.styleable.EasyCountDownTextureView);
215 | this.timeHour = typedArray.getInteger(R.styleable.EasyCountDownTextureView_easyCountHour,
216 | 0);
217 | this.timeMinute = typedArray.getInteger(
218 | R.styleable.EasyCountDownTextureView_easyCountMinute, 0);
219 | this.timeSecond = typedArray.getInteger(
220 | R.styleable.EasyCountDownTextureView_easyCountSecond, 0);
221 |
222 | this.initTimePaint(typedArray);
223 | this.initColonPaint(typedArray);
224 | this.initRectBorderPaint(typedArray);
225 | this.initBackgroundPaint(typedArray);
226 |
227 | this.rectWidth = typedArray.getDimension(
228 | R.styleable.EasyCountDownTextureView_easyCountRectWidth,
229 | this.dp2px(DEFAULT_RECT_WIDTH));
230 | this.rectHeight = typedArray.getDimension(
231 | R.styleable.EasyCountDownTextureView_easyCountRectHeight,
232 | this.dp2px(DEFAULT_RECT_HEIGHT));
233 | this.rectSpacing = typedArray.getDimension(
234 | R.styleable.EasyCountDownTextureView_easyCountRectSpacing,
235 | this.dp2px(DEFAULT_RECT_SPACING));
236 | this.refitBackgroundAttribute();
237 |
238 | final Paint.FontMetricsInt timePaintFontMetrics = this.timePaint.getFontMetricsInt();
239 | this.timePaintBaseLine = (this.backgroundRectF.bottom + this.backgroundRectF.top -
240 | timePaintFontMetrics.bottom - timePaintFontMetrics.top) / 2;
241 | // for colon
242 | this.timePaintBaseLineFixed = this.timePaintBaseLine / 40 * 37;
243 | this.rectRadius = typedArray.getDimension(
244 | R.styleable.EasyCountDownTextureView_easyCountRectRadius,
245 | this.dp2px(DEFAULT_ROUND_RECT_RADIUS));
246 | typedArray.recycle();
247 |
248 | this.updateTime();
249 | }
250 |
251 |
252 | private void initColonPaint(@NonNull final TypedArray typedArray) {
253 | this.colonPaint = new Paint();
254 | this.colonPaint.setAntiAlias(true);
255 | this.colonPaint.setColor(
256 | typedArray.getColor(R.styleable.EasyCountDownTextureView_easyCountColonColor,
257 | DEFAULT_COLOR_COLON));
258 | this.colonPaint.setTextSize(
259 | typedArray.getDimension(R.styleable.EasyCountDownTextureView_easyCountColonSize,
260 | this.dp2px(DEFAULT_TIME_TEXT_SIZE)));
261 | this.colonPaint.setStrokeWidth(
262 | typedArray.getDimension(R.styleable.EasyCountDownTextureView_easyCountColonStroke,
263 | this.dp2px(DEFAULT_COLON_PAINT_STROKE)));
264 | this.colonPaint.setStyle(Paint.Style.FILL_AND_STROKE);
265 | this.colonPaint.setTextAlign(Paint.Align.CENTER);
266 | this.colonPaint.setStrokeCap(Paint.Cap.ROUND);
267 | }
268 |
269 |
270 | private void initTimePaint(@NonNull final TypedArray typedArray) {
271 | this.timePaint = new Paint();
272 | this.timePaint.setAntiAlias(true);
273 | this.timePaint.setColor(
274 | typedArray.getColor(R.styleable.EasyCountDownTextureView_easyCountTimeColor,
275 | DEFAULT_COLOR_TIME));
276 | this.timePaint.setTextSize(
277 | typedArray.getDimension(R.styleable.EasyCountDownTextureView_easyCountTimeSize,
278 | this.dp2px(DEFAULT_COLON_TEXT_SIZE)));
279 | this.timePaint.setStrokeWidth(
280 | typedArray.getDimension(R.styleable.EasyCountDownTextureView_easyCountTimeStroke,
281 | this.dp2px(DEFAULT_TIME_PAINT_STROKE)));
282 | this.timePaint.setStyle(Paint.Style.FILL_AND_STROKE);
283 | this.timePaint.setTextAlign(Paint.Align.CENTER);
284 | this.timePaint.setStrokeCap(Paint.Cap.ROUND);
285 | }
286 |
287 |
288 | private void initRectBorderPaint(@NonNull final TypedArray typedArray) {
289 | final float rectBorderStroke = typedArray.getDimension(
290 | R.styleable.EasyCountDownTextureView_easyCountRectBorderStroke, Float.MIN_VALUE);
291 | this.checkRectBorder(rectBorderStroke);
292 | if (!this.drawRectBorder) return;
293 | this.rectBorderPaint = new Paint();
294 | this.rectBorderPaint.setAntiAlias(true);
295 | this.rectBorderPaint.setColor(
296 | typedArray.getColor(R.styleable.EasyCountDownTextureView_easyCountRectBorderColor,
297 | DEFAULT_COLOR_RECT_BORDER));
298 | this.rectBorderPaint.setStrokeWidth(rectBorderStroke);
299 | this.rectBorderPaint.setStyle(Paint.Style.STROKE);
300 | this.rectBorderPaint.setTextAlign(Paint.Align.CENTER);
301 | this.rectBorderPaint.setStrokeCap(Paint.Cap.SQUARE);
302 | }
303 |
304 |
305 | private void initBackgroundPaint(@NonNull final TypedArray typedArray) {
306 | this.backgroundPaint = new Paint();
307 | this.backgroundPaint.setAntiAlias(true);
308 | this.backgroundPaint.setColor(
309 | typedArray.getColor(R.styleable.EasyCountDownTextureView_easyCountBackgroundColor,
310 | DEFAULT_COLOR_BACKGROUND));
311 | this.backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
312 | this.backgroundPaint.setStrokeWidth(this.dp2px(DEFAULT_BACKGROUND_PAINT_WIDTH));
313 | this.backgroundPaint.setTextAlign(Paint.Align.CENTER);
314 | this.backgroundPaint.setStrokeCap(Paint.Cap.ROUND);
315 | }
316 |
317 |
318 | private void checkRectBorder(final float rectBorder) {
319 | this.drawRectBorder = rectBorder != Float.MIN_VALUE;
320 | }
321 |
322 |
323 | private void updateTime() {
324 | this.millisInFuture = this.timeHour * ONE_HOUR + this.timeMinute * ONE_MINUTE +
325 | this.timeSecond * ONE_SECOND;
326 | this.setTime(this.millisInFuture);
327 | }
328 |
329 |
330 | private void refitBackgroundAttribute() {
331 | this.paddingLeft = this.getPaddingLeft();
332 | this.paddingTop = this.getPaddingTop();
333 | this.paddingRight = this.getPaddingRight();
334 | this.paddingBottom = this.getPaddingBottom();
335 |
336 | this.firstTranslateX = this.rectWidth + this.rectSpacing + paddingLeft;
337 | this.secondTranslateX = this.rectWidth * 2 + this.rectSpacing * 2 + paddingLeft;
338 | this.firstTranslateColonX = this.firstTranslateX - this.rectSpacing / 2;
339 | this.secondTranslateColonX = this.secondTranslateX - this.rectSpacing / 2;
340 |
341 | this.backgroundRectF = new RectF(0, 0, this.rectWidth, this.rectHeight);
342 | }
343 |
344 |
345 | @Override
346 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
347 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
348 |
349 | this.viewWidth = MeasureSpec.getSize(widthMeasureSpec);
350 | this.viewHeight = MeasureSpec.getSize(heightMeasureSpec);
351 |
352 | final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
353 | final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
354 |
355 | float resultWidth;
356 | float resultHeight;
357 |
358 | switch (widthMode) {
359 | // wrap_content
360 | case MeasureSpec.AT_MOST:
361 | case MeasureSpec.UNSPECIFIED:
362 | resultWidth = this.defaultWrapContentWidth;
363 | break;
364 | // match_parent
365 | case MeasureSpec.EXACTLY:
366 | default:
367 | resultWidth = Math.max(this.viewWidth, this.defaultWrapContentWidth);
368 | break;
369 | }
370 | switch (heightMode) {
371 | // wrap_content
372 | case MeasureSpec.AT_MOST:
373 | case MeasureSpec.UNSPECIFIED:
374 | resultHeight = this.defaultWrapContentHeight;
375 | break;
376 | // match_parent
377 | case MeasureSpec.EXACTLY:
378 | default:
379 | resultHeight = Math.max(this.viewHeight, this.defaultWrapContentHeight);
380 | break;
381 | }
382 | resultWidth += (this.paddingLeft + this.paddingRight);
383 | resultHeight += (this.paddingTop + this.paddingBottom);
384 | this.setMeasuredDimension((int) resultWidth, (int) resultHeight);
385 | }
386 |
387 |
388 | @Override
389 | protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
390 | super.onSizeChanged(width, height, oldWidth, oldHeight);
391 | this.viewWidth = width;
392 | this.viewHeight = height;
393 | this.refitBackgroundAttribute();
394 | this.invalidate();
395 | }
396 |
397 |
398 | public void setTimeHour(final int timeHour) {
399 | this.timeHour = timeHour;
400 | this.updateTime();
401 | }
402 |
403 |
404 | public void setTimeMinute(final int timeMinute) {
405 | this.timeMinute = timeMinute;
406 | this.updateTime();
407 | }
408 |
409 |
410 | public void setTimeSecond(final int timeSecond) {
411 | this.timeSecond = timeSecond;
412 | this.updateTime();
413 | }
414 |
415 |
416 | public void setRectWidth(final float rectWidthDp) {
417 | this.rectWidth = this.dp2px(rectWidthDp);
418 | this.refitBackgroundAttribute();
419 | }
420 |
421 |
422 | public void setRectHeight(final float rectHeightDp) {
423 | this.rectHeight = this.dp2px(rectHeightDp);
424 | this.refitBackgroundAttribute();
425 | }
426 |
427 |
428 | public void setRectSpacing(final float rectSpacingDp) {
429 | this.rectSpacing = this.dp2px(rectSpacingDp);
430 | this.refitBackgroundAttribute();
431 | }
432 |
433 |
434 | public void setAutoResume(final boolean autoResume) {
435 | this.autoResume = autoResume;
436 | }
437 |
438 |
439 | public void setEasyCountDownListener(
440 | @NonNull final EasyCountDownListener easyCountDownListener) {
441 | this.easyCountDownListener = easyCountDownListener;
442 | this.mainHandler = new MainHandler(easyCountDownListener);
443 | }
444 |
445 |
446 | public boolean isRunningState() {
447 | return this.runningState;
448 | }
449 |
450 |
451 | public float getRectWidth() {
452 | return this.rectWidth;
453 | }
454 |
455 |
456 | public float getRectHeight() {
457 | return this.rectHeight;
458 | }
459 |
460 |
461 | public float getRectSpacing() {
462 | return this.rectSpacing;
463 | }
464 |
465 |
466 | @Override
467 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
468 | Log.i(TAG, "[onSurfaceTextureAvailable]");
469 | this.startAndRestoreTime();
470 | }
471 |
472 |
473 | @Override
474 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
475 |
476 | }
477 |
478 |
479 | @Override
480 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
481 | Log.i(TAG, "[onSurfaceTextureDestroyed]");
482 | this.stopAndRecordTime();
483 | return true;
484 | }
485 |
486 |
487 | public void stopAndRecordTime() {
488 | if (this.autoResume) {
489 | this.pauseTime = SystemClock.elapsedRealtime();
490 | }
491 | this.stop();
492 | }
493 |
494 |
495 | public void startAndRestoreTime() {
496 | if (this.pauseTime > 0) {
497 | this.millisInFuture -= (SystemClock.elapsedRealtime() - this.pauseTime);
498 | this.pauseTime = 0;
499 | }
500 | this.start();
501 | }
502 |
503 |
504 | @Override
505 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
506 | // Nothing to do
507 | }
508 |
509 |
510 | public void start() {
511 | if (this.runningState) return;
512 | this.drawZeroZeroZero();
513 | if (millisInFuture > 0) {
514 | this.easyThread = new EasyThread();
515 | this.easyThread.startThread();
516 | this.easyThread.start();
517 | this.runningState = true;
518 | if (this.easyCountDownListener != null) {
519 | this.easyCountDownListener.onCountDownStart();
520 | }
521 | } else {
522 | if (this.easyCountDownListener != null) {
523 | this.easyCountDownListener.onCountDownTimeError();
524 | }
525 | this.runningState = false;
526 | }
527 | }
528 |
529 |
530 | public void stop() {
531 | if (!this.runningState) return;
532 | if (this.easyThread != null) {
533 | this.easyThread.interrupt();
534 | this.easyThread = null;
535 | }
536 | if (this.easyCountDownListener != null) {
537 | this.easyCountDownListener.onCountDownStop(this.millisInFuture);
538 | }
539 | this.runningState = false;
540 | }
541 |
542 |
543 | /**
544 | * Start count down by date
545 | *
546 | * @param date date
547 | */
548 | public void setTime(@NonNull final Date date) {
549 | this.millisInFuture = date.getTime();
550 | }
551 |
552 |
553 | /**
554 | * Start count down by timeMillis
555 | *
556 | * @param timeMillis timeMillis
557 | */
558 | public void setTime(final long timeMillis) {
559 | this.millisInFuture = timeMillis;
560 | this.calendar.setTimeInMillis(this.millisInFuture);
561 | }
562 |
563 |
564 | private void drawZeroZeroZero() {
565 | Canvas canvas = null;
566 | try {
567 | canvas = EasyCountDownTextureView.this.lockCanvas();
568 | if (canvas == null) return;
569 | this.drawTimeAndBackground(canvas, String.format(locale, LESS_THAN_TEN_FORMAT, 0),
570 | String.format(locale, LESS_THAN_TEN_FORMAT, 0),
571 | String.format(locale, LESS_THAN_TEN_FORMAT, 0));
572 | unlockCanvasAndPost(canvas);
573 | } catch (Exception e) {
574 | e.printStackTrace();
575 | unlockCanvasAndPost(canvas);
576 | }
577 | }
578 |
579 |
580 | private class EasyThread extends Thread {
581 |
582 | private volatile boolean running = false;
583 | private volatile boolean completed = false;
584 |
585 |
586 | EasyThread() {
587 | this.running = true;
588 | }
589 |
590 |
591 | final void startThread() {
592 | this.completed = false;
593 | this.running = true;
594 | }
595 |
596 |
597 | final void stopThread() {
598 | this.completed = true;
599 | this.running = false;
600 | }
601 |
602 |
603 | private int checkCalendarHour(final long millisInFuture, int calendarHour) {
604 | final int days = (int) (millisInFuture / ONE_DAY);
605 | if (days >= 1) {
606 | calendarHour += days * 24;
607 | }
608 | return calendarHour;
609 | }
610 |
611 |
612 | @Override
613 | public void run() {
614 | while (!this.completed) {
615 | while (this.running) {
616 | Canvas canvas = null;
617 | try {
618 | synchronized (this) {
619 | lastRecordTime = SystemClock.elapsedRealtime();
620 | canvas = EasyCountDownTextureView.this.lockCanvas();
621 | if (canvas == null) continue;
622 | timeHour = calendar.get(Calendar.HOUR_OF_DAY);
623 | timeMinute = calendar.get(Calendar.MINUTE);
624 | timeSecond = calendar.get(Calendar.SECOND);
625 | drawTimeAndBackground(canvas,
626 | String.format(locale, LESS_THAN_TEN_FORMAT,
627 | this.checkCalendarHour(millisInFuture, timeHour)),
628 | String.format(locale, LESS_THAN_TEN_FORMAT, timeMinute),
629 | String.format(locale, LESS_THAN_TEN_FORMAT, timeSecond));
630 |
631 | final long pastTime = SystemClock.elapsedRealtime() - lastRecordTime;
632 | if (pastTime < COUNT_DOWN_INTERVAL) {
633 | this.wait(COUNT_DOWN_INTERVAL - pastTime);
634 | }
635 | // refresh time
636 | millisInFuture -= 1000;
637 | if (millisInFuture < 0) {
638 | this.completed = true;
639 | this.running = false;
640 | // refresh runningState
641 | runningState = false;
642 | if (mainHandler != null) {
643 | mainHandler.sendEmptyMessageDelayed(
644 | MainHandler.WHAT_COUNT_DOWN_COMPLETED,
645 | 1000);
646 | }
647 | calendar.setTimeInMillis(0);
648 | } else {
649 | calendar.setTimeInMillis(millisInFuture);
650 | }
651 | }
652 | } catch (InterruptedException interruptedException) {
653 | final long intervalTime = SystemClock.elapsedRealtime() - lastRecordTime;
654 | Log.i(TAG,
655 | "[run]\t\t\t thread interrupted\t\t\t interval time: " + intervalTime,
656 | interruptedException);
657 | millisInFuture -= intervalTime;
658 | calendar.setTimeInMillis(millisInFuture);
659 | this.stopThread();
660 | } catch (Exception e) {
661 | e.printStackTrace();
662 | } finally {
663 | try {
664 | unlockCanvasAndPost(canvas);
665 | } catch (Exception e) {
666 | e.printStackTrace();
667 | }
668 | }
669 | }
670 | }
671 | }
672 | }
673 |
674 |
675 | private void drawTimeAndBackground(@NonNull final Canvas canvas,
676 | @NonNull final String hour,
677 | @NonNull final String minute,
678 | @NonNull final String second) {
679 | // background
680 | canvas.save();
681 | canvas.translate(paddingLeft, paddingTop);
682 | canvas.drawRoundRect(backgroundRectF, rectRadius, rectRadius, backgroundPaint);
683 | // border
684 | this.drawRectBorder(canvas, backgroundRectF, rectRadius, rectBorderPaint);
685 | canvas.drawText(hour, backgroundRectF.centerX(), timePaintBaseLine, timePaint);
686 | canvas.restore();
687 |
688 | // colon
689 | canvas.save();
690 | canvas.translate(firstTranslateColonX, paddingTop);
691 | canvas.drawText(COLON, 0, timePaintBaseLineFixed, colonPaint);
692 | canvas.restore();
693 |
694 | // background
695 | canvas.save();
696 | canvas.translate(firstTranslateX, paddingTop);
697 | canvas.drawRoundRect(backgroundRectF, rectRadius, rectRadius, backgroundPaint);
698 | // border
699 | this.drawRectBorder(canvas, backgroundRectF, rectRadius, rectBorderPaint);
700 | canvas.drawText(minute, backgroundRectF.centerX(), timePaintBaseLine, timePaint);
701 | canvas.restore();
702 |
703 | // colon
704 | canvas.save();
705 | canvas.translate(secondTranslateColonX, paddingTop);
706 | canvas.drawText(COLON, 0, timePaintBaseLineFixed, colonPaint);
707 | canvas.restore();
708 |
709 | // background
710 | canvas.save();
711 | canvas.translate(secondTranslateX, paddingTop);
712 | canvas.drawRoundRect(backgroundRectF, rectRadius, rectRadius, backgroundPaint);
713 | // border
714 | this.drawRectBorder(canvas, backgroundRectF, rectRadius, rectBorderPaint);
715 | canvas.drawText(second, backgroundRectF.centerX(), timePaintBaseLine, timePaint);
716 | canvas.restore();
717 | }
718 |
719 |
720 | private void drawRectBorder(@NonNull final Canvas canvas,
721 | @NonNull final RectF rect,
722 | final float rectRadius,
723 | @Nullable Paint paint) {
724 | if (paint == null) return;
725 | if (rectRadius > 0) {
726 | paint.setStrokeCap(Paint.Cap.ROUND);
727 | canvas.drawRoundRect(rect, rectRadius, rectRadius, paint);
728 | } else {
729 | paint.setStrokeCap(Paint.Cap.SQUARE);
730 | canvas.drawRect(rect, paint);
731 | }
732 | }
733 |
734 |
735 | /**
736 | * Dp to px
737 | *
738 | * @param dp dp
739 | * @return px
740 | */
741 | private float dp2px(final float dp) {
742 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, this.metrics);
743 | }
744 |
745 |
746 | public interface EasyCountDownListener {
747 |
748 | /**
749 | * When count down start
750 | */
751 | void onCountDownStart();
752 |
753 | /**
754 | * When count down time error
755 | */
756 | void onCountDownTimeError();
757 |
758 | /**
759 | * When count down stop
760 | *
761 | * @param millisInFuture millisInFuture
762 | */
763 | void onCountDownStop(long millisInFuture);
764 |
765 | /**
766 | * When count down completed
767 | */
768 | void onCountDownCompleted();
769 |
770 | }
771 |
772 | }
773 |
--------------------------------------------------------------------------------
/easycountdowntextureview/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
55 |
--------------------------------------------------------------------------------
/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/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 07 23:04:46 CST 2016
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.14.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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/samples/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/samples/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.camnter.easycountdowntextureview.demo"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.2.0'
26 | compile 'com.camnter.easyrecyclerview:easyrecyclerview:1.2'
27 | compile project(':easycountdowntextureview')
28 | // compile 'com.camnter.easycountdowntextureview:easycountdowntextureview:1.4'
29 | }
30 |
--------------------------------------------------------------------------------
/samples/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/CaMnter/Android/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/samples/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/camnter/easycountdowntextureview/demo/CompletedActivity.java:
--------------------------------------------------------------------------------
1 | package com.camnter.easycountdowntextureview.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.Toast;
7 | import com.camnter.easycountdowntextureview.EasyCountDownTextureView;
8 |
9 | /**
10 | * Description:CompletedActivity
11 | * Created by:CaMnter
12 | */
13 |
14 | public class CompletedActivity extends AppCompatActivity
15 | implements EasyCountDownTextureView.EasyCountDownListener {
16 |
17 | private static final long WHITE_DURATION_TIME = 6 * 1000;
18 | private static final long YELLOW_DURATION_TIME = 12 * 1000;
19 | private static final String TAG = CompletedActivity.class.getSimpleName();
20 |
21 |
22 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | this.setContentView(R.layout.activity_completed);
25 | EasyCountDownTextureView whiteCountDownTextureView
26 | = (EasyCountDownTextureView) this.findViewById(R.id.completed_white_countdown_text);
27 | whiteCountDownTextureView.setTime(WHITE_DURATION_TIME);
28 | whiteCountDownTextureView.setEasyCountDownListener(this);
29 | whiteCountDownTextureView.start();
30 |
31 | EasyCountDownTextureView yellowCountDownTextureView
32 | = (EasyCountDownTextureView) this.findViewById(R.id.completed_yellow_countdown_text);
33 | yellowCountDownTextureView.setTime(YELLOW_DURATION_TIME);
34 | yellowCountDownTextureView.setEasyCountDownListener(this);
35 | yellowCountDownTextureView.start();
36 | }
37 |
38 |
39 | /**
40 | * When count down start
41 | */
42 | @Override public void onCountDownStart() {
43 |
44 | }
45 |
46 |
47 | /**
48 | * When count down time error
49 | */
50 | @Override public void onCountDownTimeError() {
51 |
52 | }
53 |
54 |
55 | /**
56 | * When count down stop
57 | *
58 | * @param millisInFuture millisInFuture
59 | */
60 | @Override public void onCountDownStop(long millisInFuture) {
61 |
62 | }
63 |
64 |
65 | /**
66 | * When count down completed
67 | */
68 | @Override public void onCountDownCompleted() {
69 | Toast.makeText(this, "[" + TAG + "] [onCountDownCompleted]", Toast.LENGTH_LONG).show();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/camnter/easycountdowntextureview/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.camnter.easycountdowntextureview.demo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import com.camnter.easycountdowntextureview.demo.adapter.MainAdapter;
8 | import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
9 | import com.camnter.easyrecyclerview.widget.EasyRecyclerView;
10 | import com.camnter.easyrecyclerview.widget.decorator.EasyDividerItemDecoration;
11 | import java.util.ArrayList;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | private EasyRecyclerView mainRecyclerView;
16 | private MainAdapter mainAdapter;
17 | private ArrayList classes;
18 |
19 |
20 | @Override protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | this.initViews();
24 | this.initData();
25 | this.initListeners();
26 | }
27 |
28 |
29 | private void initViews() {
30 | this.mainRecyclerView = (EasyRecyclerView) this.findViewById(R.id.main_rv);
31 | EasyDividerItemDecoration decoration = new EasyDividerItemDecoration(this,
32 | EasyDividerItemDecoration.VERTICAL_LIST);
33 | decoration.bottomDivider = true;
34 | this.mainRecyclerView.addItemDecoration(decoration);
35 | }
36 |
37 |
38 | private void initData() {
39 | this.classes = new ArrayList<>();
40 | this.classes.add(ShowActivity.class);
41 | this.classes.add(SettingActivity.class);
42 | this.classes.add(CompletedActivity.class);
43 |
44 | this.mainAdapter = new MainAdapter();
45 | this.mainAdapter.setList(this.classes);
46 | this.mainRecyclerView.setAdapter(this.mainAdapter);
47 | }
48 |
49 |
50 | private void initListeners() {
51 | this.mainAdapter.setOnItemClickListener(new EasyRecyclerViewHolder.OnItemClickListener() {
52 | @Override public void onItemClick(View view, int i) {
53 | Class c = MainActivity.this.classes.get(i);
54 | MainActivity.this.startActivity(new Intent(MainActivity.this, c));
55 | }
56 | });
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/camnter/easycountdowntextureview/demo/SettingActivity.java:
--------------------------------------------------------------------------------
1 | package com.camnter.easycountdowntextureview.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.util.Log;
7 | import android.view.View;
8 | import com.camnter.easycountdowntextureview.EasyCountDownTextureView;
9 |
10 | /**
11 | * Description:SettingActivity
12 | * Created by:CaMnter
13 | * Time:2016-03-17 17:20
14 | */
15 | public class SettingActivity extends AppCompatActivity
16 | implements View.OnClickListener, EasyCountDownTextureView.EasyCountDownListener {
17 |
18 | private static final String TAG = "StyleActivity";
19 | private EasyCountDownTextureView countdownText;
20 |
21 |
22 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | this.setContentView(R.layout.activity_setting);
25 | this.countdownText = (EasyCountDownTextureView) this.findViewById(
26 | R.id.setting_countdown_text);
27 | this.findViewById(R.id.setting_hour_button).setOnClickListener(this);
28 | this.findViewById(R.id.setting_minute_button).setOnClickListener(this);
29 | this.findViewById(R.id.setting_second_button).setOnClickListener(this);
30 | this.findViewById(R.id.setting_start_button).setOnClickListener(this);
31 | this.findViewById(R.id.setting_stop_button).setOnClickListener(this);
32 | this.countdownText.setEasyCountDownListener(this);
33 | }
34 |
35 |
36 | /**
37 | * Called when a view has been clicked.
38 | *
39 | * @param v The view that was clicked.
40 | */
41 | @Override public void onClick(View v) {
42 | switch (v.getId()) {
43 | case R.id.setting_hour_button:
44 | this.countdownText.setTimeHour(1);
45 | break;
46 | case R.id.setting_minute_button:
47 | this.countdownText.setTimeMinute(1);
48 | break;
49 | case R.id.setting_second_button:
50 | this.countdownText.setTimeSecond(1);
51 | break;
52 | case R.id.setting_start_button:
53 | this.countdownText.start();
54 | break;
55 | case R.id.setting_stop_button:
56 | this.countdownText.stop();
57 | break;
58 | }
59 | }
60 |
61 |
62 | /**
63 | * When count down start
64 | */
65 | @Override public void onCountDownStart() {
66 | Log.i(TAG, "[" + TAG + "] [onCountDownStart]");
67 | }
68 |
69 |
70 | /**
71 | * When count down time error
72 | */
73 | @Override public void onCountDownTimeError() {
74 |
75 | }
76 |
77 |
78 | /**
79 | * When count down stop
80 | *
81 | * @param millisInFuture millisInFuture
82 | */
83 | @Override public void onCountDownStop(long millisInFuture) {
84 | Log.i(TAG, "[" + TAG + "] [onCountDownStop]");
85 | }
86 |
87 |
88 | /**
89 | * When count down completed
90 | */
91 | @Override public void onCountDownCompleted() {
92 |
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/camnter/easycountdowntextureview/demo/ShowActivity.java:
--------------------------------------------------------------------------------
1 | package com.camnter.easycountdowntextureview.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | /**
8 | * Description:ShowActivity
9 | * Created by:CaMnter
10 | * Time:2016-03-18 13:28
11 | */
12 | public class ShowActivity extends AppCompatActivity {
13 |
14 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | this.setContentView(R.layout.activity_show);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/samples/src/main/java/com/camnter/easycountdowntextureview/demo/adapter/MainAdapter.java:
--------------------------------------------------------------------------------
1 | package com.camnter.easycountdowntextureview.demo.adapter;
2 |
3 | import android.widget.TextView;
4 | import com.camnter.easycountdowntextureview.demo.R;
5 | import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
6 | import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
7 |
8 | /**
9 | * Description:MainAdapter
10 | * Created by:CaMnter
11 | * Time:2016-03-18 13:21
12 | */
13 | public class MainAdapter extends EasyRecyclerViewAdapter {
14 |
15 | @Override public int[] getItemLayouts() {
16 | return new int[] { R.layout.item_main };
17 | }
18 |
19 |
20 | @Override public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
21 | Class c = (Class) this.getList().get(position);
22 | if (c == null) return;
23 | TextView textView = viewHolder.findViewById(R.id.main_item_tv);
24 | textView.setText(c.getSimpleName());
25 | }
26 |
27 |
28 | @Override public int getRecycleViewItemType(int position) {
29 | return 0;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/src/main/res/layout/activity_completed.xml:
--------------------------------------------------------------------------------
1 |
18 |
29 |
30 |
48 |
49 |
68 |
69 |
--------------------------------------------------------------------------------
/samples/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
18 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/samples/src/main/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
18 |
28 |
29 |
45 |
46 |
53 |
54 |
63 |
64 |
73 |
74 |
81 |
82 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/samples/src/main/res/layout/activity_show.xml:
--------------------------------------------------------------------------------
1 |
18 |
24 |
25 |
30 |
31 |
37 |
38 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/samples/src/main/res/layout/item_main.xml:
--------------------------------------------------------------------------------
1 |
18 |
22 |
23 |
31 |
32 |
--------------------------------------------------------------------------------
/samples/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/samples/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/samples/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/src/main/res/mipmap-xhdpi/bg_fruit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/samples/src/main/res/mipmap-xhdpi/bg_fruit.png
--------------------------------------------------------------------------------
/samples/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/samples/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
22 | 64dp
23 |
24 |
--------------------------------------------------------------------------------
/samples/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | #3F51B5
21 | #303F9F
22 | #FF4081
23 |
24 |
--------------------------------------------------------------------------------
/samples/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 | 16dp
21 | 16dp
22 |
23 |
--------------------------------------------------------------------------------
/samples/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 | EasyCountDownTextureView
20 | Style
21 |
22 | H = 01
23 | M = 01
24 | S = 01
25 | Start
26 | Stop
27 |
28 |
--------------------------------------------------------------------------------
/samples/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/screenshot/easy_count_down_textureview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/screenshot/easy_count_down_textureview.png
--------------------------------------------------------------------------------
/screenshot/shouji_taobao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/screenshot/shouji_taobao.png
--------------------------------------------------------------------------------
/screenshot/textureview_1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/screenshot/textureview_1.gif
--------------------------------------------------------------------------------
/screenshot/textureview_2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CaMnter/EasyCountDownTextureView/477b5deb89c1c6ddba3dfef3158dcec5f256e656/screenshot/textureview_2.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':samples',
2 | ':easycountdowntextureview'
3 |
--------------------------------------------------------------------------------