Skip to content

Commit ebe59b4

Browse files
authored
Merge pull request #2 from north2016/master
update code
2 parents 68384c9 + 89601c2 commit ebe59b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+244
-161
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
.DS_Store
77
/build
88
/captures
9-
/buildsrc/build
9+
/buildsrc/build
10+
/lib/build

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import com.app.plugin.AspectjPlugin
2+
import com.app.plugin.JavassistPlugin
3+
14
apply plugin: 'com.android.application'
25
apply plugin: 'me.tatarka.retrolambda'
36

@@ -60,5 +63,5 @@ dependencies {
6063
annotationProcessor project(':apt')
6164
}
6265

63-
apply plugin: com.app.plugin.AspectjPlugin
64-
apply plugin: com.app.plugin.JavassistPlugin
66+
apply plugin: AspectjPlugin
67+
apply plugin: JavassistPlugin

app/src/main/java/com/App.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Activity;
44
import android.app.Application;
55
import android.os.Bundle;
6+
import android.support.v7.app.AppCompatDelegate;
67

78
import com.app.annotation.aspect.TimeLog;
89
import com.base.util.SpUtil;
@@ -18,12 +19,12 @@ public class App extends Application {
1819
public Stack<Activity> store;
1920
public HashMap<String, Object> mCurActivityExtra;
2021

21-
@Override
2222
@TimeLog
2323
public void onCreate() {
2424
super.onCreate();
2525
mApp = this;
2626
SpUtil.init(this);
27+
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
2728
store = new Stack<>();
2829
registerActivityLifecycleCallbacks(new SwitchBackgroundCallbacks());
2930
}

app/src/main/java/com/base/DataBindingActivity.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.base;
22

33
import android.content.Context;
4-
import android.content.Intent;
54
import android.databinding.DataBindingUtil;
65
import android.databinding.ViewDataBinding;
76
import android.os.Bundle;
87
import android.support.v7.app.AppCompatActivity;
8+
import android.support.v7.app.AppCompatDelegate;
99
import android.support.v7.widget.Toolbar;
1010
import android.view.Menu;
1111
import android.view.MenuItem;
@@ -29,12 +29,10 @@ public abstract class DataBindingActivity<B extends ViewDataBinding> extends App
2929
private ImageView ivShadow;
3030
public B mViewBinding;
3131

32-
3332
@Override
3433
public void onCreate(Bundle savedInstanceState) {
3534
super.onCreate(savedInstanceState);
3635
isNight = SpUtil.isNight();
37-
setTheme(isNight ? R.style.AppThemeNight : R.style.AppThemeDay);
3836
View rootView = getLayoutInflater().inflate(this.getLayoutId(), null, false);
3937
mViewBinding = DataBindingUtil.bind(rootView);
4038
this.setContentView(getLayoutId(), rootView);
@@ -46,7 +44,6 @@ public void onCreate(Bundle savedInstanceState) {
4644
initView();
4745
}
4846

49-
5047
protected void initPresenter() {
5148
}
5249

@@ -62,27 +59,12 @@ private void initToolBar() {
6259
}
6360
}
6461

65-
@Override
66-
protected void onResume() {
67-
super.onResume();
68-
if (isNight != SpUtil.isNight()) reload(false);
69-
}
70-
71-
public void reload(boolean isNeedAnim) {
72-
if (isNeedAnim) {
73-
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
74-
recreate();
75-
} else {
76-
Intent intent = getIntent();
77-
overridePendingTransition(0, 0);
78-
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
79-
finish();
80-
overridePendingTransition(0, 0);
81-
startActivity(intent);
82-
}
62+
public void reload() {
63+
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
64+
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
65+
recreate();
8366
}
8467

85-
8668
public void setContentView(int layoutResID, View rootView) {
8769
if (layoutResID == R.layout.activity_main || layoutResID == R.layout.activity_flash) {
8870
super.setContentView(rootView);

app/src/main/java/com/base/adapter/TRecyclerView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void init(Context context, AttributeSet attrs) {
5757
boolean isRefreshable = ta.getBoolean(R.styleable.TRecyclerView_isRefreshable, true);
5858
ta.recycle();
5959

60-
View layout = inflate(context, R.layout.layout_list_recyclerview, this);
60+
View layout = inflate(context, R.layout.layout_list_recyclerview, this);
6161
swipeRefresh = (SwipeRefreshLayout) layout.findViewById(R.id.swiperefresh);
6262
recyclerview = (RecyclerView) layout.findViewById(R.id.recyclerview);
6363
ll_emptyView = (LinearLayout) layout.findViewById(R.id.ll_emptyview);

app/src/main/java/com/base/util/BindingUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.database.Cursor;
77
import android.databinding.BindingAdapter;
8+
import android.graphics.PorterDuff;
89
import android.net.Uri;
910
import android.provider.MediaStore;
1011
import android.text.Html;
@@ -26,6 +27,7 @@
2627
public class BindingUtils {
2728
@BindingAdapter({"imageUrl"})
2829
public static void loadImg(ImageView v, String url) {
30+
v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
2931
Glide.with(v.getContext())
3032
.load(getFuckUrl(url))
3133
.diskCacheStrategy(DiskCacheStrategy.ALL)
@@ -34,6 +36,7 @@ public static void loadImg(ImageView v, String url) {
3436

3537
@BindingAdapter({"roundImageUrl"})
3638
public static void loadRoundImg(ImageView v, String url) {
39+
v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
3740
Glide.with(v.getContext())
3841
.load(getFuckUrl(url))
3942
.diskCacheStrategy(DiskCacheStrategy.ALL)
@@ -44,12 +47,12 @@ public static void loadRoundImg(ImageView v, String url) {
4447

4548
@BindingAdapter({"comment"})
4649
public static void setComment(TextView tv, CommentInfo data) {
47-
tv.setText(Html.fromHtml("<font color='#ff7200'>" + data.creater.username + ":<br/><br/>" + "</font>" + data.content));
50+
tv.setText(Html.fromHtml("<font color='#000000'>" + data.creater.username + ":<br/><br/>" + "</font>" + data.content));
4851
}
4952

5053
@BindingAdapter({"message"})
5154
public static void setMessage(TextView tv, MessageInfo data) {
52-
tv.setText(Html.fromHtml("<font color='#ff7200'>" + data.creater.username + ":<br/><br/>" + "</font>" + data.message));
55+
tv.setText(Html.fromHtml("<font color='#000000'>" + data.creater.username + ":<br/><br/>" + "</font>" + data.message));
5356
}
5457

5558
@BindingAdapter({"article"})
@@ -70,13 +73,14 @@ public static String getFuckUrl(String url) {
7073
}
7174

7275
public static void loadRoundAndBgImg(ImageView v, String url, ImageView im_header) {
76+
v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
7377
Glide.with(v.getContext())
7478
.load(getFuckUrl(url))
7579
.diskCacheStrategy(DiskCacheStrategy.ALL)
7680
.transform(new GlideCircleTransform(v.getContext()))
7781
.error(R.mipmap.ic_launcher)
7882
.into(v);
79-
83+
im_header.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
8084
Glide.with(v.getContext()).load(getFuckUrl(url))
8185
.diskCacheStrategy(DiskCacheStrategy.ALL)
8286
.transform(new BlurTransformation(v.getContext(), 100))

app/src/main/java/com/base/util/SpUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static boolean isNight() {
2929
public static void setNight(Context context, boolean isNight) {
3030
prefs.edit().putBoolean("isNight", isNight).commit();
3131
if (context instanceof BaseActivity)
32-
((BaseActivity) context).reload(true);
32+
((BaseActivity) context).reload();
3333
}
3434

3535
public static _User getUser() {

app/src/main/java/com/base/util/helper/ImageAnimator.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.base.util.SpUtil;
1212

1313
public class ImageAnimator {
14-
String[] mImages = {
14+
private String[] mImages = {
1515
"http://img-cdn.luoo.net/pics/vol/585800ce78e88.jpg?imageView2/1/w/640/h/452",
1616
"http://img-cdn.luoo.net/pics/vol/58138dab67978.jpg?imageView2/1/w/640/h/452",
1717
"http://img-cdn.luoo.net/pics/vol/5838629f22305.jpg?imageView2/1/w/640/h/452",
@@ -22,8 +22,8 @@ public class ImageAnimator {
2222
"http://img-cdn.luoo.net/pics/vol/57e2c6fd714e2.jpg?imageView2/1/w/640/h/452",
2323
"http://img-cdn.luoo.net/pics/vol/579255f04b1da.jpg?imageView2/1/w/640/h/452",
2424
"http://img-cdn.luoo.net/pics/vol/581b681b678f1.jpg?imageView2/1/w/640/h/452"};
25-
int[] mColors;
26-
int[] mColorDay = {
25+
private int[] mColors;
26+
private int[] mColorDay = {
2727
Color.parseColor("#F44336"),
2828
Color.parseColor("#E91E63"),
2929
Color.parseColor("#9C27B0"),
@@ -36,7 +36,7 @@ public class ImageAnimator {
3636
Color.parseColor("#4CAF50"),
3737
};
3838

39-
int[] mColorNight = {
39+
private int[] mColorNight = {
4040
Color.parseColor("#290502"),
4141
Color.parseColor("#011e2b"),
4242
Color.parseColor("#210825"),
@@ -60,9 +60,9 @@ public class ImageAnimator {
6060
private int mEnd;
6161

6262
private boolean isSkip = false;//是否跳页
63-
CollapsingToolbarLayout collapsingToolbar;
63+
private CollapsingToolbarLayout collapsingToolbar;
6464

65-
public ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) {
65+
ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) {
6666
this.collapsingToolbar = collapsingToolbar;
6767
mTargetImage = targetImage;
6868
mOutgoingImage = outgoingImage;
@@ -129,7 +129,7 @@ public void end(int endPosition) {
129129
}
130130

131131
// 向前滚动, 比如0->1, offset滚动的距离(0->1), 目标渐渐淡出
132-
public void forward(int position, float positionOffset) {
132+
void forward(int position, float positionOffset) {
133133
if (isSkip) return;
134134
// Log.e("DEBUG-WCL", "forward-positionOffset: " + positionOffset);
135135
int width = mTargetImage.getWidth();
@@ -142,7 +142,7 @@ public void forward(int position, float positionOffset) {
142142
}
143143

144144
// 向后滚动, 比如1->0, offset滚动的距离(1->0), 目标渐渐淡入
145-
public void backwards(int position, float positionOffset) {
145+
void backwards(int position, float positionOffset) {
146146
if (isSkip) return;
147147
// Log.e("DEBUG-WCL", "backwards-positionOffset: " + positionOffset);
148148
int width = mTargetImage.getWidth();
@@ -156,7 +156,7 @@ public void backwards(int position, float positionOffset) {
156156
}
157157

158158
// 判断停止
159-
public boolean isWithin(int position) {
159+
boolean isWithin(int position) {
160160
return position >= mStart && position < mEnd;
161161
}
162162
}

app/src/main/java/com/ui/home/HomeActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void initUserInfo(_User user) {
9191
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
9292
if (item.getItemId() == R.id.nav_manage) TRouter.go(C.SETTING);
9393
else if (item.getItemId() == R.id.nav_share) TRouter.go(C.LOGIN);
94-
else if (item.getItemId() == R.id.nav_send) SpUtil.setNight(mContext, !SpUtil.isNight());
94+
else if (item.getItemId() == R.id.nav_theme) SpUtil.setNight(mContext, !SpUtil.isNight());
9595
return true;
9696
}
9797

app/src/main/java/com/ui/main/SettingsActivity.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import com.C;
1313
import com.app.annotation.apt.Router;
14-
import com.base.util.SpUtil;
1514

1615
@Router(C.SETTING)
1716
public class SettingsActivity extends PreferenceActivity {
@@ -20,7 +19,6 @@ public class SettingsActivity extends PreferenceActivity {
2019

2120
@Override
2221
protected void onCreate(Bundle savedInstanceState) {
23-
setTheme(SpUtil.isNight() ? R.style.AppThemeNight : R.style.AppThemeDay);
2422
getDelegate().installViewFactory();
2523
getDelegate().onCreate(savedInstanceState);
2624
super.onCreate(savedInstanceState);
@@ -31,16 +29,6 @@ protected void onCreate(Bundle savedInstanceState) {
3129
setSupportActionBar(toolbar);
3230
mDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
3331

34-
isNight = (SwitchPreference) findPreference("isNight");
35-
isNight.setOnPreferenceChangeListener((preference, newValue) -> {
36-
reload();
37-
return true;
38-
});
39-
}
40-
41-
public void reload() {
42-
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
43-
recreate();
4432
}
4533

4634

app/src/main/java/com/ui/main/TMVPFragment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.ui.main;
22

33
import android.app.Dialog;
4+
import android.graphics.PorterDuff;
45
import android.os.Bundle;
56
import android.support.design.widget.BottomSheetBehavior;
67
import android.support.design.widget.BottomSheetDialog;
78
import android.support.v4.app.FragmentManager;
89
import android.view.View;
910
import android.view.WindowManager;
11+
import android.widget.ImageView;
12+
13+
import com.base.util.SpUtil;
1014

1115
/**
1216
* Created by baixiaokang on 16/12/23.
@@ -15,6 +19,7 @@
1519
public class TMVPFragment extends android.support.design.widget.BottomSheetDialogFragment {
1620
private static TMVPFragment mTMVPFragment;
1721
private BottomSheetBehavior mBehavior;
22+
private ImageView imPay;
1823

1924
@Override
2025
public Dialog onCreateDialog(Bundle savedInstanceState) {
@@ -23,13 +28,15 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
2328
dialog.setContentView(view);
2429
mBehavior = BottomSheetBehavior.from((View) view.getParent());
2530
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
31+
imPay = (ImageView) view.findViewById(R.id.im_pay);
2632
return dialog;
2733
}
2834

2935
@Override
3036
public void onStart() {
3137
super.onStart();
3238
mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
39+
imPay.setColorFilter(getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
3340
}
3441

3542
public static TMVPFragment getInstance() {

app/src/main/java/com/view/widget/ChartView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import com.app.annotation.aspect.SingleClick;
1212
import com.base.util.BaseUtils;
13-
import com.base.util.SpUtil;
1413
import com.ui.main.R;
1514

1615
public class ChartView extends View implements View.OnClickListener {
@@ -39,7 +38,7 @@ public ChartView(Context context, Double[] Lines, Double[] num0, Double[] num1)
3938

4039
@Override
4140
protected void onDraw(Canvas canvas) {
42-
canvas.drawColor(getResources().getColor(!SpUtil.isNight() ? R.color.colorPrimary : R.color.md_grey));
41+
canvas.drawColor(getResources().getColor(R.color.colorPrimary));
4342
itemWidth = getWidth() / 9;
4443
itemHeight = getHeight() / 8;
4544
canvas.drawText("活跃用户", getWidth() / 4, itemHeight * 4 / 3, mYellowTextPaint);

0 commit comments

Comments
 (0)