Skip to content

Commit

Permalink
冷启动优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wosojadfjgo committed Sep 11, 2019
1 parent 3c7df5d commit 94cb1a6
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


### 项目简介
“优聚”是一款集多个平台的资讯内容、复合型优秀资源和实用功能的APP,打破传统限制,融合多元,发现更多、更优秀、更有趣的东西。后续也会加入更多新的功能。也欢迎各位提出意见
项目是一款组件化综合案例,包含新闻,MONO资讯,开眼视频,知乎日报,美女图片,垃圾分类,一言,古诗词,智能聊天机器人,语音识别功能,干货集中营,豆瓣电影等等模块
项目利用业余时间开发,时间不固定,暂时只实现了这些功能。
“优聚”是一款集多个平台的资讯内容、复合型优秀资源和实用功能以及多种炫酷UI特效的APP,打破传统限制,融合多元,发现更多、更优秀、更有趣的东西。
项目是一款组件化综合案例,包含新闻,MONO资讯,开眼视频,知乎日报,垃圾分类搜索,一言,古诗词,智能聊天机器人,语音识别功能,干货集中营,豆瓣影视等等模块
项目利用业余时间开发,时间不固定,暂时只实现了这些功能。后续也会加入更多新的功能。也欢迎各位提出意见。

### 主要模块
目前包含的主要模块有:base基础模块、network网络请求模块、语音识别模块、Gank模块、资讯模块。除base和network外,每个模块都可单独抽离为APP运行,不影响主工程,具体参照config.gradle配置文件。
Expand All @@ -22,4 +22,4 @@
### 截图
![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/1.png) ![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/2.png)![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/3.png)
![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/4.png) ![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/5.png)![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/6.png)
![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/7.png)
![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/7.png) ![image](https://raw.githubusercontent.com/HeYongRui/YouJu/master/screenshot/8.png)
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tools:replace="android:name">
<activity
android:name=".WelcomeActivity"
android:theme="@style/BaseAppTheme">
android:theme="@style/SplashThemeFullscreen">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/heyongrui/youju/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.heyongrui.base.assist.ConfigConstants;
Expand Down Expand Up @@ -76,17 +76,21 @@ protected void init(Bundle savedInstanceState) {
}

private void loadLocalCover() {//加载本地封面图
Object res = R.drawable.welcomimg;
File cacheDirectory = FileUtil.getCacheDirectory(this, null);
if (cacheDirectory != null && cacheDirectory.exists()) {
File file = new File(cacheDirectory.getPath(), "splash.jpg");
if (file.exists()) {
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.welcomimg);
requestOptions.skipMemoryCache(true);
requestOptions.diskCacheStrategy(DiskCacheStrategy.NONE);
GlideApp.with(this).load(file.getAbsolutePath()).apply(requestOptions).into(ivWelcome);
res = file.getAbsolutePath();
}
}
GlideApp.with(this)
.load(res)
.transition(DrawableTransitionOptions.withCrossFade())
.diskCacheStrategy(DiskCacheStrategy.NONE)
.placeholder(R.drawable.welcomimg)
.error(R.drawable.welcomimg)
.into(ivWelcome);
}

private void startMainActivity() {//开始缩放动画
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/drawable-xhdpi/bg_splash_layer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!--适配不同机型尺寸不同导致冷启动背景拉伸问题-->
<!-- 背景颜色,在上图中该颜色为黑色 -->
<item android:drawable="@color/background" />
<!-- 黑色背景上的其他图片元素,比如 一个居中显示的 logo 图标-->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/ic_launcher" />
</item>
<!-- 右上角的图标元素 -->
<!--<item>-->
<!--<bitmap-->
<!--android:gravity="top|right"-->
<!--android:src="@drawable/top_right" />-->
<!--</item>-->
<!--&lt;!&ndash; 最下面的文字,注意这里有个 bottom 设置 &ndash;&gt;-->
<!--<item android:bottom="@dimen/product_text_bottom">-->
<!--<bitmap-->
<!--android:gravity="bottom"-->
<!--android:src="@drawable/bottom_text" />-->
<!--</item>-->
</layer-list>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/welcomimg" />
tools:src="@drawable/welcomimg" />

<View
android:id="@+id/bg"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<resources>

<style name="SplashThemeFullscreen" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/bg_splash_layer</item>
<item name="android:windowContentOverlay">@null</item>
</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.heyongrui.base.assist.ConfigConstants;
import com.heyongrui.base.base.BaseActivity;
import com.heyongrui.base.widget.firefly.FireflyView;
Expand All @@ -27,6 +29,11 @@ public class PlanetBallActivity extends BaseActivity {
private FireflyView fireflyView;
private Handler mHandler = new Handler();

@Override
protected void initImmersionBar() {
ImmersionBar.with(this).hideBar(BarHide.FLAG_HIDE_STATUS_BAR).init();
}

@Override
protected int getLayoutId() {
return R.layout.activity_planet_ball;
Expand Down
Binary file added screenshot/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 94cb1a6

Please sign in to comment.