├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── nodeprogress
│ │ └── snapupview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── nodeprogress
│ │ │ └── snapupview
│ │ │ ├── MainActivity.java
│ │ │ ├── SnapUp
│ │ │ ├── MyViewHolder.java
│ │ │ ├── imageViewHolder.java
│ │ │ └── recycleAdapter.java
│ │ │ └── View
│ │ │ └── HorizontalRecycleViewLoadMore.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── home_snap_up.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── attr.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── nodeprogress
│ └── snapupview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── S60702-170557.jpg
└── S60702-172429.jpg
├── settings.gradle
└── snapupdowntimerview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── aesion
│ └── snapupdowntimerview
│ └── SnapUpCountDownTimerView.java
└── res
├── drawable
├── bg_snap_up.xml
└── bg_snap_up_red.xml
├── layout
└── view_countdowntimer.xml
├── mipmap-hdpi
└── ic_launcher.png
├── mipmap-mdpi
└── ic_launcher.png
├── mipmap-xhdpi
└── ic_launcher.png
├── mipmap-xxhdpi
└── ic_launcher.png
├── mipmap-xxxhdpi
└── ic_launcher.png
├── values-w820dp
└── dimens.xml
└── values
├── attr.xml
├── colors.xml
├── dimens.xml
├── strings.xml
└── styles.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | snapUpView
--------------------------------------------------------------------------------
/.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/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
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 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## 关于 ##
3 |
4 | # 作者 #
5 | ---
6 |
7 | 戴定康
8 |
9 | >博客:[个人博客](http://daidingkang.cc/ "个人博客")
10 |
11 | >Csdn:[戴定康的博客](http://blog.csdn.net/ddk837239693)
12 |
13 | ---
14 |
15 |
16 | # SnapUpCountDownTimerView
17 | 抢购倒计时,样式可调,大小可调,Gradle引用更方便。countDown
18 |
19 | ## Gradle引用 ##
20 |
21 | compile 'com.daidingkang:snapupcountdowntimerview:1.0.0'
22 |
23 | ## 在你的Xml中 ##
24 |
25 |
31 |
32 |
33 |
34 | ## 用法 ##
35 |
36 | ```java
37 | SnapUpCountDownTimerView rushBuyCountDownTimerView = (SnapUpCountDownTimerView) findViewById(R.id.RushBuyCountDownTimerView);
38 | rushBuyCountDownTimerView.setTime(1,55,3);//设置小时,分钟,秒。注意不能大于正常值,否则会抛出异常
39 | rushBuyCountDownTimerView.start();//开始倒计时
40 | ```
41 |
42 | rushBuyCountDownTimerView.stop();//停止倒计时
43 |
44 |
45 | So easy 是不是很简单,赶紧试试吧
46 | 喜欢的童鞋欢迎Star and Fork
47 |
48 |
49 |
50 | 
51 |
52 | 
53 |
54 |
55 | 当然,我们安卓自带了一个CountDownTimer类,大家可以看一看
56 |
57 |
58 | ```java
59 | private TextView vertifyView;
60 | private CountDownTimer timer = new CountDownTimer(10000, 1000) {
61 |
62 | @Override
63 | public void onTick(long millisUntilFinished) {
64 | vertifyView.setText((millisUntilFinished / 1000) + "秒后可重发");
65 | }
66 |
67 | @Override
68 | public void onFinish() {
69 | vertifyView.setEnabled(true);
70 | vertifyView.setText("获取验证码");
71 | }
72 | };
73 | ```
74 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.nodeprogress.snapupview"
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(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.2.1'
26 | compile 'com.android.support:recyclerview-v7:23.2.1'
27 | compile project(':snapupdowntimerview')
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 E:\android-sdk-windows/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/nodeprogress/snapupview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview;
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 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nodeprogress/snapupview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.aesion.snapupdowntimerview.SnapUpCountDownTimerView;
7 | import com.nodeprogress.snapupview.SnapUp.recycleAdapter;
8 | import com.nodeprogress.snapupview.View.HorizontalRecycleViewLoadMore;
9 |
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 |
18 | HorizontalRecycleViewLoadMore recyclerView = (HorizontalRecycleViewLoadMore) findViewById(R.id.recycle);
19 | recyclerView.setAdapter(new recycleAdapter(MainActivity.this));
20 |
21 | SnapUpCountDownTimerView rushBuyCountDownTimerView = (SnapUpCountDownTimerView) findViewById(R.id.RushBuyCountDownTimerView);
22 | rushBuyCountDownTimerView.setTime(1,55,3);
23 | rushBuyCountDownTimerView.start();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nodeprogress/snapupview/SnapUp/MyViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview.SnapUp;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | /**
8 | * User: Daidingkang(ddk19941017@Gmail.com)
9 | * Date: 2016-07-01
10 | * Time: 15:51
11 | * FIXME
12 | */
13 | public class MyViewHolder extends RecyclerView.ViewHolder {
14 |
15 | public TextView textView;
16 |
17 | public MyViewHolder(View itemView) {
18 | super(itemView);
19 | textView = (TextView) itemView;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nodeprogress/snapupview/SnapUp/imageViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview.SnapUp;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 |
7 | /**
8 | * User: Daidingkang(ddk19941017@Gmail.com)
9 | * Date: 2016-07-01
10 | * Time: 15:51
11 | * FIXME
12 | */
13 | public class imageViewHolder extends RecyclerView.ViewHolder {
14 |
15 | public ImageView imageView;
16 |
17 | public imageViewHolder(View itemView) {
18 | super(itemView);
19 | imageView = (ImageView) itemView;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nodeprogress/snapupview/SnapUp/recycleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview.SnapUp;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | public class recycleAdapter extends RecyclerView.Adapter {
11 |
12 | Context context;
13 |
14 | public recycleAdapter(Context context) {
15 | this.context = context;
16 | }
17 |
18 |
19 | @Override
20 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
21 |
22 | if (viewType == 0){
23 | return new imageViewHolder(new ImageView(context));
24 | }else {
25 | return new MyViewHolder(new TextView(context));
26 | }
27 | }
28 |
29 | @Override
30 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
31 | if (getItemViewType(position) == 0) {
32 | imageViewHolder viewHolder = (imageViewHolder) holder;
33 | viewHolder.imageView.setPadding(50,20,20,20);
34 | viewHolder.imageView.setBackgroundColor(Color.BLUE);
35 | } else {
36 | MyViewHolder viewHolder = (MyViewHolder) holder;
37 | viewHolder.textView.setText(" 淘宝 " + position);
38 | }
39 | }
40 |
41 | @Override
42 | public int getItemCount() {
43 | return 21;
44 | }
45 |
46 | @Override
47 | public int getItemViewType(int position) {
48 | return (position == 20) ? 0 : 1;
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/nodeprogress/snapupview/View/HorizontalRecycleViewLoadMore.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview.View;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.widget.GridLayoutManager;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.widget.Toast;
11 |
12 | /**
13 | * User: Daidingkang(ddk19941017@Gmail.com)
14 | * Date: 2016-07-02
15 | * Time: 10:42
16 | * FIXME
17 | * 横向滑动加载更多的RecycleView
18 | */
19 | public class HorizontalRecycleViewLoadMore extends RecyclerView {
20 | GridLayoutManager manager;
21 | boolean lastPosition;
22 | Context context;
23 |
24 | public HorizontalRecycleViewLoadMore(Context context) {
25 | super(context);
26 | init(context);
27 | }
28 |
29 |
30 | public HorizontalRecycleViewLoadMore(Context context, @Nullable AttributeSet attrs) {
31 | super(context, attrs);
32 | init(context);
33 | }
34 |
35 | float xMove = 0;
36 | float x = 0;
37 |
38 | @Override
39 | public boolean onTouchEvent(MotionEvent e) {
40 |
41 | switch (e.getAction()) {
42 | case MotionEvent.ACTION_DOWN:
43 | if (lastPosition) {
44 | x = e.getX();
45 | }
46 | break;
47 | case MotionEvent.ACTION_MOVE:
48 | xMove = e.getX();
49 | break;
50 | case MotionEvent.ACTION_UP:
51 | if (lastPosition) {
52 | float xDistance = x - xMove;
53 | if ((xDistance) > 200) {//可以判断滑动距离,而且通过正负判断为左滑还是右滑
54 | Toast.makeText(context, "触发横向加载更多", Toast.LENGTH_SHORT).show();
55 | }
56 | }
57 | break;
58 | }
59 |
60 | return super.onTouchEvent(e);
61 | }
62 |
63 | private void init(final Context context) {
64 | this.context = context;
65 | manager = new GridLayoutManager(context, 1, LinearLayoutManager.HORIZONTAL, false);
66 | setLayoutManager(manager);
67 |
68 | addOnScrollListener(new OnScrollListener() {
69 | @Override
70 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
71 | super.onScrollStateChanged(recyclerView, newState);
72 | if (newState == RecyclerView.SCROLL_STATE_IDLE) {//当前的recycleView不滑动(滑动已经停止时)
73 | int lastVisiblePosition = manager.findLastVisibleItemPosition();//最后一个可见的位置
74 | if (lastVisiblePosition >= manager.getItemCount() - 1) {//如果是最后一个位置就是滑到底部了
75 | lastPosition = true;
76 | } else {
77 | if (lastPosition) {
78 | lastPosition = false;
79 | }
80 | }
81 | }
82 | }
83 | });
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/home_snap_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
25 |
26 |
33 |
34 |
35 |
36 |
43 |
44 |
45 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
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 | snapUpView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
23 |
24 |
27 |
28 |
29 |
37 |
38 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/test/java/com/nodeprogress/snapupview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.nodeprogress.snapupview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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.1.2'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/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/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 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.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/gradlew
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/images/S60702-170557.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/images/S60702-170557.jpg
--------------------------------------------------------------------------------
/images/S60702-172429.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/images/S60702-172429.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':snapupdowntimerview'
2 |
--------------------------------------------------------------------------------
/snapupdowntimerview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/snapupdowntimerview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.3"
7 |
8 | defaultConfig {
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 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | testCompile 'junit:junit:4.12'
27 | compile 'com.android.support:appcompat-v7:23.2.1'
28 | }
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/snapupdowntimerview/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 E:\android-sdk-windows/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 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/java/com/aesion/snapupdowntimerview/SnapUpCountDownTimerView.java:
--------------------------------------------------------------------------------
1 |
2 | package com.aesion.snapupdowntimerview;
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.os.Handler;
8 | import android.os.Message;
9 | import android.util.AttributeSet;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import java.util.Timer;
17 | import java.util.TimerTask;
18 |
19 | @SuppressLint("HandlerLeak")
20 | public class SnapUpCountDownTimerView extends LinearLayout {
21 |
22 | private TextView tv_hour_decade;
23 | private TextView tv_hour_unit;
24 | private TextView tv_min_decade;
25 | private TextView tv_min_unit;
26 | private TextView tv_sec_decade;
27 | private TextView tv_sec_unit;
28 |
29 | private Context context;
30 |
31 | private int hour_decade;
32 | private int hour_unit;
33 | private int min_decade;
34 | private int min_unit;
35 | private int sec_decade;
36 | private int sec_unit;
37 |
38 | private Timer timer;
39 |
40 | private Handler handler = new Handler() {
41 |
42 | public void handleMessage(Message msg) {
43 | countDown();
44 | }
45 | };
46 |
47 | public SnapUpCountDownTimerView(Context context, AttributeSet attrs) {
48 | super(context, attrs);
49 |
50 | this.context = context;
51 | LayoutInflater inflater = (LayoutInflater) context
52 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
53 | View view = inflater.inflate(R.layout.view_countdowntimer, this);
54 |
55 | tv_hour_decade = (TextView) view.findViewById(R.id.tv_hour_decade);
56 | tv_hour_unit = (TextView) view.findViewById(R.id.tv_hour_unit);
57 | tv_min_decade = (TextView) view.findViewById(R.id.tv_min_decade);
58 | tv_min_unit = (TextView) view.findViewById(R.id.tv_min_unit);
59 | tv_sec_decade = (TextView) view.findViewById(R.id.tv_sec_decade);
60 | tv_sec_unit = (TextView) view.findViewById(R.id.tv_sec_unit);
61 |
62 | TypedArray array = context.obtainStyledAttributes(attrs,R.styleable.SnapUpCountDownTimerView);
63 | int size = array.getInteger(R.styleable.SnapUpCountDownTimerView_viewSize, 12);
64 |
65 |
66 | tv_hour_decade.setTextSize(size);
67 | tv_hour_unit.setTextSize(size);
68 | tv_min_decade.setTextSize(size);
69 | tv_min_unit.setTextSize(size);
70 | tv_sec_decade.setTextSize(size);
71 | tv_sec_unit.setTextSize(size);
72 | ((TextView)view.findViewById(R.id.colon_minute)).setTextSize(size);
73 | ((TextView)view.findViewById(R.id.colon_hour)).setTextSize(size);
74 | }
75 |
76 |
77 | public void start() {
78 | if (timer == null) {
79 | timer = new Timer();
80 | timer.schedule(new TimerTask() {
81 | @Override
82 | public void run() {
83 | handler.sendEmptyMessage(0);
84 | }
85 | }, 0, 1000);
86 | }
87 | }
88 |
89 |
90 | public void stop() {
91 | if (timer != null) {
92 | timer.cancel();
93 | timer = null;
94 | }
95 | }
96 |
97 |
98 | public void setTime(int hour, int min, int sec) {
99 |
100 | if (hour >= 60 || min >= 60 || sec >= 60 || hour < 0 || min < 0
101 | || sec < 0) {
102 | throw new RuntimeException("时间格式错误,请检查你的代码");
103 | }
104 |
105 | hour_decade = hour / 10;
106 | hour_unit = hour - hour_decade * 10;
107 |
108 | min_decade = min / 10;
109 | min_unit = min - min_decade * 10;
110 |
111 | sec_decade = sec / 10;
112 | sec_unit = sec - sec_decade * 10;
113 |
114 | tv_hour_decade.setText(hour_decade + "");
115 | tv_hour_unit.setText(hour_unit + "");
116 | tv_min_decade.setText(min_decade + "");
117 | tv_min_unit.setText(min_unit + "");
118 | tv_sec_decade.setText(sec_decade + "");
119 | tv_sec_unit.setText(sec_unit + "");
120 | }
121 |
122 |
123 | private void countDown() {
124 | if (isCarry4Unit(tv_sec_unit)) {
125 | if (isCarry4Decade(tv_sec_decade)) {
126 | if (isCarry4Unit(tv_min_unit)) {
127 | if (isCarry4Decade(tv_min_decade)) {
128 | if (isCarry4Unit(tv_hour_unit)) {
129 | if (isCarry4Decade(tv_hour_decade)) {
130 | Toast.makeText(context, "计数完成",
131 | Toast.LENGTH_SHORT).show();
132 | stop();
133 | setTime(0, 0, 0);//重置为0
134 | }
135 | }
136 | }
137 | }
138 | }
139 | }
140 | }
141 |
142 |
143 | private boolean isCarry4Decade(TextView tv) {
144 |
145 | int time = Integer.valueOf(tv.getText().toString());
146 | time = time - 1;
147 | if (time < 0) {
148 | time = 5;
149 | tv.setText(time + "");
150 | return true;
151 | } else {
152 | tv.setText(time + "");
153 | return false;
154 | }
155 | }
156 |
157 |
158 | private boolean isCarry4Unit(TextView tv) {
159 |
160 | int time = Integer.valueOf(tv.getText().toString());
161 | time = time - 1;
162 | if (time < 0) {
163 | time = 9;
164 | tv.setText(time + "");
165 | return true;
166 | } else {
167 | tv.setText(time + "");
168 | return false;
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/drawable/bg_snap_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/drawable/bg_snap_up_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/layout/view_countdowntimer.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
19 |
20 |
24 |
25 |
26 |
27 |
33 |
34 |
40 |
41 |
44 |
45 |
49 |
50 |
51 |
52 |
58 |
59 |
60 |
66 |
67 |
70 |
71 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/snapupdowntimerview/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/snapupdowntimerview/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/snapupdowntimerview/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/snapupdowntimerview/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aesion/SnapUpCountDownTimerView/c7b87c401cd4f819537f9a4554887fda34aa2839/snapupdowntimerview/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | snapUpDownTimerView
3 |
4 |
--------------------------------------------------------------------------------
/snapupdowntimerview/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
23 |
24 |
27 |
28 |
29 |
37 |
38 |
42 |
43 |
44 |
--------------------------------------------------------------------------------