开源中国源码解析之Splash页面
来源:互联网 发布:淘宝客服图标素材 编辑:程序博客网 时间:2024/06/17 02:18
涉及的类
AppStart //欢迎页面MainActivity //主页面LogUploadService //上传日志的服务TDevice //手机设备工具类
功能介绍
1.设置视图,并且让视图做Alpha动画
2.监听动画,在动画播放完成之后,开启服务上传日志,并且跳转到MainActivity
3.在onResume方法中让本地缓存版本与现在的版本进行比较,如果现在的版本大于缓存的版本,则清除图片缓存
具体代码分析
1.设置视图,监听动画
// 防止第三方跳转时出现双实例Activity aty=AppManager.getActivity(MainActivity.class); if (aty != null && !aty.isFinishing()) { finish(); }// SystemTool.gc(this); //针对性能好的手机使用,加快应用相应速度final View view = View.inflate(this, R.layout.app_start, null); setContentView(view);// 渐变展示启动屏AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f); aa.setDuration(800); view.startAnimation(aa);aa.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { redirectTo(); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { }});
2.在动画结束后,进行跳转与上传日志 redirectTo()
/*** 跳转到...*/private void redirectTo() { Intent uploadLog = new Intent(this, LogUploadService.class); startService(uploadLog); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish();}
3.在onResume方法中让本地缓存版本与现在的版本进行比较,如果现在的版本大于缓存的版本,则清除图片缓存
@Overrideprotected void onResume() { super.onResume(); int cacheVersion = PreferenceHelper.readInt(this, "first_install","first_install", -1); int currentVersion = TDevice.getVersionCode(); if (cacheVersion < currentVersion) { PreferenceHelper.write(this, "first_install", "first_install",currentVersion); cleanImageCache(); //清除图片缓存 } }
4.清除图片缓存方法 cleanImageCache()
private void cleanImageCache() { final File folder = FileUtils.getSaveFolder("OSChina/imagecache"); File[] files = folder.listFiles(); if (files != null && files.length > 0) { KJAsyncTask.execute(new Runnable() { @Override public void run() { if (folder.isDirectory()) { for (File file : folder.listFiles()) { file.delete(); } } } }); } }
0 0
- 开源中国源码解析之Splash页面
- 开源中国源码学习(二)——Splash界面
- 开源中国源码解析之检测更新
- Splash 页面
- Android开发之启动页面Splash Screen
- Android性能优化之Splash页面设计
- Android 开发之 Splash 页面 3 秒跳转
- 手机安全卫士------Splash页面
- Android Splash 页面
- zaker splash页面实现
- Splash动态页面爬虫
- jeeCmsV7-src 源码解析之六(前台页面初始化)
- http页面解析之httpacp开源软件
- Android启动页面设置Splash
- 闪屏页面(Splash)开发
- 实现Splash页面版本自动更新
- Splash页面的跳转逻辑
- Safe-splash页面(1)
- 丑数(Ugly Number)
- jquery.validate.js 在ie中丢失焦点的时候不触发验证
- Codeforces Round #309 (Div. 2) C 排列组合+费马小
- 真机测试的时候出现 data parameter is nil
- 人月神话读书笔记(10)----提纲挈领
- 开源中国源码解析之Splash页面
- 理解RESTful架构
- C++STL之string详讲
- 百度地图导航功能 希望对大家有用吧
- Robotium
- Linux 使用 ip route , ip rule , iptables 配置策略路由
- 安卓百分比布局---很好的解决屏幕适配问题
- HttpURLConnection处理post请求,返回字符串
- C# 结构体 struct