Skip to content

Commit a3835fc

Browse files
committed
小调整
1 parent 7c49715 commit a3835fc

File tree

9 files changed

+88
-27
lines changed

9 files changed

+88
-27
lines changed

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,44 @@ public static void switchNightMode() {
8686
public static void switchNightMode(boolean isNight) {
8787
if (isNight) {
8888
// 切换正常模式
89-
SkinCompatManager.getInstance().restoreDefaultTheme();
89+
SkinCompatManager.getInstance().loadSkin("", new SkinCompatManager.SkinLoaderListener() {
90+
@Override
91+
public void onStart() {
92+
93+
}
94+
95+
@Override
96+
public void onSuccess() {
97+
// 发出通知
98+
EventBus.getDefault().post(new ThemeChangedEvent(ThemeCompat.isNight()));
99+
}
100+
101+
@Override
102+
public void onFailed(String s) {
103+
104+
}
105+
});
90106
} else {
91-
SkinCompatManager.getInstance().loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN);
107+
SkinCompatManager.getInstance().loadSkin("night", new SkinCompatManager.SkinLoaderListener() {
108+
@Override
109+
public void onStart() {
110+
111+
}
112+
113+
@Override
114+
public void onSuccess() {
115+
// 发出通知
116+
EventBus.getDefault().post(new ThemeChangedEvent(ThemeCompat.isNight()));
117+
}
118+
119+
@Override
120+
public void onFailed(String s) {
121+
122+
}
123+
}, SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN);
92124
}
93125

94-
// 发出通知
95-
EventBus.getDefault().post(new ThemeChangedEvent(ThemeCompat.isNight()));
126+
96127
}
97128

98129
/**

app/src/main/java/com/rae/cnblogs/activity/SearchActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.rae.cnblogs.activity;
22

3+
import android.os.Build;
34
import android.os.Bundle;
45
import android.support.annotation.Nullable;
56
import android.support.v4.app.Fragment;
7+
import android.support.v4.content.ContextCompat;
68
import android.view.View;
79

10+
import com.rae.cnblogs.R;
11+
import com.rae.cnblogs.ThemeCompat;
812
import com.rae.cnblogs.fragment.SearchFragment;
913

1014
/**
@@ -26,6 +30,14 @@ protected Fragment newFragment() {
2630
return SearchFragment.newInstance();
2731
}
2832

33+
@Override
34+
protected void onResume() {
35+
super.onResume();
36+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
37+
getWindow().setStatusBarColor(ContextCompat.getColor(this, ThemeCompat.isNight() ? R.color.nightColorPrimary : R.color.white));
38+
}
39+
}
40+
2941
@Override
3042
public void finish() {
3143
super.finish();

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.rae.cnblogs.widget;
22

33
import android.content.Context;
4+
import android.support.annotation.DrawableRes;
45
import android.support.v7.widget.LinearLayoutManager;
56
import android.support.v7.widget.RecyclerView;
67
import android.support.v7.widget.StaggeredGridLayoutManager;
@@ -9,31 +10,48 @@
910
import com.jcodecraeer.xrecyclerview.ProgressStyle;
1011
import com.jcodecraeer.xrecyclerview.XRecyclerView;
1112

13+
import skin.support.widget.SkinCompatBackgroundHelper;
14+
import skin.support.widget.SkinCompatSupportable;
15+
1216
/**
1317
* RecycleView
1418
* Created by ChenRui on 2016/12/3 17:26.
1519
*/
16-
public class RaeRecyclerView extends XRecyclerView {
20+
public class RaeRecyclerView extends XRecyclerView implements SkinCompatSupportable {
21+
22+
private SkinCompatBackgroundHelper mBackgroundTintHelper;
1723

1824
private RaeLoadMoreView mFootView;
1925

2026

2127
public RaeRecyclerView(Context context) {
2228
super(context);
23-
init();
29+
init(null, 0);
2430
}
2531

2632
public RaeRecyclerView(Context context, AttributeSet attrs) {
2733
super(context, attrs);
28-
init();
34+
init(attrs, 0);
2935
}
3036

3137
public RaeRecyclerView(Context context, AttributeSet attrs, int defStyle) {
3238
super(context, attrs, defStyle);
33-
init();
39+
init(attrs, defStyle);
3440
}
3541

36-
private void init() {
42+
public void setBackgroundResource(@DrawableRes int resId) {
43+
super.setBackgroundResource(resId);
44+
if (this.mBackgroundTintHelper != null) {
45+
this.mBackgroundTintHelper.onSetBackgroundResource(resId);
46+
}
47+
48+
}
49+
50+
private void init(AttributeSet attrs, int defStyle) {
51+
52+
this.mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
53+
this.mBackgroundTintHelper.loadFromAttributes(attrs, defStyle);
54+
3755
setLayoutManager(new LinearLayoutManager(getContext()));
3856
setPullRefreshEnabled(false);
3957
mFootView = new RaeLoadMoreView(getContext());
@@ -59,7 +77,6 @@ public void setLoadingMoreProgressStyle(int style) {
5977

6078
/**
6179
* 是否在顶部
62-
*
6380
*/
6481
public boolean isOnTop() {
6582
if (getChildCount() == 0) {
@@ -101,4 +118,11 @@ public boolean isOnTop() {
101118
}
102119
return false;
103120
}
121+
122+
@Override
123+
public void applySkin() {
124+
if (this.mBackgroundTintHelper != null) {
125+
this.mBackgroundTintHelper.applySkin();
126+
}
127+
}
104128
}

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
import android.content.Context;
44
import android.content.res.TypedArray;
5-
import android.support.design.widget.TabLayout;
65
import android.util.AttributeSet;
76

87
import com.rae.cnblogs.R;
98

109
import skin.support.content.res.SkinCompatResources;
10+
import skin.support.design.widget.SkinMaterialTabLayout;
1111
import skin.support.widget.SkinCompatBackgroundHelper;
1212
import skin.support.widget.SkinCompatHelper;
1313
import skin.support.widget.SkinCompatSupportable;
1414

1515
import static skin.support.widget.SkinCompatHelper.INVALID_ID;
1616

1717

18-
public class RaeTabLayout extends TabLayout implements SkinCompatSupportable {
18+
public class RaeTabLayout extends SkinMaterialTabLayout implements SkinCompatSupportable {
1919
private SkinCompatBackgroundHelper mBackgroundTintHelper;
2020

2121
private int mIndicatorColorResId = INVALID_ID;
@@ -37,7 +37,6 @@ public RaeTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
3737
initViews(attrs, defStyleAttr);
3838
}
3939

40-
4140
private void initViews(AttributeSet attrs, int defStyleAttr) {
4241
obtainAttributes(getContext(), attrs);
4342
mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
@@ -67,20 +66,14 @@ private void applyTabLayoutResources() {
6766
if (mTextSelectColorResId != INVALID_ID && mTextUnselectColorResId != INVALID_ID) {
6867
setTabTextColors(resources.getColor(mTextUnselectColorResId), resources.getColor(mTextSelectColorResId));
6968
}
70-
71-
// 找到所有的TAB,TODO:TAB VIEW
72-
int tabCount = getTabCount();
73-
for (int i = 0; i < tabCount; i++) {
74-
Tab tab = getTabAt(i);
75-
}
7669
}
7770

7871
@Override
7972
public void applySkin() {
73+
super.applySkin();
8074
applyTabLayoutResources();
8175
if (mBackgroundTintHelper != null) {
8276
mBackgroundTintHelper.applySkin();
8377
}
84-
8578
}
8679
}
Loading

app/src/main/res/layout/activity_setting.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@
143143

144144
<ProgressBar
145145
android:id="@+id/pb_check_update"
146+
style="@style/Widget.AppCompat.ProgressBar"
146147
android:layout_width="24dp"
147148
android:layout_height="24dp"
148-
android:indeterminateDrawable="@drawable/ic_progress_loading"
149+
android:indeterminateDrawable="@drawable/progress_bar_loading"
149150
android:visibility="invisible"/>
150151

151152
<TextView

app/src/main/res/layout/activity_system_message.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
1616
android:background="@color/background_divider"
17+
app:empty_icon="@drawable/ic_empty_message"
1718
app:empty_message="暂无消息">
1819

1920
<com.rae.cnblogs.widget.RaeRecyclerView
2021
android:id="@+id/recycler_view"
2122
android:layout_width="match_parent"
22-
android:layout_height="match_parent"
23-
android:background="@color/background_divider"/>
23+
android:layout_height="match_parent"/>
2424

2525
</com.rae.cnblogs.widget.PlaceholderView>
2626
</LinearLayout>

app/src/main/res/layout/fm_search.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@
9797
android:layout_height="match_parent"/>
9898
</LinearLayout>
9999

100-
<android.support.v7.widget.RecyclerView
100+
<com.rae.cnblogs.widget.RaeRecyclerView
101101
android:id="@+id/rec_search"
102102
android:layout_width="match_parent"
103103
android:layout_height="match_parent"
104-
android:background="@color/white"/>
104+
android:background="@color/red"/>
105105

106106
</RelativeLayout>
107107
</android.support.v7.widget.FitWindowsLinearLayout>

app/src/main/res/values/colors_night.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
<color name="dividerPrimary_night">#2b2c2f</color>
1515
<color name="dividerColor_night">#2b2c2f</color>
1616
<color name="ph4_night">#595959</color>
17-
<color name="ph3_night">#595959</color>
17+
<color name="ph3_night">#595959</color>\
1818
<color name="ph2_night">#505053</color>
1919
<color name="ph1_night">#8f9091</color>
2020
<color name="default_background_night">#1F1F21</color>
21-
<color name="background_divider_night">#1F1F21</color>
21+
<color name="background_divider_night">@color/nightColorPrimary</color>
2222
<color name="colorToastPrimary_night">@color/nightColorPrimary</color>
2323
<color name="commentAvatarColor_night">@color/nightColorPrimary</color>
2424
<color name="blog_item_pressed_night">@color/nightColorPrimary</color>

0 commit comments

Comments
 (0)