High imitation Xiaomi Mall splash animation

High imitation Xiaomi Mall splash animation

Source code introduction

This is a high imitation of the Xiaomi Mall splash interface. The animation effects are exactly the same as those of the Xiaomi Mall. It is only for learning and communication use. Please do not use it for other purposes.
Source code running screenshot

Source code snippet:

  1. package com.example.testsplashview;
  2.   
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.IntentFilter;
  7. import android.os.Bundle;
  8. import android.os.Handler;
  9. import android.support.v4.app.Fragment;
  10. import android.support.v4.app.FragmentActivity;
  11. import android.support.v4.app.FragmentManager;
  12. import android.support.v4.app.FragmentTransaction;
  13. import android.support.v4.content.LocalBroadcastManager;
  14. import android.widget.Toast;
  15.   
  16. public   class WelcomeActivity extends FragmentActivity
  17. {
  18. private   static   final   long EXIT_DURATION_BETWEEN_BACKKEY_PRESSED = 1000L;
  19. private   int mBackKeyPressedCount;
  20. private Fragment[] mFragments;
  21. private BroadcastReceiver mPageShowReceiver = new BroadcastReceiver() {
  22.       
  23. @Override  
  24. public   void onReceive(Context context, Intent paramIntent) {
  25. String str = paramIntent.getAction();
  26. if ( "page0_animation_done" .equals(str)){
  27. Intent intent = new Intent();
  28. intent.setClass(getApplicationContext(), MainActivity. class );
  29. startActivity(intent);
  30. finish();
  31. }
  32. if ( "page1_animation_done" .equals(str))
  33. getSupportFragmentManager().beginTransaction().remove(page1).commitAllowingStateLoss();
  34. if ( "page2_animation_done" .equals(str))
  35. getSupportFragmentManager().beginTransaction().remove(page2).commitAllowingStateLoss();
  36. if ( "page3_animation_done" .equals(str))
  37. getSupportFragmentManager().beginTransaction().remove(page3).commitAllowingStateLoss();
  38. if ( "page4_animation_done" .equals(str))
  39. getSupportFragmentManager().beginTransaction().remove(page4).commitAllowingStateLoss();
  40. }
  41. };
  42. private BaseInShowPage page0;
  43. private BaseInShowPage page1;
  44. private BaseInShowPage page2;
  45. private BaseInShowPage page3;
  46. private BaseInShowPage page4;
  47. @Override  
  48. public   void onBackPressed()
  49. {
  50. mBackKeyPressedCount = ( 1 + mBackKeyPressedCount);
  51. if (mBackKeyPressedCount == 2 ){
  52. finish();
  53. } else {
  54. new Handler().postDelayed( new Runnable() {
  55.           
  56. @Override  
  57. public   void run() {
  58. mBackKeyPressedCount = 0 ;
  59. }
  60. }, EXIT_DURATION_BETWEEN_BACKKEY_PRESSED);
  61. }
  62. }
  63. @Override  
  64. protected   void onCreate(Bundle paramBundle)
  65. {
  66. super .onCreate(paramBundle);
  67. setContentView(R.layout.welcome_fragment);
  68. IntentFilter localIntentFilter = new IntentFilter();
  69. localIntentFilter.addAction( "page0_animation_done" );
  70. localIntentFilter.addAction( "page1_animation_done" );
  71. localIntentFilter.addAction( "page2_animation_done" );
  72. localIntentFilter.addAction( "page3_animation_done" );
  73. localIntentFilter.addAction( "page4_animation_done" );
  74. LocalBroadcastManager.getInstance( this ).registerReceiver(mPageShowReceiver, localIntentFilter);
  75. if (paramBundle != null )
  76. return ;
  77. page4 = new Page4();
  78. page3 = new Page3();
  79. page2 = new Page2();
  80. page1 = new Page1();
  81. page0 = new Page0();
  82. Fragment[] arrayOfFragment = new Fragment[ 5 ];
  83. arrayOfFragment[ 0 ] = page0;
  84. arrayOfFragment[ 1 ] = page4;
  85. arrayOfFragment[ 2 ] = page3;
  86. arrayOfFragment[ 3 ] = page2;
  87. arrayOfFragment[ 4 ] = page1;
  88. mFragments = arrayOfFragment;
  89. for ( int i = 0 ; i < mFragments.length; i++)
  90. getSupportFragmentManager().beginTransaction().add(R.id.fragmentview, mFragments[i]).addToBackStack( null ).commit();
  91. }
  92. @Override  
  93. protected   void onDestroy()
  94. {
  95. super .onDestroy();
  96. LocalBroadcastManager.getInstance( this ).unregisterReceiver(mPageShowReceiver);
  97. }
  98. }

Source code link: http://download..com/data/1975262

<<:  GuessGame——Guessing Game

>>:  Everything about Bitcoin in 2014 is in this report

Recommend

Google, BlackBerry team up to make Android devices more secure

BlackBerry has announced a partnership with Googl...

"The Royal Anglican Knights" HD Japanese plug-in Chinese subtitles

Chinese name: Royal Anglican Knights Original tit...

Product Operation: How to build a product structure pyramid?

If you do marketing for a long time, you will hav...

Four myths about Apple design

Every technology company has its own image. When p...

Li Jiaoshou's Marketing Class: A Model to Unravel How Marketing Experts Win

Before we officially start, I would like to ask y...

Come and see! An autobiography from a stomach cell…

Author: Lu Ting Shanghai Jiao Tong University Sch...

Which is more expensive, fur or mink? The difference between the two

Fur and mink are two types of fur fabrics that we...

How to become a "low-altitude hero"? You can't just fly if you want to!

Let’s talk about the “traffic rules” of the low-a...