Skip to content

Commit

Permalink
Merge pull request #2 from north2016/master
Browse files Browse the repository at this point in the history
update code
  • Loading branch information
jinghongjun authored Jan 19, 2017
2 parents 68384c9 + 89601c2 commit ebe59b4
Show file tree
Hide file tree
Showing 54 changed files with 244 additions and 161 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
.DS_Store
/build
/captures
/buildsrc/build
/buildsrc/build
/lib/build
6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.app.plugin.AspectjPlugin
import com.app.plugin.JavassistPlugin

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

Expand Down Expand Up @@ -60,5 +63,5 @@ dependencies {
annotationProcessor project(':apt')
}

apply plugin: com.app.plugin.AspectjPlugin
apply plugin: com.app.plugin.JavassistPlugin
apply plugin: AspectjPlugin
apply plugin: JavassistPlugin
3 changes: 2 additions & 1 deletion app/src/main/java/com/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;

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

@Override
@TimeLog
public void onCreate() {
super.onCreate();
mApp = this;
SpUtil.init(this);
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
store = new Stack<>();
registerActivityLifecycleCallbacks(new SwitchBackgroundCallbacks());
}
Expand Down
28 changes: 5 additions & 23 deletions app/src/main/java/com/base/DataBindingActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.base;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -29,12 +29,10 @@ public abstract class DataBindingActivity<B extends ViewDataBinding> extends App
private ImageView ivShadow;
public B mViewBinding;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isNight = SpUtil.isNight();
setTheme(isNight ? R.style.AppThemeNight : R.style.AppThemeDay);
View rootView = getLayoutInflater().inflate(this.getLayoutId(), null, false);
mViewBinding = DataBindingUtil.bind(rootView);
this.setContentView(getLayoutId(), rootView);
Expand All @@ -46,7 +44,6 @@ public void onCreate(Bundle savedInstanceState) {
initView();
}


protected void initPresenter() {
}

Expand All @@ -62,27 +59,12 @@ private void initToolBar() {
}
}

@Override
protected void onResume() {
super.onResume();
if (isNight != SpUtil.isNight()) reload(false);
}

public void reload(boolean isNeedAnim) {
if (isNeedAnim) {
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
recreate();
} else {
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
public void reload() {
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
recreate();
}


public void setContentView(int layoutResID, View rootView) {
if (layoutResID == R.layout.activity_main || layoutResID == R.layout.activity_flash) {
super.setContentView(rootView);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/base/adapter/TRecyclerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void init(Context context, AttributeSet attrs) {
boolean isRefreshable = ta.getBoolean(R.styleable.TRecyclerView_isRefreshable, true);
ta.recycle();

View layout = inflate(context, R.layout.layout_list_recyclerview, this);
View layout = inflate(context, R.layout.layout_list_recyclerview, this);
swipeRefresh = (SwipeRefreshLayout) layout.findViewById(R.id.swiperefresh);
recyclerview = (RecyclerView) layout.findViewById(R.id.recyclerview);
ll_emptyView = (LinearLayout) layout.findViewById(R.id.ll_emptyview);
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/base/util/BindingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Intent;
import android.database.Cursor;
import android.databinding.BindingAdapter;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.provider.MediaStore;
import android.text.Html;
Expand All @@ -26,6 +27,7 @@
public class BindingUtils {
@BindingAdapter({"imageUrl"})
public static void loadImg(ImageView v, String url) {
v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
Glide.with(v.getContext())
.load(getFuckUrl(url))
.diskCacheStrategy(DiskCacheStrategy.ALL)
Expand All @@ -34,6 +36,7 @@ public static void loadImg(ImageView v, String url) {

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

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

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

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

public static void loadRoundAndBgImg(ImageView v, String url, ImageView im_header) {
v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
Glide.with(v.getContext())
.load(getFuckUrl(url))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.transform(new GlideCircleTransform(v.getContext()))
.error(R.mipmap.ic_launcher)
.into(v);

im_header.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
Glide.with(v.getContext()).load(getFuckUrl(url))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.transform(new BlurTransformation(v.getContext(), 100))
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/base/util/SpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static boolean isNight() {
public static void setNight(Context context, boolean isNight) {
prefs.edit().putBoolean("isNight", isNight).commit();
if (context instanceof BaseActivity)
((BaseActivity) context).reload(true);
((BaseActivity) context).reload();
}

public static _User getUser() {
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/com/base/util/helper/ImageAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.base.util.SpUtil;

public class ImageAnimator {
String[] mImages = {
private String[] mImages = {
"http://img-cdn.luoo.net/pics/vol/585800ce78e88.jpg?imageView2/1/w/640/h/452",
"http://img-cdn.luoo.net/pics/vol/58138dab67978.jpg?imageView2/1/w/640/h/452",
"http://img-cdn.luoo.net/pics/vol/5838629f22305.jpg?imageView2/1/w/640/h/452",
Expand All @@ -22,8 +22,8 @@ public class ImageAnimator {
"http://img-cdn.luoo.net/pics/vol/57e2c6fd714e2.jpg?imageView2/1/w/640/h/452",
"http://img-cdn.luoo.net/pics/vol/579255f04b1da.jpg?imageView2/1/w/640/h/452",
"http://img-cdn.luoo.net/pics/vol/581b681b678f1.jpg?imageView2/1/w/640/h/452"};
int[] mColors;
int[] mColorDay = {
private int[] mColors;
private int[] mColorDay = {
Color.parseColor("#F44336"),
Color.parseColor("#E91E63"),
Color.parseColor("#9C27B0"),
Expand All @@ -36,7 +36,7 @@ public class ImageAnimator {
Color.parseColor("#4CAF50"),
};

int[] mColorNight = {
private int[] mColorNight = {
Color.parseColor("#290502"),
Color.parseColor("#011e2b"),
Color.parseColor("#210825"),
Expand All @@ -60,9 +60,9 @@ public class ImageAnimator {
private int mEnd;

private boolean isSkip = false;//是否跳页
CollapsingToolbarLayout collapsingToolbar;
private CollapsingToolbarLayout collapsingToolbar;

public ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) {
ImageAnimator(CollapsingToolbarLayout collapsingToolbar, ImageView targetImage, ImageView outgoingImage) {
this.collapsingToolbar = collapsingToolbar;
mTargetImage = targetImage;
mOutgoingImage = outgoingImage;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void end(int endPosition) {
}

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

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

// 判断停止
public boolean isWithin(int position) {
boolean isWithin(int position) {
return position >= mStart && position < mEnd;
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/ui/home/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void initUserInfo(_User user) {
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.nav_manage) TRouter.go(C.SETTING);
else if (item.getItemId() == R.id.nav_share) TRouter.go(C.LOGIN);
else if (item.getItemId() == R.id.nav_send) SpUtil.setNight(mContext, !SpUtil.isNight());
else if (item.getItemId() == R.id.nav_theme) SpUtil.setNight(mContext, !SpUtil.isNight());
return true;
}

Expand Down
12 changes: 0 additions & 12 deletions app/src/main/java/com/ui/main/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import com.C;
import com.app.annotation.apt.Router;
import com.base.util.SpUtil;

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

@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SpUtil.isNight() ? R.style.AppThemeNight : R.style.AppThemeDay);
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
Expand All @@ -31,16 +29,6 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
mDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

isNight = (SwitchPreference) findPreference("isNight");
isNight.setOnPreferenceChangeListener((preference, newValue) -> {
reload();
return true;
});
}

public void reload() {
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
recreate();
}


Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/ui/main/TMVPFragment.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.ui.main;

import android.app.Dialog;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;

import com.base.util.SpUtil;

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Expand All @@ -23,13 +28,15 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
dialog.setContentView(view);
mBehavior = BottomSheetBehavior.from((View) view.getParent());
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
imPay = (ImageView) view.findViewById(R.id.im_pay);
return dialog;
}

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

public static TMVPFragment getInstance() {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/view/widget/ChartView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.app.annotation.aspect.SingleClick;
import com.base.util.BaseUtils;
import com.base.util.SpUtil;
import com.ui.main.R;

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

@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(getResources().getColor(!SpUtil.isNight() ? R.color.colorPrimary : R.color.md_grey));
canvas.drawColor(getResources().getColor(R.color.colorPrimary));
itemWidth = getWidth() / 9;
itemHeight = getHeight() / 8;
canvas.drawText("活跃用户", getWidth() / 4, itemHeight * 4 / 3, mYellowTextPaint);
Expand Down
Loading

0 comments on commit ebe59b4

Please sign in to comment.