├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kakasure │ │ └── splashdemo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── kakasure │ │ └── splashdemo │ │ ├── MyApplication.java │ │ ├── animator │ │ ├── AnimatorFactory.java │ │ ├── DefaultAnimator.java │ │ ├── FirstAnimator.java │ │ ├── SecondAnimator.java │ │ └── ThirdAnimator.java │ │ ├── callback │ │ └── AnimatorCallback.java │ │ ├── manager │ │ ├── ActManager.java │ │ └── AnimatorManager.java │ │ ├── ui │ │ ├── MainActivity.java │ │ └── SplashFragment.java │ │ └── utils │ │ └── AppUtils.java │ └── res │ ├── drawable │ ├── login_bg.xml │ └── register_bg.xml │ ├── layout │ ├── activity_main.xml │ └── fragment.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── yindao_down.png │ └── yindao_on.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── img_guide_page_1.png │ ├── img_guide_page_1_star.png │ ├── img_guide_page_3_icon1.png │ ├── img_guide_page_3_icon2.png │ ├── img_guide_page_3_icon3.png │ ├── img_guide_page_3_icon4.png │ ├── img_guide_page_3_icon5.png │ ├── img_guide_page_3_icon6.png │ ├── img_guide_page_3_icon7.png │ ├── img_guide_page_4_arrow_1.png │ ├── img_guide_page_4_arrow_2.png │ ├── img_guide_page_4_arrow_3.png │ ├── img_guide_page_4_box.png │ ├── img_guide_page_4_cash.png │ ├── img_guide_page_4_order.png │ ├── img_guide_page_bg.png │ ├── splash_brand.png │ └── splash_shake.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | 6 | # files for the dex VM 7 | *.dex 8 | 9 | 10 | # Java class files 11 | *.class 12 | 13 | 14 | # generated files 15 | bin/ 16 | gen/ 17 | 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | 23 | # Windows thumbnail db 24 | Thumbs.db 25 | 26 | 27 | # OSX files 28 | .DS_Store 29 | 30 | # Eclipse project files 31 | .classpath 32 | .project 33 | 34 | 35 | # Android Studio 36 | .idea 37 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 38 | .gradle 39 | build/ 40 | 41 | 42 | # Signing files 43 | .signing/ 44 | 45 | 46 | # User-specific configurations 47 | .idea/libraries/ 48 | .idea/workspace.xml 49 | .idea/tasks.xml 50 | .idea/.name 51 | .idea/compiler.xml 52 | .idea/copyright/profiles_settings.xml 53 | .idea/encodings.xml 54 | .idea/misc.xml 55 | .idea/modules.xml 56 | .idea/scopes/scope_settings.xml 57 | .idea/vcs.xml 58 | *.iml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SplashView 2 | SplashView
3 | 欢迎Star, Fork
4 | [我的博客](http://blog.csdn.net/dashentao1989/article/details/48548049)
5 | ![运行效果图](http://img.blog.csdn.net/20150921094832151) 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.kakasure.splashdemo" 9 | minSdkVersion 11 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 | compile 'com.android.support:appcompat-v7:23.0.1' 25 | } 26 | -------------------------------------------------------------------------------- /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 D:\het_software\sdk\android-sdk_r24.0.2-windows\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/kakasure/splashdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo; 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 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by Administrator on 2015/9/18. 7 | */ 8 | public class MyApplication extends Application{ 9 | @Override 10 | public void onCreate() { 11 | 12 | super.onCreate(); 13 | } 14 | 15 | @Override 16 | public void onTerminate() { 17 | super.onTerminate(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/animator/AnimatorFactory.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.animator; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by Administrator on 2015/9/17. 7 | * 简单工厂类
8 | */ 9 | public class AnimatorFactory { 10 | public static final String TAG = AnimatorFactory.class.getSimpleName(); 11 | 12 | public static DefaultAnimator getInstance(int position) { 13 | switch (position) { 14 | case 0: 15 | return new FirstAnimator(); 16 | case 1: 17 | return new SecondAnimator(); 18 | case 2: 19 | return new ThirdAnimator(); 20 | default: 21 | Log.i(TAG, "you know, it will not be happened!"); 22 | break; 23 | } 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/animator/DefaultAnimator.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.animator; 2 | 3 | import android.view.View; 4 | 5 | import com.kakasure.splashdemo.callback.AnimatorCallback; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Administrator on 2015/9/17. 11 | * 动画公用接口
12 | */ 13 | public interface DefaultAnimator { 14 | void startAnimator(View view, AnimatorCallback animatorCallback); 15 | 16 | void withChangeAnimator(int position, float positionOffset, List view, float positionOffsetPix, boolean flag); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/animator/FirstAnimator.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.animator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.animation.ObjectAnimator; 6 | import android.view.View; 7 | import android.view.animation.AccelerateInterpolator; 8 | import android.widget.ImageView; 9 | 10 | import com.kakasure.splashdemo.R; 11 | import com.kakasure.splashdemo.callback.AnimatorCallback; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Administrator on 2015/9/17. 17 | */ 18 | public class FirstAnimator implements DefaultAnimator { 19 | public View baseView; 20 | private ImageView start1; 21 | private ImageView start2; 22 | private ImageView start3; 23 | 24 | private void initView() { 25 | start1 = (ImageView) baseView.findViewById(R.id.start1); 26 | start2 = (ImageView) baseView.findViewById(R.id.start2); 27 | start3 = (ImageView) baseView.findViewById(R.id.start3); 28 | start1.setVisibility(View.GONE); 29 | start2.setVisibility(View.GONE); 30 | start3.setVisibility(View.GONE); 31 | } 32 | 33 | @Override 34 | public void startAnimator(final View view, final AnimatorCallback animatorCallback) { 35 | if (view != null) { 36 | baseView = view; 37 | initView(); 38 | ImageView imageView = (ImageView) view.findViewById(R.id.first_page_img); 39 | AnimatorSet animatorSet = new AnimatorSet(); 40 | ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f); 41 | ObjectAnimator scalexAnimator = ObjectAnimator.ofFloat(imageView, "scaleX", 0.4f, 1f); 42 | ObjectAnimator scaleyAnimator = ObjectAnimator.ofFloat(imageView, "scaleY", 0.4f, 1f); 43 | animatorSet.play(alphaAnimator).with(scalexAnimator).with(scaleyAnimator); 44 | animatorSet.setDuration(1 * 500); 45 | animatorSet.setInterpolator(new AccelerateInterpolator()); 46 | animatorSet.start(); 47 | animatorSet.addListener(new Animator.AnimatorListener() { 48 | @Override 49 | public void onAnimationStart(Animator animation) { 50 | animatorCallback.AnimatorStart(0); 51 | } 52 | 53 | @Override 54 | public void onAnimationEnd(Animator animation) { 55 | animatorCallback.AnimatorComplete(0); 56 | startAnimatorSet(start1); 57 | } 58 | 59 | @Override 60 | public void onAnimationCancel(Animator animation) { 61 | 62 | } 63 | 64 | @Override 65 | public void onAnimationRepeat(Animator animation) { 66 | 67 | } 68 | }); 69 | } 70 | } 71 | 72 | private void startAnimatorSet(final View view) { 73 | ObjectAnimator startAnimatorX1 = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f, 1.8f, 1f, 0.7f, 1.4f, 1.0f, 0.8f, 1f); 74 | ObjectAnimator startAnimatorY1 = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f, 1.8f, 1f, 0.7f, 1.4f, 1.0f, 0.8f, 1f); 75 | AnimatorSet animatorSet = new AnimatorSet(); 76 | animatorSet.setDuration(200); 77 | animatorSet.setInterpolator(new AccelerateInterpolator()); 78 | animatorSet.play(startAnimatorX1).with(startAnimatorY1); 79 | animatorSet.addListener(new Animator.AnimatorListener() { 80 | @Override 81 | public void onAnimationStart(Animator animation) { 82 | view.setVisibility(View.VISIBLE); 83 | } 84 | 85 | @Override 86 | public void onAnimationEnd(Animator animation) { 87 | switch (view.getId()) { 88 | case R.id.start1: 89 | startAnimatorSet(start2); 90 | break; 91 | case R.id.start2: 92 | startAnimatorSet(start3); 93 | break; 94 | case R.id.start3: 95 | // TODO NOTHING 96 | break; 97 | default: 98 | break; 99 | } 100 | } 101 | 102 | @Override 103 | public void onAnimationCancel(Animator animation) { 104 | 105 | } 106 | 107 | @Override 108 | public void onAnimationRepeat(Animator animation) { 109 | 110 | } 111 | }); 112 | animatorSet.start(); 113 | } 114 | 115 | @Override 116 | public void withChangeAnimator(int position, float positionOffset, List view, float positionOffsetPix, boolean flag) { 117 | if (view != null) { 118 | if (positionOffsetPix == 0) { 119 | view.get(position).setAlpha(1f); 120 | } else { 121 | if (flag) { 122 | view.get(position).setAlpha(1 - positionOffset); 123 | } else { 124 | view.get(position).setAlpha(positionOffset); 125 | } 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/animator/SecondAnimator.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.animator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.animation.ObjectAnimator; 6 | import android.view.View; 7 | import android.view.animation.LinearInterpolator; 8 | import android.widget.ImageView; 9 | 10 | import com.kakasure.splashdemo.R; 11 | import com.kakasure.splashdemo.callback.AnimatorCallback; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Administrator on 2015/9/17. 17 | */ 18 | public class SecondAnimator implements DefaultAnimator { 19 | private View baseView; 20 | private ImageView bg1; 21 | private ImageView bg2; 22 | private ImageView bg3; 23 | private ImageView bg4; 24 | private ImageView bg5; 25 | private ImageView bg6; 26 | private ImageView bg7; 27 | 28 | private void initView() { 29 | bg1 = (ImageView) baseView.findViewById(R.id.second_bg1); 30 | bg2 = (ImageView) baseView.findViewById(R.id.second_bg2); 31 | bg3 = (ImageView) baseView.findViewById(R.id.second_bg3); 32 | bg4 = (ImageView) baseView.findViewById(R.id.second_bg4); 33 | bg5 = (ImageView) baseView.findViewById(R.id.second_bg5); 34 | bg6 = (ImageView) baseView.findViewById(R.id.second_bg6); 35 | bg7 = (ImageView) baseView.findViewById(R.id.second_bg7); 36 | bg1.setVisibility(View.INVISIBLE); 37 | bg2.setVisibility(View.INVISIBLE); 38 | bg3.setVisibility(View.INVISIBLE); 39 | bg4.setVisibility(View.INVISIBLE); 40 | bg5.setVisibility(View.INVISIBLE); 41 | bg6.setVisibility(View.INVISIBLE); 42 | bg7.setVisibility(View.INVISIBLE); 43 | } 44 | 45 | @Override 46 | public void startAnimator(View view, final AnimatorCallback animatorCallback) { 47 | if (view != null) { 48 | baseView = view; 49 | initView(); 50 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 51 | objectAnimator.setDuration(500); 52 | objectAnimator.addListener(new Animator.AnimatorListener() { 53 | @Override 54 | public void onAnimationStart(Animator animation) { 55 | animatorCallback.AnimatorStart(1); 56 | } 57 | 58 | @Override 59 | public void onAnimationEnd(Animator animation) { 60 | animatorCallback.AnimatorComplete(1); 61 | startAnimatorSet(bg1); 62 | } 63 | 64 | @Override 65 | public void onAnimationCancel(Animator animation) { 66 | 67 | } 68 | 69 | @Override 70 | public void onAnimationRepeat(Animator animation) { 71 | 72 | } 73 | }); 74 | objectAnimator.start(); 75 | } 76 | } 77 | 78 | private void startAnimatorSet(final View view) { 79 | ObjectAnimator startAnimatorX1 = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f); 80 | ObjectAnimator startAnimatorY1 = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f); 81 | ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 82 | AnimatorSet animatorSet = new AnimatorSet(); 83 | animatorSet.setDuration(100); 84 | animatorSet.setInterpolator(new LinearInterpolator()); 85 | animatorSet.play(startAnimatorX1).with(alphaAnimator).with(startAnimatorY1); 86 | animatorSet.addListener(new Animator.AnimatorListener() { 87 | @Override 88 | public void onAnimationStart(Animator animation) { 89 | view.setVisibility(View.VISIBLE); 90 | } 91 | 92 | @Override 93 | public void onAnimationEnd(Animator animation) { 94 | switch (view.getId()) { 95 | case R.id.second_bg1: 96 | startAnimatorSet(bg2); 97 | break; 98 | case R.id.second_bg2: 99 | startAnimatorSet(bg3); 100 | break; 101 | case R.id.second_bg3: 102 | startAnimatorSet(bg4); 103 | break; 104 | case R.id.second_bg4: 105 | startAnimatorSet(bg5); 106 | break; 107 | case R.id.second_bg5: 108 | startAnimatorSet(bg6); 109 | break; 110 | case R.id.second_bg6: 111 | startAnimatorSet(bg7); 112 | break; 113 | case R.id.second_bg7: 114 | // TODO NOTHING 115 | break; 116 | default: 117 | break; 118 | } 119 | } 120 | 121 | @Override 122 | public void onAnimationCancel(Animator animation) { 123 | 124 | } 125 | 126 | @Override 127 | public void onAnimationRepeat(Animator animation) { 128 | 129 | } 130 | }); 131 | animatorSet.start(); 132 | } 133 | 134 | @Override 135 | public void withChangeAnimator(int position, float positionOffset, List view, float positionOffsetPix, boolean flag) { 136 | if (view != null) { 137 | if (positionOffsetPix == 0) { 138 | view.get(position).setAlpha(1f); 139 | } else { 140 | if (flag) { 141 | view.get(position).setAlpha(1 - positionOffset); 142 | } else { 143 | view.get(position).setAlpha(positionOffset); 144 | } 145 | } 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/animator/ThirdAnimator.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.animator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.animation.ObjectAnimator; 6 | import android.view.View; 7 | import android.view.animation.AccelerateInterpolator; 8 | import android.widget.ImageView; 9 | 10 | import com.kakasure.splashdemo.R; 11 | import com.kakasure.splashdemo.callback.AnimatorCallback; 12 | import com.kakasure.splashdemo.manager.ActManager; 13 | import com.kakasure.splashdemo.utils.AppUtils; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Created by Administrator on 2015/9/17. 19 | */ 20 | public class ThirdAnimator implements DefaultAnimator { 21 | private View baseView; 22 | private ImageView cash; 23 | private ImageView order; 24 | private ImageView box; 25 | private ImageView arrow1; 26 | private ImageView arrow2; 27 | private ImageView arrow3; 28 | 29 | private void initView() { 30 | cash = (ImageView) baseView.findViewById(R.id.third_cash); 31 | order = (ImageView) baseView.findViewById(R.id.third_order); 32 | box = (ImageView) baseView.findViewById(R.id.third_box); 33 | arrow1 = (ImageView) baseView.findViewById(R.id.third_arrow_1); 34 | arrow2 = (ImageView) baseView.findViewById(R.id.third_arrow_2); 35 | arrow3 = (ImageView) baseView.findViewById(R.id.third_arrow_3); 36 | cash.setVisibility(View.INVISIBLE); 37 | order.setVisibility(View.INVISIBLE); 38 | box.setVisibility(View.INVISIBLE); 39 | arrow1.setVisibility(View.INVISIBLE); 40 | arrow2.setVisibility(View.INVISIBLE); 41 | arrow3.setVisibility(View.INVISIBLE); 42 | } 43 | 44 | @Override 45 | public void startAnimator(View view, final AnimatorCallback animatorCallback) { 46 | if (view != null) { 47 | baseView = view; 48 | initView(); 49 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 50 | objectAnimator.setDuration(500); 51 | objectAnimator.addListener(new Animator.AnimatorListener() { 52 | @Override 53 | public void onAnimationStart(Animator animation) { 54 | animatorCallback.AnimatorStart(2); 55 | } 56 | 57 | @Override 58 | public void onAnimationEnd(Animator animation) { 59 | animatorCallback.AnimatorComplete(2); 60 | startAnimatorSet(box); 61 | } 62 | 63 | @Override 64 | public void onAnimationCancel(Animator animation) { 65 | 66 | } 67 | 68 | @Override 69 | public void onAnimationRepeat(Animator animation) { 70 | 71 | } 72 | }); 73 | objectAnimator.start(); 74 | } 75 | } 76 | 77 | private void startAnimatorSet(final View view) { 78 | AnimatorSet animatorSet = new AnimatorSet(); 79 | animatorSet.setDuration(150); 80 | animatorSet.setInterpolator(new AccelerateInterpolator()); 81 | switch (view.getId()) { 82 | case R.id.third_box: 83 | ObjectAnimator alphaAnimatorBox = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 84 | animatorSet.play(alphaAnimatorBox); 85 | break; 86 | case R.id.third_cash: 87 | ObjectAnimator alphaAnimatorCash = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 88 | animatorSet.play(alphaAnimatorCash); 89 | break; 90 | case R.id.third_order: 91 | ObjectAnimator alphaAnimatorOrder = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); 92 | animatorSet.play(alphaAnimatorOrder); 93 | break; 94 | case R.id.third_arrow_1: 95 | float currentX1 = view.getTranslationX(); 96 | float currentY1 = view.getTranslationY(); 97 | ObjectAnimator arrowX1 = ObjectAnimator.ofFloat(view, "translationX", currentX1 - AppUtils.dip2px(ActManager.getInstance().getCurrentActivity(), 8), currentX1); 98 | ObjectAnimator arrowY1 = ObjectAnimator.ofFloat(view, "translationY", currentY1 - AppUtils.dip2px(ActManager.getInstance().getCurrentActivity(), 8), currentY1); 99 | animatorSet.play(arrowX1).with(arrowY1); 100 | break; 101 | case R.id.third_arrow_2: 102 | float currentX2 = view.getTranslationX(); 103 | ObjectAnimator arrowX2 = ObjectAnimator.ofFloat(view, "translationX", currentX2 + AppUtils.dip2px(ActManager.getInstance().getCurrentActivity(), 8), currentX2); 104 | animatorSet.play(arrowX2); 105 | break; 106 | case R.id.third_arrow_3: 107 | float currentX3 = view.getTranslationX(); 108 | float currentY3 = view.getTranslationY(); 109 | ObjectAnimator arrowX3 = ObjectAnimator.ofFloat(view, "translationX", currentX3 - AppUtils.dip2px(ActManager.getInstance().getCurrentActivity(), 8), currentX3); 110 | ObjectAnimator arrowY3 = ObjectAnimator.ofFloat(view, "translationY", currentY3 + AppUtils.dip2px(ActManager.getInstance().getCurrentActivity(), 8), currentY3); 111 | animatorSet.play(arrowX3).with(arrowY3); 112 | break; 113 | default: 114 | break; 115 | } 116 | animatorSet.addListener(new Animator.AnimatorListener() { 117 | @Override 118 | public void onAnimationStart(Animator animation) { 119 | view.setVisibility(View.VISIBLE); 120 | } 121 | 122 | @Override 123 | public void onAnimationEnd(Animator animation) { 124 | switch (view.getId()) { 125 | case R.id.third_box: 126 | startAnimatorSet(cash); 127 | break; 128 | case R.id.third_cash: 129 | startAnimatorSet(order); 130 | break; 131 | case R.id.third_order: 132 | startAnimatorSet(arrow1); 133 | break; 134 | case R.id.third_arrow_1: 135 | startAnimatorSet(arrow2); 136 | break; 137 | case R.id.third_arrow_2: 138 | startAnimatorSet(arrow3); 139 | break; 140 | case R.id.third_arrow_3: 141 | // TODO NOTHING 142 | break; 143 | default: 144 | break; 145 | } 146 | } 147 | 148 | @Override 149 | public void onAnimationCancel(Animator animation) { 150 | 151 | } 152 | 153 | @Override 154 | public void onAnimationRepeat(Animator animation) { 155 | 156 | } 157 | }); 158 | animatorSet.start(); 159 | } 160 | 161 | @Override 162 | public void withChangeAnimator(int position, float positionOffset, List view, float positionOffsetPix, boolean flag) { 163 | if (view != null) { 164 | if (positionOffsetPix == 0) { 165 | view.get(position).setAlpha(1f); 166 | } else { 167 | if (flag) { 168 | view.get(position).setAlpha(1 - positionOffset); 169 | } else { 170 | view.get(position).setAlpha(positionOffset); 171 | } 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/callback/AnimatorCallback.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.callback; 2 | 3 | /** 4 | * Created by Administrator on 2015/9/17. 5 | */ 6 | public interface AnimatorCallback { 7 | 8 | void AnimatorComplete(int position); 9 | 10 | void AnimatorStart(int position); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/manager/ActManager.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.manager; 2 | 3 | import android.app.Activity; 4 | 5 | import java.util.Stack; 6 | 7 | /** 8 | * Created by Administrator on 2015/9/17. 9 | */ 10 | public class ActManager { 11 | private static Stack mActivityStack; 12 | private static ActManager mActivityManager; 13 | private static Object object = new Object(); 14 | 15 | private ActManager() { 16 | mActivityStack = new Stack(); 17 | } 18 | 19 | public static ActManager getInstance() { 20 | if (mActivityManager == null) { 21 | synchronized (object) { 22 | if (mActivityManager == null) { 23 | mActivityManager = new ActManager(); 24 | } 25 | } 26 | 27 | } 28 | return mActivityManager; 29 | } 30 | 31 | /** 32 | * 销毁最近使用的activity(前提已经添加进入了管理器) 33 | * 34 | * @return true=销毁成功,false=集合为空没有或者activity==null 35 | */ 36 | public boolean finishActivity() { 37 | if (mActivityStack.size() == 0) 38 | return false; 39 | Activity activity = mActivityStack.lastElement(); 40 | if (activity != null) { 41 | mActivityStack.remove(activity); 42 | activity.finish(); 43 | activity = null; 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | /** 50 | * 将某个activity销毁掉 51 | * 52 | * @param activity 53 | */ 54 | public void finishActivity(Activity activity) { 55 | if (activity != null) { 56 | activity.finish(); 57 | mActivityStack.remove(activity); 58 | activity = null; 59 | } 60 | } 61 | 62 | /** 63 | * 获得最近使用的activity实例 64 | * @return 65 | */ 66 | public synchronized Activity getCurrentActivity() { 67 | return mActivityStack.lastElement(); 68 | } 69 | 70 | /** 71 | * 添加一个Activity 72 | * 73 | * @param activity 74 | */ 75 | public void pushActivity(Activity activity) { 76 | if (mActivityStack == null) { 77 | mActivityStack = new Stack(); 78 | } 79 | if (mActivityStack.contains(activity)) { 80 | mActivityStack.remove(activity); 81 | } 82 | mActivityStack.add(activity); 83 | } 84 | 85 | /** 86 | * 销毁所有的activity.System.exit(0)方式退出app 87 | */ 88 | public void finishAll() { 89 | while (true) { 90 | if (!finishActivity()) 91 | break; 92 | } 93 | } 94 | 95 | public int getSize() { 96 | return null == mActivityStack ? 0 : mActivityStack.size(); 97 | } 98 | 99 | public Stack getActivityStack() { 100 | return mActivityStack; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/manager/AnimatorManager.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.manager; 2 | 3 | import android.util.SparseArray; 4 | import android.view.View; 5 | 6 | import com.kakasure.splashdemo.callback.AnimatorCallback; 7 | import com.kakasure.splashdemo.animator.AnimatorFactory; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Administrator on 2015/9/17. 14 | * 动画管理类
15 | * 16 | * @author dashentao 17 | * @date 2015 9-17 18 | * @since V 1.0 19 | */ 20 | public class AnimatorManager implements AnimatorCallback { 21 | // 管理View的集合 22 | private List viewList = new ArrayList(); 23 | private static AnimatorManager mAnimatorManager; 24 | private static Object object = new Object(); 25 | private SparseArray sparseArray = new SparseArray(); 26 | 27 | public static AnimatorManager getInstance() { 28 | if (mAnimatorManager == null) { 29 | synchronized (object) { 30 | if (mAnimatorManager == null) { 31 | mAnimatorManager = new AnimatorManager(); 32 | } 33 | } 34 | } 35 | return mAnimatorManager; 36 | } 37 | 38 | public void add(View view) { 39 | if (viewList != null) { 40 | viewList.add(view); 41 | } 42 | } 43 | 44 | public void addAll(List view) { 45 | if (viewList != null) { 46 | viewList.clear(); 47 | viewList.addAll(view); 48 | } 49 | } 50 | 51 | /** 52 | * ViewPager滑动式渐变动画
53 | * 54 | * @param position 55 | * @param positionOffset 56 | */ 57 | public void withChangeAnimator(int position, float positionOffset, float positionOffsetPix, boolean flag) { 58 | if (sparseArray != null) { 59 | if (sparseArray.get(position) != null && sparseArray.get(position)) { 60 | AnimatorFactory.getInstance(position).withChangeAnimator(position, positionOffset, viewList, positionOffsetPix, flag); 61 | } 62 | } 63 | } 64 | 65 | /** 66 | * 启动相应子页面的动画
67 | * 68 | * @param position 69 | */ 70 | public void startAnimator(int position) { 71 | // 对动画做隐藏处理 72 | if (viewList != null && viewList.size() > 0) { 73 | for (int i = 0; i < viewList.size(); i++) { 74 | if (i == position) { 75 | viewList.get(i).setVisibility(View.VISIBLE); 76 | } else { 77 | viewList.get(i).setVisibility(View.INVISIBLE); 78 | } 79 | } 80 | } 81 | AnimatorFactory.getInstance(position).startAnimator(viewList.get(position), this); 82 | } 83 | 84 | @Override 85 | public void AnimatorComplete(int position) { 86 | if (sparseArray != null) { 87 | sparseArray.put(position, true); 88 | } 89 | } 90 | 91 | @Override 92 | public void AnimatorStart(int position) { 93 | if (sparseArray != null) { 94 | sparseArray.put(position, false); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/ui/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.ui; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.support.v4.app.Fragment; 7 | import android.support.v4.app.FragmentManager; 8 | import android.support.v4.app.FragmentPagerAdapter; 9 | import android.support.v4.view.ViewPager; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.util.Log; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.Button; 15 | import android.widget.FrameLayout; 16 | import android.widget.ImageView; 17 | import android.widget.LinearLayout; 18 | import android.widget.RelativeLayout; 19 | 20 | import com.kakasure.splashdemo.R; 21 | import com.kakasure.splashdemo.manager.ActManager; 22 | import com.kakasure.splashdemo.manager.AnimatorManager; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | /** 28 | * Created by Administrator on 2015/9/16. 29 | * 30 | * @author dashentao 31 | * @date 2015 9-16 32 | * @since V 1.0 33 | */ 34 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 35 | private String TAG = MainActivity.this.getClass().getSimpleName(); 36 | private ViewPager viewPager; 37 | private Button login; 38 | private Button register; 39 | private LinearLayout linearLayout; 40 | private RelativeLayout relativeLayoutFirst; 41 | private RelativeLayout relativeLayoutSecond; 42 | private RelativeLayout relativeLayoutThrid; 43 | private FrameLayout splashbg; 44 | private List imgList = new ArrayList(); 45 | private List fragList = new ArrayList(); 46 | private int currentPosition = -1; 47 | private Handler myHandler = new Handler() { 48 | @Override 49 | public void handleMessage(Message msg) { 50 | super.handleMessage(msg); 51 | 52 | splashbg.setVisibility(View.GONE); 53 | updateIndicatorStatus(0); 54 | } 55 | }; 56 | 57 | @Override 58 | protected void onCreate(Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | setContentView(R.layout.activity_main); 61 | ActManager.getInstance().pushActivity(this); 62 | initView(); 63 | initListener(); 64 | initAdapter(); 65 | init(); 66 | } 67 | 68 | public void initListener() { 69 | login.setOnClickListener(this); 70 | register.setOnClickListener(this); 71 | viewPager.setOnPageChangeListener(new MyPageChangeListener()); 72 | } 73 | 74 | public void initView() { 75 | viewPager = (ViewPager) findViewById(R.id.viewpager); 76 | login = (Button) findViewById(R.id.login); 77 | register = (Button) findViewById(R.id.register); 78 | linearLayout = (LinearLayout) findViewById(R.id.linearlayout); 79 | relativeLayoutFirst = (RelativeLayout) findViewById(R.id.relativelayout_first); 80 | relativeLayoutSecond = (RelativeLayout) findViewById(R.id.relativelayout_second); 81 | relativeLayoutThrid = (RelativeLayout) findViewById(R.id.relativelayout_third); 82 | splashbg = (FrameLayout) findViewById(R.id.splash_bg); 83 | } 84 | 85 | /** 86 | * 初始化适配器
87 | */ 88 | public void initAdapter() { 89 | FragmentManager fragmentManager = getSupportFragmentManager(); 90 | MyAdapter myAdapter = new MyAdapter(fragmentManager); 91 | for (int i = 0; i < 3; i++) { 92 | SplashFragment splashFragment = SplashFragment.newInstance(getResources().getStringArray(R.array.titles)[i]); 93 | fragList.add(splashFragment); 94 | } 95 | myAdapter.list.clear(); 96 | myAdapter.list.addAll(fragList); 97 | viewPager.setAdapter(myAdapter); 98 | } 99 | 100 | public void init() { 101 | for (int i = 0; i < fragList.size(); i++) { 102 | ImageView imageView = new ImageView(this); 103 | LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 104 | linearLayout.addView(imageView, layoutParams); 105 | imgList.add(imageView); 106 | } 107 | List view = new ArrayList(); 108 | view.add(relativeLayoutFirst); 109 | view.add(relativeLayoutSecond); 110 | view.add(relativeLayoutThrid); 111 | AnimatorManager.getInstance().addAll(view); 112 | myHandler.sendEmptyMessageDelayed(1, 2 * 1000); 113 | } 114 | 115 | public void updateIndicatorStatus(int position) { 116 | currentPosition = position; 117 | AnimatorManager.getInstance().startAnimator(position); 118 | switch (position) { 119 | case 0: 120 | imgList.get(0).setBackgroundResource(R.mipmap.yindao_down); 121 | imgList.get(1).setBackgroundResource(R.mipmap.yindao_on); 122 | imgList.get(2).setBackgroundResource(R.mipmap.yindao_on); 123 | break; 124 | case 1: 125 | imgList.get(1).setBackgroundResource(R.mipmap.yindao_down); 126 | imgList.get(0).setBackgroundResource(R.mipmap.yindao_on); 127 | imgList.get(2).setBackgroundResource(R.mipmap.yindao_on); 128 | break; 129 | case 2: 130 | imgList.get(2).setBackgroundResource(R.mipmap.yindao_down); 131 | imgList.get(1).setBackgroundResource(R.mipmap.yindao_on); 132 | imgList.get(0).setBackgroundResource(R.mipmap.yindao_on); 133 | break; 134 | default: 135 | break; 136 | } 137 | } 138 | 139 | @Override 140 | public void onClick(View v) { 141 | switch (v.getId()) { 142 | case R.id.login: 143 | // 登录状态 144 | break; 145 | case R.id.register: 146 | // 用户注册 147 | break; 148 | default: 149 | Log.i(TAG, "It will not happened!"); 150 | break; 151 | } 152 | } 153 | 154 | /** 155 | * 滑动页面监视器 156 | */ 157 | public class MyPageChangeListener implements ViewPager.OnPageChangeListener { 158 | 159 | @Override 160 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 161 | // Log.i(TAG, "positionOffset is =" + positionOffset); 162 | // Log.i(TAG, "positionOffsetPixels is = " + positionOffsetPixels); 163 | Log.i(TAG, "position = " + position); 164 | boolean flag = false; 165 | if (position == currentPosition) { 166 | flag = true; 167 | } else { 168 | flag = false; 169 | } 170 | AnimatorManager.getInstance().withChangeAnimator(currentPosition, positionOffset, positionOffsetPixels, flag); 171 | } 172 | 173 | @Override 174 | public void onPageSelected(int position) { 175 | updateIndicatorStatus(position); 176 | Log.i(TAG, "onPageSelected is called, position = " + position); 177 | } 178 | 179 | @Override 180 | public void onPageScrollStateChanged(int state) { 181 | } 182 | } 183 | 184 | /** 185 | * ViewPager适配器 186 | */ 187 | public class MyAdapter extends FragmentPagerAdapter { 188 | List list = new ArrayList(); 189 | 190 | public MyAdapter(FragmentManager fm) { 191 | super(fm); 192 | } 193 | 194 | @Override 195 | public Fragment getItem(int position) { 196 | return list.get(position); 197 | } 198 | 199 | @Override 200 | public int getCount() { 201 | return list.size(); 202 | } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/ui/SplashFragment.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.text.TextPaint; 6 | import android.text.TextUtils; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.TextView; 11 | 12 | import com.kakasure.splashdemo.R; 13 | 14 | /** 15 | * Created by Administrator on 2015/9/16. 16 | * 17 | * @author dashentao 18 | * @date 2015 9-16 19 | * @since V 1.0 20 | */ 21 | public class SplashFragment extends Fragment { 22 | public static final String TYPE = "type"; 23 | private View view; 24 | private TextView textView1; 25 | private TextView textView2; 26 | private String type; 27 | 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 30 | view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment, null); 31 | type = getArguments().getString(TYPE); 32 | initView(); 33 | initListener(); 34 | initAdapter(); 35 | init(); 36 | return view; 37 | } 38 | 39 | public void init() { 40 | if (!TextUtils.isEmpty(type)) { 41 | updateUI(type); 42 | } 43 | } 44 | 45 | public void initView() { 46 | textView1 = (TextView) view.findViewById(R.id.title1); 47 | textView2 = (TextView) view.findViewById(R.id.title2); 48 | TextPaint tp = textView1.getPaint(); 49 | tp.setFakeBoldText(true); 50 | } 51 | 52 | public void initListener() { 53 | 54 | } 55 | 56 | public void initAdapter() { 57 | 58 | } 59 | 60 | private void updateUI(String result) { 61 | String[] titles = result.split("/"); 62 | textView1.setText(titles[0]); 63 | textView2.setText(titles[1]); 64 | } 65 | 66 | public static SplashFragment newInstance(String type) { 67 | SplashFragment splashFragment = new SplashFragment(); 68 | Bundle bundle = new Bundle(); 69 | bundle.putString(TYPE, type); 70 | splashFragment.setArguments(bundle); 71 | return splashFragment; 72 | } 73 | 74 | @Override 75 | public void onResume() { 76 | super.onResume(); 77 | } 78 | 79 | @Override 80 | public void onDestroy() { 81 | super.onDestroy(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/kakasure/splashdemo/utils/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.kakasure.splashdemo.utils; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by Administrator on 2015/9/17. 7 | */ 8 | public class AppUtils { 9 | /** 10 | * 将px值转换为dip或dp值 11 | * 12 | * @param pxValue 13 | * @param context 14 | * @return 15 | */ 16 | public static int px2dip(Context context, float pxValue) { 17 | final float scale = context.getResources().getDisplayMetrics().density; 18 | return (int) (pxValue / scale + 0.5f); 19 | } 20 | 21 | /** 22 | * 将dip或dp值转换为px值 23 | * 24 | * @param dipValue 25 | * @param context 26 | * @return 27 | */ 28 | public static int dip2px(Context context, float dipValue) { 29 | final float scale = context.getResources().getDisplayMetrics().density; 30 | return (int) (dipValue * scale + 0.5f); 31 | } 32 | 33 | /** 34 | * 将px值转换为sp值 35 | * 36 | * @param pxValue 37 | * @param context 38 | * @return 39 | */ 40 | public static int px2sp(Context context, float pxValue) { 41 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 42 | return (int) (pxValue / fontScale + 0.5f); 43 | } 44 | 45 | /** 46 | * 将sp值转换为px值 47 | * 48 | * @param spValue 49 | * @param context 50 | * @return 51 | */ 52 | public static int sp2px(Context context, float spValue) { 53 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; 54 | return (int) (spValue * fontScale + 0.5f); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/login_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/register_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 14 | 15 | 20 | 21 | 29 | 30 | 39 | 40 | 50 | 51 | 56 | 57 | 58 | 64 | 65 | 72 | 73 | 81 | 82 | 90 | 91 | 100 | 101 | 109 | 110 | 117 | 118 | 124 | 125 | 126 | 132 | 133 | 140 | 141 | 150 | 151 | 159 | 160 | 168 | 169 | 176 | 177 | 185 | 186 | 187 | 192 | 193 | 201 | 202 | 203 | 204 | 205 | 210 | 211 |