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

Don’t want to drink milk? Try these “milk substitutes” →

For most people of this generation, the main sour...

WeChat group operation ideas, methods and strategies!

"Groups" bring together similar users a...

After 30 years, the Siberian tiger returns to Changbai Mountain

Recently, wild Siberian tigers have been spotted ...

5 key points to master user operations in community operations

The definition and goals of user operations in co...

Why did ZTE use its patent stick to target Xiaomi?

Breaking news: According to authoritative media r...

How to make AI more "human"? MIT research: This is crucial

Written by: Green Apple Editor: HS Layout: Li Xue...

How to use channels to achieve user growth?

There are many entrepreneurs around me. Most of t...

How Xiaomi Enters Users' Homes from the Details of the Conference

On July 22, Xiaomi held its 2014 annual press con...

How to quickly lock in users and achieve satisfactory promotion results?

Every industry takes two things into consideratio...