createFactory(Class> viewClazz){
24 | CreatePresenter annotation = viewClazz.getAnnotation(CreatePresenter.class);
25 | Class aClass = null;
26 | if(annotation != null) {
27 | aClass = (Class
) annotation.value();
28 | }
29 | return aClass == null ? null : new PresenterFactory(aClass);
30 | }
31 | @Override
32 | public P createPresenter() {
33 | try {
34 | return mPresenterClass.newInstance();
35 | } catch (Exception e) {
36 | throw new RuntimeException("Presenter create failed!," +
37 | "please check if declaration @CreatePresenter(xxx.class) anotation or not");
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/LodeMoreFlowableSubscriber.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 |
5 | import com.gank.chen.http.exception.ApiException;
6 | import com.gank.chen.util.NetworkHelper;
7 | import com.gank.chen.util.ToastUtils;
8 |
9 | import io.reactivex.subscribers.ResourceSubscriber;
10 |
11 | /**
12 | *
13 | * @author chen
14 | * @date 2017/12/17
15 | */
16 |
17 | public abstract class LodeMoreFlowableSubscriber extends ResourceSubscriber {
18 | private Context context;
19 |
20 | public LodeMoreFlowableSubscriber(Context context) {
21 | this.context = context;
22 | }
23 | @Override
24 | protected void onStart() {
25 | super.onStart();
26 | }
27 |
28 | @Override
29 | public void onNext(T t) {
30 | if (t == null) {
31 | return;
32 | }
33 | onSuccess(t);
34 | }
35 |
36 | @Override
37 | public void onError(Throwable t) {
38 | if (!NetworkHelper.isNetworkAvailable(context)) {
39 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
40 | } else {
41 | ApiException.handleException(context,t);
42 | ToastUtils.showToast(context, t.getMessage());
43 | }
44 | dispose();
45 | }
46 |
47 | @Override
48 | public void onComplete() {
49 | dispose();
50 | }
51 |
52 | /**
53 | * 加载成功
54 | *
55 | * @return
56 | */
57 | public abstract void onSuccess(T t);
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main_drawerlayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/presenter/MeiZiListPresenter.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.presenter;
2 |
3 | import android.content.Context;
4 |
5 | import com.gank.chen.base.BasePrestener;
6 | import com.gank.chen.http.ApiRetrofit;
7 | import com.gank.chen.http.subscriber.ApiSubscriberFlowable;
8 | import com.gank.chen.http.subscriber.LodeMoreFlowableSubscriber;
9 | import com.gank.chen.mvp.model.MeiZi;
10 | import com.gank.chen.mvp.view.PullDownLoadMoreViewImp;
11 | import com.gank.chen.widget.StateView;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * Created by chen on 2017/12/17
17 | *
18 | * @author chenbo
19 | */
20 |
21 | public class MeiZiListPresenter extends BasePrestener>> {
22 |
23 | public void getGankData(Context context, StateView stateView, int page) {
24 |
25 | ApiRetrofit.setFlowableSubscribe(apiUtil.getGankData(page), new ApiSubscriberFlowable>(context, stateView) {
26 | @Override
27 | public void onSuccess(List gankModel) {
28 | getView().onLoadSucess(gankModel);
29 | }
30 |
31 | });
32 | }
33 |
34 | public void getMoreGankData(Context context, int page) {
35 | ApiRetrofit.setFlowableSubscribe(apiUtil.getGankData(page), new LodeMoreFlowableSubscriber>(context) {
36 | @Override
37 | public void onSuccess(List gankModel) {
38 | getView().onLoadMoreSuccess(gankModel);
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/widget/ColorFlipPagerTitleView.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.widget;
2 |
3 | import android.content.Context;
4 |
5 | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
6 |
7 | /**
8 | * Created by hackware on 2016/7/24.
9 | */
10 |
11 | public class ColorFlipPagerTitleView extends SimplePagerTitleView {
12 | private float mChangePercent = 0.5f;
13 |
14 | public ColorFlipPagerTitleView(Context context) {
15 | super(context);
16 | }
17 |
18 | @Override
19 | public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
20 | if (leavePercent >= mChangePercent) {
21 | setTextColor(mNormalColor);
22 | } else {
23 | setTextColor(mSelectedColor);
24 | }
25 | }
26 |
27 | @Override
28 | public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
29 | if (enterPercent >= mChangePercent) {
30 | setTextColor(mSelectedColor);
31 | } else {
32 | setTextColor(mNormalColor);
33 | }
34 | }
35 |
36 | @Override
37 | public void onSelected(int index, int totalCount) {
38 | }
39 |
40 | @Override
41 | public void onDeselected(int index, int totalCount) {
42 | }
43 |
44 | public float getChangePercent() {
45 | return mChangePercent;
46 | }
47 |
48 | public void setChangePercent(float changePercent) {
49 | mChangePercent = changePercent;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
21 |
22 |
28 |
29 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/widget/BottomNavigationViewHelper.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.widget;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.support.design.internal.BottomNavigationItemView;
5 | import android.support.design.internal.BottomNavigationMenuView;
6 | import android.support.design.widget.BottomNavigationView;
7 |
8 | import java.lang.reflect.Field;
9 |
10 | /**
11 | * Creat by chen on 2018/11/5
12 | * Describe:
13 | *
14 | * @author chenbo
15 | */
16 | public class BottomNavigationViewHelper {
17 |
18 | @SuppressLint("RestrictedApi")
19 | public static void disableShiftMode(BottomNavigationView view) {
20 | //获取子View BottomNavigationMenuView的对象
21 | BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
22 | try {
23 | //设置私有成员变量mShiftingMode可以修改
24 | Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
25 | shiftingMode.setAccessible(true);
26 | shiftingMode.setBoolean(menuView, false);
27 | shiftingMode.setAccessible(false);
28 | for (int i = 0; i < menuView.getChildCount(); i++) {
29 | BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
30 | //去除shift效果
31 | item.setShiftingMode(false);
32 | item.setChecked(item.getItemData().isChecked());
33 | }
34 | } catch (NoSuchFieldException e) {
35 | } catch (IllegalAccessException e) {
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/util/keyboard/AutoActivityLifecycleCallback.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.util.keyboard;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.os.Bundle;
6 |
7 | /**
8 | * Created by Piasy{github.com/Piasy} on 8/18/16.
9 | */
10 |
11 | public abstract class AutoActivityLifecycleCallback implements Application.ActivityLifecycleCallbacks {
12 | private final Activity mTargetActivity;
13 |
14 | AutoActivityLifecycleCallback(Activity targetActivity) {
15 | mTargetActivity = targetActivity;
16 | }
17 |
18 | @Override
19 | public void onActivityCreated(Activity activity, Bundle bundle) {
20 |
21 | }
22 |
23 | @Override
24 | public void onActivityStarted(Activity activity) {
25 |
26 | }
27 |
28 | @Override
29 | public void onActivityResumed(Activity activity) {
30 |
31 | }
32 |
33 | @Override
34 | public void onActivityPaused(Activity activity) {
35 |
36 | }
37 |
38 | @Override
39 | public void onActivityStopped(Activity activity) {
40 |
41 | }
42 |
43 | @Override
44 | public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
45 |
46 | }
47 |
48 | @Override
49 | public void onActivityDestroyed(Activity activity) {
50 | if (activity == mTargetActivity) {
51 | mTargetActivity.getApplication().unregisterActivityLifecycleCallbacks(this);
52 | onTargetActivityDestroyed();
53 | }
54 | }
55 |
56 | protected abstract void onTargetActivityDestroyed();
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
18 |
19 |
20 |
23 |
24 |
25 |
28 |
29 |
30 |
33 |
34 |
37 |
38 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_tab_chapter.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/CommonWebsiteModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | /**
4 | * Creat by chen on 2018/10/31
5 | * Describe:
6 | */
7 | public class CommonWebsiteModel {
8 | // "icon": "",
9 | // "id": 17,
10 | // "link": "http://www.wanandroid.com/article/list/0?cid=176",
11 | // "name": "国内大牛博客集合",
12 | // "order": 1,
13 | // "visible": 1
14 | private String icon;
15 | private int id;
16 | private String link;
17 | private String name;
18 | private int order;
19 | private int visible;
20 |
21 | public String getIcon() {
22 | return icon;
23 | }
24 |
25 | public void setIcon(String icon) {
26 | this.icon = icon;
27 | }
28 |
29 | public int getId() {
30 | return id;
31 | }
32 |
33 | public void setId(int id) {
34 | this.id = id;
35 | }
36 |
37 | public String getLink() {
38 | return link;
39 | }
40 |
41 | public void setLink(String link) {
42 | this.link = link;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public int getOrder() {
54 | return order;
55 | }
56 |
57 | public void setOrder(int order) {
58 | this.order = order;
59 | }
60 |
61 | public int getVisible() {
62 | return visible;
63 | }
64 |
65 | public void setVisible(int visible) {
66 | this.visible = visible;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/LodeMoreObserverSubscriber.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 |
5 | import com.gank.chen.http.exception.ApiException;
6 | import com.gank.chen.util.NetworkHelper;
7 | import com.gank.chen.util.ToastUtils;
8 |
9 | import io.reactivex.Observer;
10 | import io.reactivex.disposables.Disposable;
11 |
12 | /**
13 | * Created by chen on 2017/12/17.
14 | */
15 |
16 | public abstract class LodeMoreObserverSubscriber implements Observer {
17 | private Context context;
18 | private Disposable disposable;
19 |
20 | public LodeMoreObserverSubscriber(Context context) {
21 | this.context = context;
22 | }
23 |
24 |
25 | @Override
26 | public void onNext(T t) {
27 | if (t == null) {
28 | return;
29 | }
30 | onSuccess(t);
31 | }
32 |
33 | @Override
34 | public void onError(Throwable t) {
35 | if (!NetworkHelper.isNetworkAvailable(context)) {
36 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
37 | } else {
38 | ApiException.handleException(context, t);
39 | ToastUtils.showToast(context, t.getMessage());
40 | }
41 | disposable.dispose();
42 | }
43 |
44 | @Override
45 | public void onComplete() {
46 | disposable.dispose();
47 | }
48 |
49 | @Override
50 | public void onSubscribe(Disposable d) {
51 | disposable = d;
52 | }
53 |
54 | /**
55 | * 加载成功
56 | *
57 | * @return
58 | */
59 | public abstract void onSuccess(T t);
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/ui/activity/AboutUsActivity.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.ui.activity;
2 |
3 |
4 | import android.webkit.WebView;
5 |
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.gank.chen.R;
8 | import com.gank.chen.base.BaseNoNetActivity;
9 | import com.gank.chen.common.RouterUrlManager;
10 |
11 | import butterknife.BindView;
12 |
13 | /**
14 | * @author chenbo
15 | */
16 | @Route(path = RouterUrlManager.ABOUT)
17 | public class AboutUsActivity extends BaseNoNetActivity {
18 |
19 | @BindView(R.id.my_webview)
20 | WebView myX5WebView;
21 |
22 | @Override
23 | public int getViewLayoutId() {
24 | return R.layout.activity_about_us;
25 | }
26 |
27 | @Override
28 | public void initData() {
29 |
30 | }
31 |
32 | @Override
33 | public void initView() {
34 | initToolBar("关于", false);
35 | String url = "file:///android_asset/about.html";
36 | myX5WebView.loadUrl(url);
37 | // smartRefresh.setRefreshHeader(new TaurusHeader(this));
38 | // smartRefresh.setPrimaryColorsId(R.color.colorPrimary, R.color.colorPrimaryDark);
39 | // smartRefresh.setOnRefreshListener(new OnRefreshListener() {
40 | // @Override
41 | // public void onRefresh(@NonNull RefreshLayout refreshLayout) {
42 | // refreshLayout.finishRefresh(1000);
43 | // }
44 | // });
45 | // smartRefresh.setEnableLoadMore(false);
46 | }
47 |
48 | // @Override
49 | // public boolean onCreateOptionsMenu(Menu menu) {
50 | // getMenuInflater().inflate(R.menu.menu_share, menu);
51 | // return super.onCreateOptionsMenu(menu);
52 | // }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/ui/fragment/FragmentFactory.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.ui.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 |
6 | import com.gank.chen.common.RouterUrlManager;
7 | import com.gank.chen.mvp.model.ChaptersListModel;
8 | import com.gank.chen.util.RouterUtil;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @author chenbo
14 | * @date 2018/1/27
15 | */
16 |
17 | public class FragmentFactory {
18 | public static Fragment creatChaptersFragment(ChaptersListModel mhomeTab) {
19 | Fragment fragment = null;
20 | if (mhomeTab != null) {
21 | fragment = RouterUtil.getFragment(RouterUrlManager.CHAPTERSLIST_FRAGMENT);
22 | Bundle bundle = new Bundle();
23 | bundle.putInt("id", mhomeTab.getId());
24 | fragment.setArguments(bundle);
25 | }
26 | return fragment;
27 | }
28 |
29 | public static Fragment creatProjectFragment(ChaptersListModel mhomeTab) {
30 | Fragment fragment = null;
31 | if (mhomeTab != null) {
32 | fragment = RouterUtil.getFragment(RouterUrlManager.PROJECTLIST_FRAGMENT);
33 | Bundle bundle = new Bundle();
34 | bundle.putInt("id", mhomeTab.getId());
35 | fragment.setArguments(bundle);
36 | }
37 | return fragment;
38 | }
39 |
40 | public static Fragment creatTodoFragment(int position) {
41 | Fragment fragment = RouterUtil.getFragment(RouterUrlManager.TODOLIST_FRAGMENT);
42 | Bundle bundle = new Bundle();
43 | bundle.putInt("doneOrNot", position);
44 | fragment.setArguments(bundle);
45 | return fragment;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/ArticleModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Creat by chen on 2018/10/17
7 | * Describe:
8 | *
9 | * @author chenbo
10 | */
11 | public class ArticleModel {
12 | private int curPage;
13 | private List datas;
14 | private int offset;
15 | private boolean over;
16 | private int pageCount;
17 | private int size;
18 | private int total;
19 |
20 | public int getCurPage() {
21 | return curPage;
22 | }
23 |
24 | public void setCurPage(int curPage) {
25 | this.curPage = curPage;
26 | }
27 |
28 | public List getDatas() {
29 | return datas;
30 | }
31 |
32 | public void setDatas(List datas) {
33 | this.datas = datas;
34 | }
35 |
36 | public int getOffset() {
37 | return offset;
38 | }
39 |
40 | public void setOffset(int offset) {
41 | this.offset = offset;
42 | }
43 |
44 | public boolean isOver() {
45 | return over;
46 | }
47 |
48 | public void setOver(boolean over) {
49 | this.over = over;
50 | }
51 |
52 | public int getPageCount() {
53 | return pageCount;
54 | }
55 |
56 | public void setPageCount(int pageCount) {
57 | this.pageCount = pageCount;
58 | }
59 |
60 | public int getSize() {
61 | return size;
62 | }
63 |
64 | public void setSize(int size) {
65 | this.size = size;
66 | }
67 |
68 | public int getTotal() {
69 | return total;
70 | }
71 |
72 | public void setTotal(int total) {
73 | this.total = total;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/assets/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 | 关于WanAndroid
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
网站内容
18 |
本网站每天新增20~30篇优质文章,并加入到现有分类中,力求整理出一份优质而又详尽的知识体系,闲暇时间不妨上来学习下知识;
19 | 除此以外,并为大家提供平时开发过程中常用的工具以及常用的网址导航。
20 |
当然这只是我们目前的功能,未来我们将提供更多更加便捷的功能...
21 |
如果您有任何好的建议:
22 |
23 | - —关于网站排版
24 | - —关于新增常用网址以及工具
25 | - —未来你希望增加的功能等
26 |
27 |
可以在 hongyangAndroid/xueandroid 项目中以issue的形式提出,我将及时跟进。
28 |
29 |
如果您希望长期关注本站,可以加入我们的QQ群:591683946
30 |
关于网站作者
31 |
我是鸿洋,长期在CSDN上编写高质量的博客:
32 | blog.csdn.net/lmj623565791
33 | 并维护着一个微信公众号[hongyangAndroid],欢迎关注一下表示对我的支持:
34 |
"每天早晨7点30分,为你推荐优秀技术博文,提升从上班路上的闲暇时间开始~"
35 |
关于本App
36 |
这是基于鸿洋大神开放的Api做的App
37 | https://github.com/boiyun/WanAndroid
38 | 非常高兴能再这里遇到你,希望能给个Star支持一下,如果愿意帮忙试用,也希望能在github中以issue提出你的宝贵意见和建议,谢谢~
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/presenter/AddTodoPresenter.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.presenter;
2 |
3 | import android.content.Context;
4 |
5 | import com.gank.chen.base.BasePrestener;
6 | import com.gank.chen.http.ApiRetrofit;
7 | import com.gank.chen.http.subscriber.SubscriberObserverProgress;
8 | import com.gank.chen.mvp.view.ImpAddTodo;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * Creat by chen on 2018/11/15
14 | * Describe:
15 | *
16 | * @author chenbo
17 | */
18 | public class AddTodoPresenter extends BasePrestener {
19 |
20 | public void toAddOneToDo(Context context, Map map) {
21 | ApiRetrofit.setObservableBooleanSubscribe(apiUtil.toAddToDo(map)
22 | , new SubscriberObserverProgress(context) {
23 | @Override
24 | public void onSuccess(Boolean t) {
25 | if (t) {
26 | getView().onAddSuccess("添加成功");
27 | } else {
28 | getView().onAddFail("添加失败");
29 | }
30 |
31 | }
32 | });
33 |
34 | }
35 |
36 | public void toUpdateTheToDo(Context context, int id, Map map) {
37 | ApiRetrofit.setObservableBooleanSubscribe(apiUtil.toUpdateToDo(id, map), new SubscriberObserverProgress(context) {
38 | @Override
39 | public void onSuccess(Boolean aBoolean) {
40 | if (aBoolean) {
41 | getView().onUpdateSuccess();
42 | } else {
43 | getView().onUpdateFail("更新失败");
44 | }
45 |
46 | }
47 | });
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_navigation.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
13 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/ApiSubscriberFlowable.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 |
5 | import com.gank.chen.http.exception.ApiException;
6 | import com.gank.chen.util.NetworkHelper;
7 | import com.gank.chen.util.ToastUtils;
8 | import com.gank.chen.widget.StateView;
9 |
10 | import io.reactivex.subscribers.ResourceSubscriber;
11 |
12 | /**
13 | * @author chen
14 | * @date 2017/12/17
15 | */
16 |
17 | public abstract class ApiSubscriberFlowable extends ResourceSubscriber {
18 | private Context context;
19 | private StateView stateView;
20 |
21 | public ApiSubscriberFlowable(Context context, StateView stateView) {
22 | this.context = context;
23 | this.stateView = stateView;
24 | }
25 |
26 | @Override
27 | protected void onStart() {
28 | super.onStart();
29 | stateView.showLoading();
30 | }
31 |
32 | @Override
33 | public void onNext(T t) {
34 | if (t == null) {
35 | stateView.showEmpty();
36 | return;
37 | }
38 | stateView.showContent();
39 | onSuccess(t);
40 | }
41 |
42 | @Override
43 | public void onError(Throwable t) {
44 | if (!NetworkHelper.isNetworkAvailable(context)) {
45 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
46 | } else {
47 | ApiException.handleException(context, t);
48 | ToastUtils.showToast(context, t.getMessage());
49 | }
50 | stateView.showRetry();
51 | dispose();
52 | }
53 |
54 | @Override
55 | public void onComplete() {
56 | dispose();
57 | }
58 | /**
59 | * 加载成功
60 | *
61 | * @return
62 | */
63 | public abstract void onSuccess(T t);
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_pop_todo_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
25 |
26 |
34 |
35 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/util/keyboard/SimpleUnregistrar.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.util.keyboard;
2 |
3 | import android.app.Activity;
4 | import android.os.Build;
5 | import android.view.View;
6 | import android.view.ViewTreeObserver;
7 |
8 | import java.lang.ref.WeakReference;
9 |
10 | /**
11 | * @author Anoop S S
12 | * anoopvvs@gmail.com
13 | * on 28/02/2017
14 | */
15 |
16 | public class SimpleUnregistrar implements Unregistrar {
17 |
18 | private WeakReference mActivityWeakReference;
19 |
20 | private WeakReference mOnGlobalLayoutListenerWeakReference;
21 |
22 | SimpleUnregistrar(Activity activity, ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener) {
23 | mActivityWeakReference = new WeakReference<>(activity);
24 | mOnGlobalLayoutListenerWeakReference = new WeakReference<>(globalLayoutListener);
25 | }
26 |
27 | @Override
28 | public void unregister() {
29 | Activity activity = mActivityWeakReference.get();
30 | ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener = mOnGlobalLayoutListenerWeakReference.get();
31 |
32 | if (null != activity && null != globalLayoutListener) {
33 | View activityRoot = KeyboardVisibilityEvent.getActivityRoot(activity);
34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
35 | activityRoot.getViewTreeObserver()
36 | .removeOnGlobalLayoutListener(globalLayoutListener);
37 | } else {
38 | activityRoot.getViewTreeObserver()
39 | .removeGlobalOnLayoutListener(globalLayoutListener);
40 | }
41 | }
42 |
43 | mActivityWeakReference.clear();
44 | mOnGlobalLayoutListenerWeakReference.clear();
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/util/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.util;
2 |
3 |
4 | /**
5 | *
6 | * @author Rick
7 | * @date 2018/6/5
8 | */
9 |
10 | public class LogUtil {
11 | private static String tag = "rick";
12 | private static boolean log = true;
13 |
14 | public static void setTag(String tag) {
15 | LogUtil.tag = tag;
16 | }
17 |
18 | public static void setLog(boolean log) {
19 | LogUtil.log = log;
20 | }
21 |
22 | public static void i(String msg) {
23 | if (log) {
24 | android.util.Log.i(tag, msg);
25 | }
26 | }
27 |
28 | public static void i(String tag, String msg) {
29 | if (log) {
30 | android.util.Log.i(tag, msg);
31 | }
32 | }
33 |
34 | public static void d(String msg) {
35 | if (log) {
36 | android.util.Log.d(tag, msg);
37 | }
38 | }
39 |
40 | public static void d(String tag, String msg) {
41 | if (log) {
42 | android.util.Log.d(tag, msg);
43 | }
44 | }
45 |
46 | public static void w(String msg) {
47 | if (log) {
48 | android.util.Log.w(tag, msg);
49 | }
50 | }
51 |
52 | public static void w(String tag, String msg) {
53 | if (log) {
54 | android.util.Log.w(tag, msg);
55 | }
56 | }
57 |
58 | public static void v(String msg) {
59 | if (log) {
60 | android.util.Log.v(tag, msg);
61 | }
62 | }
63 |
64 | public static void v(String tag, String msg) {
65 | if (log) {
66 | android.util.Log.v(tag, msg);
67 | }
68 | }
69 |
70 | public static void e(String msg) {
71 | android.util.Log.e(tag, msg);
72 | }
73 |
74 | public static void e(String tag, String msg) {
75 | android.util.Log.e(tag, msg);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/ApiSubscriberObserver.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 | import android.os.SystemClock;
5 |
6 | import com.gank.chen.http.exception.ApiException;
7 | import com.gank.chen.util.NetworkHelper;
8 | import com.gank.chen.util.ToastUtils;
9 | import com.gank.chen.widget.StateView;
10 |
11 | import io.reactivex.Observer;
12 | import io.reactivex.disposables.Disposable;
13 |
14 | /**
15 | * @author chen
16 | * @date 2017/12/17
17 | */
18 |
19 | public abstract class ApiSubscriberObserver implements Observer {
20 | private Context context;
21 | private StateView stateView;
22 | private Disposable disposable;
23 |
24 | public ApiSubscriberObserver(Context context, StateView stateView) {
25 | this.context = context;
26 | this.stateView = stateView;
27 | }
28 |
29 | @Override
30 | public void onSubscribe(Disposable d) {
31 | disposable = d;
32 | stateView.showLoading();
33 | }
34 |
35 | @Override
36 | public void onNext(T t) {
37 | if (t == null) {
38 | stateView.showEmpty();
39 | return;
40 | }
41 | stateView.showContent();
42 | onSuccess(t);
43 | }
44 |
45 | @Override
46 | public void onError(Throwable t) {
47 | if (!NetworkHelper.isNetworkAvailable(context)) {
48 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
49 | } else {
50 | ApiException.handleException(context, t);
51 | ToastUtils.showToast(context, t.getMessage());
52 | }
53 | stateView.showRetry();
54 | disposable.dispose();
55 | }
56 |
57 | @Override
58 | public void onComplete() {
59 | disposable.dispose();
60 |
61 | }
62 |
63 | /**
64 | * 加载成功
65 | *
66 | * @return
67 | */
68 | public abstract void onSuccess(T t);
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_todo.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
25 |
26 |
35 |
36 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/util/GlideCircleTransform.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapShader;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 |
9 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
10 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
11 |
12 | /**
13 | *
14 | * @author Rick
15 | * @date 2018/6/5
16 | */
17 |
18 | public class GlideCircleTransform extends BitmapTransformation {
19 | public GlideCircleTransform(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
24 | return circleCrop(pool, toTransform);
25 | }
26 |
27 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
28 | if (source == null) return null;
29 |
30 | int size = Math.min(source.getWidth(), source.getHeight());
31 | int x = (source.getWidth() - size) / 2;
32 | int y = (source.getHeight() - size) / 2;
33 |
34 | // TODO this could be acquired from the pool too
35 | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
36 |
37 | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
38 | if (result == null) {
39 | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
40 | }
41 |
42 | Canvas canvas = new Canvas(result);
43 | Paint paint = new Paint();
44 | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
45 | paint.setAntiAlias(true);
46 | float r = size / 2f;
47 | canvas.drawCircle(r, r, r, paint);
48 | return result;
49 | }
50 |
51 | @Override public String getId() {
52 | return getClass().getName();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/SubscriberFlowableProgress.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 | import com.gank.chen.http.exception.ApiException;
7 | import com.gank.chen.util.NetworkHelper;
8 | import com.gank.chen.util.ToastUtils;
9 |
10 | import io.reactivex.subscribers.DisposableSubscriber;
11 |
12 | /**
13 | * @author chen
14 | * @date 2017/12/17
15 | */
16 |
17 | public abstract class SubscriberFlowableProgress extends DisposableSubscriber {
18 | private Context context;
19 | private MaterialDialog dialog;
20 |
21 | public SubscriberFlowableProgress(Context context) {
22 | this.context = context;
23 | }
24 |
25 |
26 | @Override
27 | protected void onStart() {
28 | super.onStart();
29 | dialog = new MaterialDialog.Builder(context)
30 | .progress(true, 0)
31 | .content("请稍后")
32 | .canceledOnTouchOutside(false)
33 | .cancelable(false)
34 | .show();
35 |
36 |
37 | }
38 |
39 | @Override
40 | public void onNext(T t) {
41 | if (t == null) {
42 | return;
43 | }
44 | onSuccess(t);
45 | }
46 |
47 | @Override
48 | public void onError(Throwable t) {
49 | if (!NetworkHelper.isNetworkAvailable(context)) {
50 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
51 | } else {
52 | ApiException.handleException(context, t);
53 | ToastUtils.showToast(context, t.getMessage());
54 | }
55 | dialog.dismiss();
56 | dispose();
57 | }
58 |
59 | @Override
60 | public void onComplete() {
61 | dialog.dismiss();
62 | dispose();
63 | }
64 |
65 | /**
66 | * 加载成功
67 | *
68 | * @return
69 | */
70 | public abstract void onSuccess(T t);
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/ChaptersModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | /**
4 | * Creat by chen on 2018/10/19
5 | * Describe:
6 | */
7 | public class ChaptersModel {
8 | // "children": [],
9 | // "courseId": 13,
10 | // "id": 408,
11 | // "name": "鸿洋",
12 | // "order": 190000,
13 | // "parentChapterId": 407,
14 | // "userControlSetTop": false,
15 | // "visible": 1
16 |
17 | private int id;
18 | private int courseId;
19 | private int order;
20 | private int parentChapterId;
21 | private int visible;
22 | private boolean userControlSetTop;
23 | private String name;
24 |
25 | public int getId() {
26 | return id;
27 | }
28 |
29 | public void setId(int id) {
30 | this.id = id;
31 | }
32 |
33 | public int getCourseId() {
34 | return courseId;
35 | }
36 |
37 | public void setCourseId(int courseId) {
38 | this.courseId = courseId;
39 | }
40 |
41 | public int getOrder() {
42 | return order;
43 | }
44 |
45 | public void setOrder(int order) {
46 | this.order = order;
47 | }
48 |
49 | public int getParentChapterId() {
50 | return parentChapterId;
51 | }
52 |
53 | public void setParentChapterId(int parentChapterId) {
54 | this.parentChapterId = parentChapterId;
55 | }
56 |
57 | public int getVisible() {
58 | return visible;
59 | }
60 |
61 | public void setVisible(int visible) {
62 | this.visible = visible;
63 | }
64 |
65 | public boolean isUserControlSetTop() {
66 | return userControlSetTop;
67 | }
68 |
69 | public void setUserControlSetTop(boolean userControlSetTop) {
70 | this.userControlSetTop = userControlSetTop;
71 | }
72 |
73 | public String getName() {
74 | return name;
75 | }
76 |
77 | public void setName(String name) {
78 | this.name = name;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/widget/behavior/ScaleAnimateHelper.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.widget.behavior;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 | import android.view.animation.Animation;
6 | import android.view.animation.ScaleAnimation;
7 |
8 | /**
9 | * ScaleAnimateHelper using for float button
10 | *
11 | * Created by wing on 11/8/16.
12 | */
13 |
14 | public class ScaleAnimateHelper implements AnimateHelper {
15 |
16 | public View mTarget;
17 | public int mCurrentState = STATE_SHOW;
18 |
19 | private ScaleAnimateHelper(View view) {
20 | mTarget = view;
21 | }
22 |
23 | public static ScaleAnimateHelper get(View view) {
24 | return new ScaleAnimateHelper(view);
25 | }
26 |
27 | @Override public void show() {
28 | ValueAnimator va = ValueAnimator.ofFloat(mTarget.getScaleX(), 1);
29 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
30 | @Override public void onAnimationUpdate(ValueAnimator valueAnimator) {
31 | float scale = (Float) valueAnimator.getAnimatedValue();
32 | mTarget.setScaleX(scale);
33 | mTarget.setScaleY(scale);
34 | }
35 | });
36 | va.setDuration(300);
37 | va.start();
38 |
39 | mCurrentState = STATE_SHOW;
40 | }
41 |
42 | @Override public void hide() {
43 | ValueAnimator va = ValueAnimator.ofFloat(mTarget.getScaleX(), 0);
44 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
45 | @Override public void onAnimationUpdate(ValueAnimator valueAnimator) {
46 | float scale = (Float) valueAnimator.getAnimatedValue();
47 | mTarget.setScaleX(scale);
48 | mTarget.setScaleY(scale);
49 | }
50 | });
51 | va.setDuration(300);
52 | va.start();
53 | mCurrentState = STATE_HIDE;
54 | }
55 |
56 | @Override public void setStartY(float y) {
57 |
58 | }
59 |
60 | @Override public void setMode(int modeBottom) {
61 |
62 | }
63 |
64 | @Override
65 | public int getState() {
66 | return mCurrentState;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/common/RouterUrlManager.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.common;
2 |
3 | /**
4 | * Creat by chen on 2018/10/10
5 | * Describe:
6 | *
7 | * @author chenbo
8 | */
9 | public class RouterUrlManager {
10 |
11 | //acitvity
12 |
13 | public static final String LOGIN = "/activity/LoginActivity";
14 | public static final String SETTING = "/activity/SettingActivity";
15 | public static final String TODOLIST_ACTIVITY = "/activity/ToDoListActivity";
16 | public static final String DETAIL = "/activity/DetailActivity";
17 | public static final String MEIZI_DETAIL = "/activity/MeiZiDetailActivity";
18 | public static final String REGISTER = "/activity/RegisterActivity";
19 | public static final String MAIN = "/ui/MainActivity";
20 | public static final String MINE_COLLECTION = "/activity/MineCollectionsActivity";
21 | public static final String ABOUT = "/activity/AboutUsActivity";
22 | public static final String MINE_MESSAGE = "/activity/MineMessageActivity";
23 | public static final String COMMON_WEBSITES = "/activity/CommonWebsitesActivity";
24 | public static final String SEARCH_ACTIVITY = "/activity/SearchActivity";
25 | public static final String QUARY_RESULT= "/activity/QuaryResultActivity";
26 | public static final String ADD_TODO_ACTIVITY= "/activity/AddOneTodoActivity";
27 |
28 |
29 | //fragment
30 |
31 | public static final String CHAPTERSLIST_FRAGMENT = "/fragment/ChaptersListFragment";
32 | public static final String PROJECTLIST_FRAGMENT = "/fragment/ProjectListFragment";
33 | public static final String CHAPTERS_FRAGMENT = "/fragment/ChaptersFragment";
34 | public static final String PROJECT_FRAGMENT = "/fragment/ProjectFragment";
35 | public static final String MAIN_FRAGMENT = "/fragment/MainFragment";
36 | public static final String MEIZI_FRAGMENT = "/fragment/MeiZiFragment";
37 | public static final String NAVIGATION_FRAGMENT = "/fragment/NavigationFragment";
38 | public static final String TODOLIST_FRAGMENT = "/fragment/TodoListFragment";
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/ChaptersListModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | /**
4 | * Creat by chen on 2018/10/22
5 | * Describe:
6 | * @author chenbo
7 | */
8 | public class ChaptersListModel {
9 |
10 | // "children": [],
11 | // "courseId": 13,
12 | // "id": 408,
13 | // "name": "鸿洋",
14 | // "order": 190000,
15 | // "parentChapterId": 407,
16 | // "userControlSetTop": false,
17 | // "visible": 1
18 |
19 | private int courseId;
20 | private int id;
21 | private int order;
22 | private int parentChapterId;
23 | private int visible;
24 | private boolean userControlSetTop;
25 | private String name;
26 |
27 | public int getCourseId() {
28 | return courseId;
29 | }
30 |
31 | public void setCourseId(int courseId) {
32 | this.courseId = courseId;
33 | }
34 |
35 | public int getId() {
36 | return id;
37 | }
38 |
39 | public void setId(int id) {
40 | this.id = id;
41 | }
42 |
43 | public int getOrder() {
44 | return order;
45 | }
46 |
47 | public void setOrder(int order) {
48 | this.order = order;
49 | }
50 |
51 | public int getParentChapterId() {
52 | return parentChapterId;
53 | }
54 |
55 | public void setParentChapterId(int parentChapterId) {
56 | this.parentChapterId = parentChapterId;
57 | }
58 |
59 | public int getVisible() {
60 | return visible;
61 | }
62 |
63 | public void setVisible(int visible) {
64 | this.visible = visible;
65 | }
66 |
67 | public boolean isUserControlSetTop() {
68 | return userControlSetTop;
69 | }
70 |
71 | public void setUserControlSetTop(boolean userControlSetTop) {
72 | this.userControlSetTop = userControlSetTop;
73 | }
74 |
75 | public String getName() {
76 | return name;
77 | }
78 |
79 | public void setName(String name) {
80 | this.name = name;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/http/subscriber/SubscriberObserverProgress.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.http.subscriber;
2 |
3 | import android.content.Context;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 | import com.gank.chen.http.exception.ApiException;
7 | import com.gank.chen.util.NetworkHelper;
8 | import com.gank.chen.util.ToastUtils;
9 |
10 | import io.reactivex.Observer;
11 | import io.reactivex.disposables.Disposable;
12 |
13 | /**
14 | * @author chenbo
15 | */
16 | public abstract class SubscriberObserverProgress implements Observer {
17 | private Context context;
18 | private Disposable disposable;
19 | private MaterialDialog dialog;
20 |
21 | public SubscriberObserverProgress(Context context) {
22 | this.context = context;
23 |
24 | }
25 |
26 |
27 | @Override
28 | public void onError(Throwable t) {
29 | if (!NetworkHelper.isNetworkAvailable(context)) {
30 | ToastUtils.showToast(context, "当前无网络连接,请先设置网络!");
31 | } else {
32 | ApiException.handleException(context, t);
33 | ToastUtils.showToast(context, ApiException.handleException(context, t).getMessage());
34 | }
35 | dialog.dismiss();
36 | disposable.dispose();
37 | }
38 |
39 | @Override
40 | public void onComplete() {
41 | dialog.dismiss();
42 | disposable.dispose();
43 | }
44 |
45 |
46 | @Override
47 | public void onSubscribe(Disposable d) {
48 | disposable = d;
49 | dialog = new MaterialDialog.Builder(context)
50 | .progress(true, 0)
51 | .content("请稍后")
52 | .canceledOnTouchOutside(false)
53 | .cancelable(false)
54 | .show();
55 |
56 | }
57 |
58 | @Override
59 | public void onNext(T t) {
60 | if (t == null) {
61 | return;
62 | }
63 | onSuccess(t);
64 | }
65 |
66 | /**
67 | * 加载成功
68 | *
69 | * @return
70 | */
71 | public abstract void onSuccess(T t);
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/BannerModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | /**
4 | * Creat by chen on 2018/10/17
5 | * Describe:
6 | *
7 | * @author chenbo
8 | */
9 | public class BannerModel {
10 | // "desc": "",
11 | // "id": 18,
12 | // "imagePath": "http://www.wanandroid.com/blogimgs/00f83f1d-3c50-439f-b705-54a49fc3d90d.jpg",
13 | // "isVisible": 1,
14 | // "order": 0,
15 | // "title": "公众号文章列表强势上线",
16 | // "type": 0,
17 | // "url": "http://www.wanandroid.com/wxarticle/list/409/1"
18 | private String desc;
19 | private int id;
20 | private String imagePath;
21 | private int isVisible;
22 | private int order;
23 | private String title;
24 | private int type;
25 | private String url;
26 |
27 | public String getDesc() {
28 | return desc;
29 | }
30 |
31 | public void setDesc(String desc) {
32 | this.desc = desc;
33 | }
34 |
35 | public int getId() {
36 | return id;
37 | }
38 |
39 | public void setId(int id) {
40 | this.id = id;
41 | }
42 |
43 | public String getImagePath() {
44 | return imagePath;
45 | }
46 |
47 | public void setImagePath(String imagePath) {
48 | this.imagePath = imagePath;
49 | }
50 |
51 | public int getIsVisible() {
52 | return isVisible;
53 | }
54 |
55 | public void setIsVisible(int isVisible) {
56 | this.isVisible = isVisible;
57 | }
58 |
59 | public int getOrder() {
60 | return order;
61 | }
62 |
63 | public void setOrder(int order) {
64 | this.order = order;
65 | }
66 |
67 | public String getTitle() {
68 | return title;
69 | }
70 |
71 | public void setTitle(String title) {
72 | this.title = title;
73 | }
74 |
75 | public int getType() {
76 | return type;
77 | }
78 |
79 | public void setType(int type) {
80 | this.type = type;
81 | }
82 |
83 | public String getUrl() {
84 | return url;
85 | }
86 |
87 | public void setUrl(String url) {
88 | this.url = url;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/util/SharePreferenceUtil.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | import com.gank.chen.common.MyApplication;
8 |
9 | /**
10 | * @author Rick
11 | * @date 2018/6/5
12 | */
13 |
14 | public class SharePreferenceUtil {
15 | private static final String NAME = "Gank";
16 | private static Context context = MyApplication.getmContext();
17 | private static SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
18 |
19 |
20 | public static String getString(String key, String defaultValue) {
21 | return sp.getString(key, defaultValue);
22 | }
23 |
24 | public static void setString(String key, String value) {
25 | sp.edit().putString(key, value).apply();
26 | }
27 |
28 | public static boolean getBoolean(String key, boolean defaultValue) {
29 | return sp.getBoolean(key, defaultValue);
30 | }
31 |
32 | public static boolean hasKey(String key) {
33 | return sp.contains(key);
34 | }
35 |
36 | public static void setBoolean(String key, boolean value) {
37 | sp.edit().putBoolean(key, value).apply();
38 | }
39 |
40 | public static void setInt(String key, int value) {
41 | sp.edit().putInt(key, value).apply();
42 | }
43 |
44 | public static int getInt(String key, int defaultValue) {
45 | return sp.getInt(key, defaultValue);
46 | }
47 |
48 | public static void setFloat(String key, float value) {
49 | sp.edit().putFloat(key, value).apply();
50 | }
51 |
52 | public static float getFloat(String key, float defaultValue) {
53 | return sp.getFloat(key, defaultValue);
54 | }
55 |
56 | public static void setLong(String key, long value) {
57 | sp.edit().putLong(key, value).apply();
58 | }
59 |
60 | public static long getLong(String key, long defaultValue) {
61 | return sp.getLong(key, defaultValue);
62 | }
63 |
64 | public static void clear() {
65 | if (sp != null) {
66 | sp.edit().clear().apply();
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/mvp/model/RegisterModel.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.mvp.model;
2 |
3 | /**
4 | * Creat by chen on 2018/10/18
5 | * Describe:
6 | * @author chenbo
7 | */
8 | public class RegisterModel {
9 | // "chapterTops": [],
10 | // "collectIds": [],
11 | // "email": "",
12 | // "icon": "",
13 | // "id": 11772,
14 | // "password": "123456",
15 | // "token": "",
16 | // "type": 0,
17 | // "username": "13391999591"
18 |
19 | private String username;
20 | private String token;
21 | private int type;
22 | private String password;
23 | private String passwordNative;
24 | private int id;
25 | private String icon;
26 | private String email;
27 |
28 | public String getPasswordNative() {
29 | return passwordNative;
30 | }
31 |
32 | public void setPasswordNative(String passwordNative) {
33 | this.passwordNative = passwordNative;
34 | }
35 |
36 | public String getUsername() {
37 | return username;
38 | }
39 |
40 | public void setUsername(String username) {
41 | this.username = username;
42 | }
43 |
44 | public String getToken() {
45 | return token;
46 | }
47 |
48 | public void setToken(String token) {
49 | this.token = token;
50 | }
51 |
52 | public int getType() {
53 | return type;
54 | }
55 |
56 | public void setType(int type) {
57 | this.type = type;
58 | }
59 |
60 | public String getPassword() {
61 | return password;
62 | }
63 |
64 | public void setPassword(String password) {
65 | this.password = password;
66 | }
67 |
68 | public int getId() {
69 | return id;
70 | }
71 |
72 | public void setId(int id) {
73 | this.id = id;
74 | }
75 |
76 | public String getIcon() {
77 | return icon;
78 | }
79 |
80 | public void setIcon(String icon) {
81 | this.icon = icon;
82 | }
83 |
84 | public String getEmail() {
85 | return email;
86 | }
87 |
88 | public void setEmail(String email) {
89 | this.email = email;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_mine.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
25 |
26 |
34 |
35 |
36 |
37 |
45 |
46 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gank/chen/adapter/NavigationAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gank.chen.adapter;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | import com.chad.library.adapter.base.BaseQuickAdapter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 | import com.gank.chen.R;
10 | import com.gank.chen.common.RouterUrlManager;
11 | import com.gank.chen.mvp.model.ArticleListModel;
12 | import com.gank.chen.mvp.model.CommonWebsiteModel;
13 | import com.gank.chen.mvp.model.NavigationModel;
14 | import com.gank.chen.util.CommenUtil;
15 | import com.gank.chen.util.RouterUtil;
16 | import com.google.android.flexbox.FlexDirection;
17 | import com.google.android.flexbox.FlexboxLayoutManager;
18 | import com.google.android.flexbox.JustifyContent;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * @author chenbo
24 | */
25 | public class NavigationAdapter extends BaseQuickAdapter {
26 |
27 |
28 | public NavigationAdapter(List data) {
29 | super(R.layout.item_navigation, data);
30 | }
31 |
32 | @Override
33 | protected void convert(BaseViewHolder helper, NavigationModel item) {
34 | RecyclerView recyclerView = helper.getView(R.id.rv_item_navigation);
35 | List articles = item.getArticles();
36 | helper.setText(R.id.tv_item_navigation, item.getName());
37 |
38 | FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(mContext);
39 | layoutManager.setFlexDirection(FlexDirection.ROW);
40 | layoutManager.setJustifyContent(JustifyContent.FLEX_START);
41 |
42 | recyclerView.setLayoutManager(layoutManager);
43 |
44 | NavigationItemAdapter navigationItemAdapter = new NavigationItemAdapter(articles);
45 | navigationItemAdapter.setNewData(articles);
46 | navigationItemAdapter.setOnItemClickListener(new OnItemClickListener() {
47 | @Override
48 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
49 | List articles = (List) adapter.getData();
50 | Bundle bundle = new Bundle();
51 | bundle.putString("weburl", articles.get(position).getLink());
52 | bundle.putString("title", articles.get(position).getTitle());
53 | RouterUtil.goToActivity(RouterUrlManager.DETAIL, bundle);
54 | }
55 | });
56 | recyclerView.setAdapter(navigationItemAdapter);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------