From fb26d0eb074cc3f46ba7d6bbb222f50246d0b505 Mon Sep 17 00:00:00 2001 From: Edwin Wu Date: Mon, 19 Jun 2017 17:35:53 +0800 Subject: [PATCH] WelcomeActivity --- app/build.gradle | 8 ++-- app/src/main/AndroidManifest.xml | 4 +- .../androidhttputils/WelcomeActivity.java | 39 +++++++++++++++++++ app/src/main/res/layout/activity_welcome.xml | 24 ++++++++++++ 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/github/why168/androidhttputils/WelcomeActivity.java create mode 100644 app/src/main/res/layout/activity_welcome.xml diff --git a/app/build.gradle b/app/build.gradle index 4223289..74103f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,14 +31,14 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.9.5' - compile 'com.android.support.constraint:constraint-layout:1.0.2' // support compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion" - compile 'com.lovedise:permissiongen:0.0.6' compile project(':http-library') + compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.lovedise:permissiongen:0.0.6' + testCompile 'junit:junit:4.12' + testCompile 'org.mockito:mockito-core:1.9.5' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 98fcfaa..c3a26f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,6 @@ - - + + \ No newline at end of file diff --git a/app/src/main/java/com/github/why168/androidhttputils/WelcomeActivity.java b/app/src/main/java/com/github/why168/androidhttputils/WelcomeActivity.java new file mode 100644 index 0000000..04e4e65 --- /dev/null +++ b/app/src/main/java/com/github/why168/androidhttputils/WelcomeActivity.java @@ -0,0 +1,39 @@ +package com.github.why168.androidhttputils; + +import android.content.Intent; +import android.os.Bundle; +import android.os.SystemClock; +import android.support.v7.app.AppCompatActivity; +import android.widget.Chronometer; + +/** + * WelcomeActivity + * + * @author Edwin.Wu + * @version 2017/6/19 17:17 + * @since JDK1.8 + */ +public class WelcomeActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_welcome); + + + Chronometer mChronometer = (Chronometer) findViewById(R.id.chronometer); + mChronometer.setBase(SystemClock.elapsedRealtime()); + mChronometer.start(); + mChronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { + @Override + public void onChronometerTick(Chronometer chronometer) { + if (SystemClock.elapsedRealtime() - chronometer.getBase() > 3 * 1000) { + chronometer.stop(); + startActivity(new Intent(WelcomeActivity.this, HomeActivity.class)); + finish(); + } + } + }); + } + +} diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml new file mode 100644 index 0000000..2514947 --- /dev/null +++ b/app/src/main/res/layout/activity_welcome.xml @@ -0,0 +1,24 @@ + + + + + + +