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

Why don't you laugh when you tickle yourself?

© Daily Mail Leviathan Press: In fact, as early a...

Be careful! A "cold" may be fulminant myocarditis

This is the 5008th article of Da Yi Xiao Hu Tiant...

How to fully plan a screen-sweeping event?

In this era of mobile Internet where the focus of...

Why do we need to use project thinking to attract new users?

What should you do when the KPI indicator is &quo...

Chen Qingzhu's Physiognomy Episode 15

Chen Qingzhu's Physiognomy 15 episodes resour...

Why are there always long lines in the women's restroom? What can we do?

I went to the bathroom with my boyfriend at the s...

How does user operation build user tags?

Building user tags is actually a very simple task...