Skip to content

Commit 8a47864

Browse files
committed
解决华为荣耀6兼容问题
1 parent 3106848 commit 8a47864

9 files changed

+114
-12
lines changed

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ android {
7373
yinyongbao {} // 应用宝
7474
// m360 {} // 360手机助手
7575
// pp {} // PP助手
76+
meizu {} // 魅族
7677
xiaomi {} // 小米商店
7778
huawei {} // 华为商店
7879
official {} // 官方版本

app/src/main/java/com/rae/cnblogs/AppRoute.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static void jumpToBlogContent(Context context, BlogBean blog, BlogType ty
8484
Intent intent = new Intent(context, BlogContentActivity.class);
8585
// 不传递摘要和正文这些过大的数据。进去博文正文之后再从数据库拉取。
8686
intent.putExtra("blog", blog);
87-
intent.putExtra("blogId", blog.getId());
87+
intent.putExtra("blogId", blog.getBlogId());
8888
intent.putExtra("type", type.getTypeName());
8989
startActivity(context, intent);
9090
}

app/src/main/java/com/rae/cnblogs/ThemeCompat.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import com.rae.cnblogs.message.ThemeChangedEvent;
1515
import com.rae.cnblogs.widget.RaeSkinImageView;
16+
import com.rae.cnblogs.widget.RaeSkinImageViewV4;
1617

1718
import org.greenrobot.eventbus.EventBus;
1819

@@ -34,7 +35,12 @@ public static class CnblogsThemeHookInflater implements SkinLayoutInflater {
3435
@Override
3536
public View createView(@NonNull Context context, String name, @NonNull AttributeSet attributeSet) {
3637
if (TextUtils.equals("ImageView", name)) {
37-
return new RaeSkinImageView(context, attributeSet);
38+
try {
39+
return new RaeSkinImageView(context, attributeSet);
40+
} catch (Throwable e) {
41+
e.printStackTrace();
42+
}
43+
return new RaeSkinImageViewV4(context, attributeSet);
3844
}
3945
return null;
4046
}

app/src/main/java/com/rae/cnblogs/fragment/CategoriesFragment.java

+18-8
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,6 @@ public void onItemLongClick(int i) {
227227
});
228228
}
229229

230-
/**
231-
* 通知分类数据改变
232-
*/
233-
private void notifyDataSetChanged() {
234-
mCategoryAdapter.updateDataSet(mCategoryItems);
235-
mUnusedAdapter.updateDataSet(mUnusedItems);
236-
}
237230

238231
@Override
239232
public void onItemDrag() {
@@ -302,7 +295,7 @@ public ObservableSource<Empty> apply(List<CategoryBean> categoryBeans) throws Ex
302295
public void accept(@NonNull Empty empty) throws Exception {
303296
if (enableNotify) {
304297
mHandler.removeMessages(0);
305-
mHandler.sendEmptyMessageDelayed(0, 300);
298+
mHandler.sendEmptyMessageDelayed(0, 200);
306299
}
307300
}
308301
});
@@ -319,6 +312,23 @@ public boolean handleMessage(Message msg) {
319312
}
320313
});
321314

315+
/**
316+
* 通知分类数据改变
317+
*/
318+
private void notifyDataSetChanged() {
319+
mCategoryAdapter.updateDataSet(mCategoryItems);
320+
mUnusedAdapter.updateDataSet(mUnusedItems);
321+
322+
// bug fix: 兼容华为文字白屏问题
323+
mCategoryRecyclerView.postDelayed(new Runnable() {
324+
@Override
325+
public void run() {
326+
mCategoryAdapter.notifyDataSetChanged();
327+
mUnusedAdapter.notifyDataSetChanged();
328+
}
329+
}, 300);
330+
}
331+
322332
@Override
323333
public void onDestroy() {
324334
mHandler.removeMessages(0);

app/src/main/java/com/rae/cnblogs/model/CategoriesOverallItem.java

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public void bindViewHolder(FlexibleAdapter flexibleAdapter, CategoriesViewHolder
5757

5858
}
5959

60+
61+
6062
@Override
6163
public boolean isDraggable() {
6264
// 首页、推荐不能拖动

app/src/main/java/com/rae/cnblogs/widget/RaeSkinImageView.java

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.rae.cnblogs.ThemeCompat;
88

9+
import skin.support.widget.SkinCompatBackgroundHelper;
10+
import skin.support.widget.SkinCompatImageHelper;
911
import skin.support.widget.SkinCompatImageView;
1012

1113
public class RaeSkinImageView extends SkinCompatImageView {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.rae.cnblogs.widget;
2+
3+
4+
import android.content.Context;
5+
import android.support.annotation.DrawableRes;
6+
import android.util.AttributeSet;
7+
import android.widget.ImageView;
8+
9+
import com.rae.cnblogs.ThemeCompat;
10+
11+
import skin.support.widget.SkinCompatBackgroundHelper;
12+
import skin.support.widget.SkinCompatImageHelper;
13+
import skin.support.widget.SkinCompatSupportable;
14+
15+
/**
16+
* 兼容4.4.4 问题
17+
*/
18+
public class RaeSkinImageViewV4 extends ImageView implements SkinCompatSupportable {
19+
20+
private SkinCompatBackgroundHelper mBackgroundTintHelper;
21+
private SkinCompatImageHelper mImageHelper;
22+
23+
public RaeSkinImageViewV4(Context context) {
24+
this(context, null);
25+
init();
26+
}
27+
28+
public RaeSkinImageViewV4(Context context, AttributeSet attrs) {
29+
this(context, attrs, 0);
30+
init();
31+
}
32+
33+
public RaeSkinImageViewV4(Context context, AttributeSet attrs, int defStyleAttr) {
34+
super(context, attrs, defStyleAttr);
35+
this.mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
36+
this.mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
37+
this.mImageHelper = new SkinCompatImageHelper(this);
38+
this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
39+
init();
40+
}
41+
42+
private void init() {
43+
// 初始化的时候不用取反
44+
setAlpha(ThemeCompat.isNight() ? 0.3f : 1f);
45+
}
46+
47+
@Override
48+
public void applySkin() {
49+
setAlpha(isNight() ? 0.3f : 1f);
50+
if (this.mBackgroundTintHelper != null) {
51+
this.mBackgroundTintHelper.applySkin();
52+
}
53+
54+
if (this.mImageHelper != null) {
55+
this.mImageHelper.applySkin();
56+
}
57+
}
58+
59+
public boolean isNight() {
60+
// 因为是先应用主题之后才会设置主题名称,所以这里取反。
61+
return !ThemeCompat.isNight();
62+
}
63+
64+
65+
public void setBackgroundResource(@DrawableRes int resId) {
66+
super.setBackgroundResource(resId);
67+
if (this.mBackgroundTintHelper != null) {
68+
this.mBackgroundTintHelper.onSetBackgroundResource(resId);
69+
}
70+
71+
}
72+
73+
public void setImageResource(@DrawableRes int resId) {
74+
if (this.mImageHelper != null) {
75+
this.mImageHelper.setImageResource(resId);
76+
}
77+
78+
}
79+
80+
}

app/tinker-support.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tinkerSupport {
4141
// tinkerId = "cnblogs-path-1.0.0-001"
4242

4343
// 构建多渠道补丁时使用
44-
buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
44+
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
4545

4646
// 是否启用加固模式,默认为false.(tinker-spport 1.0.7起支持)
4747
// isProtectedApp = true

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ task cleanCache(type: Delete) {
5252
println '-------------> end clean cache task <----------------'
5353
}
5454
}
55+
5556
ext {
5657
compileSdkVersion = 26
5758
buildToolsVersion = '26.0.1'
5859
targetSdkVersion = 26
5960
minSdkVersion = 15
60-
supportVersion = '25.1.0'
61+
supportVersion = '25.4.0'
6162
}

0 commit comments

Comments
 (0)