高仿小米商城splash动画
创始人
2025-01-09 12:40:53
0

源码简介

高仿小米商城splash界面,动画效果和小米商城完全一样,仅限于学习交流使用,请勿做其他用途。
源码运行截图

源码片段:

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

源码链接:http://down.51cto.com/data/1975262

相关内容

热门资讯

PHP新手之PHP入门 PHP是一种易于学习和使用的服务器端脚本语言。只需要很少的编程知识你就能使用PHP建立一个真正交互的...
网络中立的未来 网络中立性是什... 《牛津词典》中对“网络中立”的解释是“电信运营商应秉持的一种原则,即不考虑来源地提供所有内容和应用的...
各种千兆交换机的数据接口类型详... 千兆交换机有很多值得学习的地方,这里我们主要介绍各种千兆交换机的数据接口类型,作为局域网的主要连接设...
粉嫩如何诠释霸道 东芝M805... “霸道粉”是个什么玩意东芝M805拿过来的时候,笔者扑哧笑了,不是笑这款笔记本,而是笑这款产品的颜色...
什么是大数据安全 什么是大数据... 在《为什么需要大数据安全分析》一文中,我们已经阐述了一个重要观点,即:安全要素信息呈现出大数据的特征...
全面诠释网络负载均衡 负载均衡的出现大大缓解了服务器的压力,更是有效的利用了资源,提高了效率。那么我们现在来说一下网络负载...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
30分钟搞定iOS自定义相机 最近公司的项目中用到了相机,由于不用系统的相机,UI给的相机切图,必须自定义才可以。就花时间简单研究...
P2P的自白|我不生产内容,我... 现在一提起P2P,人们就会联想到正在被有关部门“围剿”的互联网理财服务。×租宝事件使得劳...