11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_email.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_gank.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_ok_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_issues.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_issues_white.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_close_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_webview.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_cancel_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gank_item_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_profile.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tb_munion_aditem.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_girl_detail.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_brower.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_web.xml:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_describe.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/umeng_update_string.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 未联网
4 | 发现新版本
5 | 最新版本:
6 | 更新内容
7 | 仅需要下载:
8 | 新版本大小:
9 | (提示:非WIFI环境)
10 | 立即更新
11 | 应用更新
12 | 以后再说
13 | 忽略该版
14 | 正在更新中....
15 | 最新版本已下载,是否安装?
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_bug.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/model_toolbar.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 16dp
7 | 8dp
8 |
9 | 10dp
10 | 14dp
11 | 16dp
12 | 24dp
13 | 60dp
14 | 72dp
15 |
16 | 14dp
17 | 16dp
18 | 24dp
19 | 16dp
20 |
21 | 96dp
22 | 18
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
24 |
--------------------------------------------------------------------------------
/GankDaily.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/umeng_update_string.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Please make sure you are connected to internet,update failed
5 | New version found
6 | Latest version:
7 | Update Content
8 | Update size:
9 | Target size:
10 | (Warning: Not WIFI Condition)
11 | Update now
12 | App updating
13 | Not now
14 | Ingore this
15 | Updating....
16 | The lastest version has been downloaded, install now ?
17 | 2.6.0.1.20150312
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/core/GankCategory.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.core;
21 |
22 | public enum GankCategory {
23 | 福利,
24 | iOS,
25 | Android,
26 | App,
27 | 拓展资源,
28 | 瞎推荐,
29 | 休息视频;
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_github.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/beta/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/BaseData.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data;
21 |
22 | /**
23 | * Created by GuDong on 9/28/15.
24 | * Contact with gudong.name@gmail.com
25 | */
26 | public class BaseData {
27 | public boolean error;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/ICustomDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | /**
23 | * Created by GuDong on 11/6/15 15:59.
24 | * Contact with gudong.name@gmail.com.
25 | */
26 | public interface ICustomDialog extends IBaseView {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/IBaseView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | /**
23 | * 所有项目View的基类 恩,目前是这么想的
24 | * Created by GuDong on 10/29/15 14:23.
25 | * Contact with gudong.name@gmail.com.
26 | */
27 | public interface IBaseView {
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/umeng_common_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 正在下载中...
4 | 下载出错啦,请检查网络后继续。
5 | 暂停
6 | 继续
7 | 取消
8 | 正在下载:
9 | 暂停:
10 | 正在下载应用
11 | 正在更新安装包
12 | 请连接网络后再尝试!
13 | 下载失败
14 | 下载完成,请点击安装
15 | 更新完成,请点击安装
16 | 新版本已经准备好,请点击安装
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/entity/Soul.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data.entity;
21 |
22 | /**
23 | * Created by GuDong on 15/10/8.
24 | * Contact with gudong.name@gmail.com
25 | */
26 | public class Soul {
27 | protected long id;
28 | public String objectId;
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/IWebView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | /**
23 | * Created by GuDong on 11/2/15 17:04.
24 | * Contact with gudong.name@gmail.com.
25 | */
26 | public interface IWebView extends ISwipeRefreshView {
27 | void showLoadErrorMessage(String message);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/assets/about_gank_site.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
23 |
24 |
25 |
26 |
44 | 关于GankDaily
45 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # if you want build a release type,please set value
21 |
22 |
23 | SIGN_FILE=/Users/mao/Documents/private/key/gudong.jks
24 | SIGN_KEYSTORE_PASS=228560
25 | SIGN_KEYSTORE_ALIAS=desert
26 | SIGN_KEYSTORE_ALIAS_PASS=228560
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/RestData.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data;
21 |
22 | import com.gudong.gankio.data.entity.Gank;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Created by GuDong on 15/10/8.
28 | * Contact with gudong.name@gmail.com
29 | */
30 | public class RestData extends BaseData {
31 | public Listresults;
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/IGirlFaceView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | /**
23 | * Created by GuDong on 11/2/15 18:21.
24 | * Contact with gudong.name@gmail.com.
25 | */
26 | public interface IGirlFaceView extends IBaseView {
27 |
28 | void saveSuccess(String message);
29 | void showFailInfo(String error);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/PrettyGirlData.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data;
21 |
22 | import com.gudong.gankio.data.entity.Girl;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * 妹子数据集合对象
28 | * Created by GuDong on 9/28/15.
29 | * Contact with gudong.name@gmail.com
30 | */
31 | public class PrettyGirlData extends BaseData {
32 | public Listresults;
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_view_list.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
14 |
15 |
21 |
22 |
26 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/ISwipeRefreshView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | /**
23 | * if you implement ISwipeRefreshView , you view should be a list view
24 | * Created by GuDong on 10/29/15 18:08.
25 | * Contact with gudong.name@gmail.com.
26 | */
27 | public interface ISwipeRefreshView extends IBaseView {
28 |
29 |
30 | void getDataFinish();
31 |
32 | void showEmptyView();
33 |
34 | void showErrorView(Throwable throwable);
35 |
36 | void showRefresh();
37 |
38 | void hideRefresh();
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/umeng_common_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | The app is already in downloading list.
4 | dowload interrupted.
5 | Pause
6 | Continue
7 | Cancel
8 | Downloading:
9 | Pause:
10 | Download start.
11 | Patch start.
12 | Please make sure you are connected to internet, download failed
13 | Download Failed!
14 | Download finished,click to install it.
15 | Patch finished,click to install it.
16 | New version is ready,click to install it.
17 | icon
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/TaskUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import android.os.AsyncTask;
23 | import android.os.Build;
24 |
25 | /**
26 | * Created by drak11t on 8/16/14.
27 | */
28 | public class TaskUtils {
29 |
30 | @SafeVarargs public static void executeAsyncTask(
31 | AsyncTask task, Params... params) {
32 | if (Build.VERSION.SDK_INT >= 11) {
33 | task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
34 | }
35 | else {
36 | task.execute(params);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/core/MainFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.core;
21 |
22 | /**
23 | * Created by GuDong on 15/10/8.
24 | * Contact with gudong.name@gmail.com
25 | */
26 | public class MainFactory {
27 | /**
28 | * 数据主机地址
29 | */
30 | public static final String HOST = "http://gank.io/api";
31 |
32 | private static GuDong mGuDong;
33 |
34 | protected static final Object monitor = new Object();
35 |
36 | public static GuDong getGuDongInstance(){
37 | synchronized (monitor){
38 | if(mGuDong==null){
39 | mGuDong = new MainRetrofit().getService();
40 | }
41 | return mGuDong;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/IViewListView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | import com.gudong.gankio.data.entity.Soul;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * index view
28 | * Created by GuDong on 10/29/15 14:10.
29 | * Contact with gudong.name@gmail.com.
30 | */
31 | public interface IViewListView extends ISwipeRefreshView{
32 | /**
33 | * load data successfully
34 | * @param data
35 | */
36 | void fillData(List data);
37 |
38 | /**
39 | * append data to history list(load more)
40 | * @param data
41 | */
42 | void appendMoreDataToView(List data);
43 |
44 | /**
45 | * no more data
46 | */
47 | void hasNoMoreData();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/GankApp.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio;
21 |
22 | import android.app.Application;
23 | import android.content.Context;
24 |
25 | import com.orhanobut.logger.LogLevel;
26 | import com.orhanobut.logger.Logger;
27 |
28 | /**
29 | * Created by GuDong on 10/14/15 23:42.
30 | * Contact with gudong.name@gmail.com.
31 | */
32 | public class GankApp extends Application {
33 | public static Context sContext;
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 | sContext = this;
38 | //只有调试模式下 才启用日志输出
39 | if(BuildConfig.DEBUG){
40 | Logger.init("Gank").hideThreadInfo().setMethodCount(0);
41 | }else{
42 | Logger.init("Gank").setLogLevel(LogLevel.NONE);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/presenter/BasePresenter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.presenter;
21 |
22 | import android.app.Activity;
23 |
24 | import com.gudong.gankio.core.GuDong;
25 | import com.gudong.gankio.core.MainFactory;
26 | import com.gudong.gankio.ui.view.IBaseView;
27 |
28 | /**
29 | * Created by GuDong on 10/29/15 14:08.
30 | * Contact with gudong.name@gmail.com.
31 | */
32 | public class BasePresenter {
33 |
34 | protected GV mView;
35 | /**
36 | * TODO 这里用是否用Activity待考证
37 | */
38 | protected Activity mContext;
39 |
40 | public static final GuDong mGuDong = MainFactory.getGuDongInstance();
41 |
42 | public BasePresenter(Activity context, GV view) {
43 | mContext = context;
44 | mView = view;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gank_item_girl.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
25 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/assets/about_gank_app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
23 |
28 |
29 |
30 |
31 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/entity/Girl.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data.entity;
21 |
22 |
23 | import java.util.Date;
24 |
25 | /**
26 | * Created by GuDong on 15/10/8.
27 | * Contact with gudong.name@gmail.com
28 | */
29 | public class Girl extends Soul {
30 |
31 | /**
32 | * createdAt : 2015-10-07T05:42:23.910Z
33 | * publishedAt : 2015-10-08T01:29:48.812Z
34 | * used : true
35 | * type : 福利
36 | * url : http://ww4.sinaimg.cn/large/7a8aed7bgw1ewsip9thfoj20hs0qo774.jpg
37 | * who : 张涵宇
38 | * desc : 10.8
39 | * updatedAt : 2015-10-08T01:29:49.400Z
40 | */
41 |
42 | public boolean used;
43 | public String type;
44 | public String url;
45 | public String who;
46 | public String desc;
47 | public Date createdAt;
48 | public Date publishedAt;
49 | public Date updatedAt;
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/core/GuDong.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.core;
21 |
22 | import com.gudong.gankio.data.GankData;
23 | import com.gudong.gankio.data.PrettyGirlData;
24 | import com.gudong.gankio.data.RestData;
25 |
26 | import retrofit.http.GET;
27 | import retrofit.http.Path;
28 | import rx.Observable;
29 |
30 | /**
31 | * Created by GuDong on 9/27/15.
32 | * Contact with gudong.name@gmail.com
33 | */
34 | public interface GuDong {
35 |
36 | @GET("/data/福利/{pagesize}/{page}")
37 | Observable getPrettyGirlData(@Path("pagesize") int pagesize,@Path("page") int page);
38 |
39 | @GET("/data/休息视频/{pagesize}/{page}")
40 | Observable get休息视频Data(@Path("pagesize") int pagesize, @Path("page")int page);
41 |
42 | @GET("/day/{year}/{month}/{day}")
43 | Observable getGankData(@Path("year")int year,@Path("month")int month,@Path("day")int day);
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/GankData.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data;
21 |
22 | import com.gudong.gankio.data.entity.Gank;
23 | import com.google.gson.annotations.SerializedName;
24 |
25 | import java.util.List;
26 |
27 | /**
28 | * Created by GuDong on 10/9/15 22:20.
29 | * Contact with gudong.name@gmail.com.
30 | */
31 | public class GankData extends BaseData {
32 |
33 | public List category;
34 | public Result results;
35 |
36 | public class Result {
37 | @SerializedName("Android") public List androidList;
38 | @SerializedName("休息视频") public List 休息视频List;
39 | @SerializedName("iOS") public List iOSList;
40 | @SerializedName("福利") public List 妹纸List;
41 | @SerializedName("拓展资源") public List 拓展资源List;
42 | @SerializedName("瞎推荐") public List 瞎推荐List;
43 | @SerializedName("App") public List appList;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_check_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
10 |
13 |
16 |
17 |
20 |
23 |
24 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/StringStyleUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import android.content.Context;
23 | import android.text.SpannableString;
24 | import android.text.SpannableStringBuilder;
25 | import android.text.style.TextAppearanceSpan;
26 |
27 | import com.gudong.gankio.R;
28 | import com.gudong.gankio.data.entity.Gank;
29 |
30 | public class StringStyleUtils {
31 |
32 | public static SpannableString format(Context context, String text, int style) {
33 | SpannableString spannableString = new SpannableString(text);
34 | spannableString.setSpan(new TextAppearanceSpan(context, style), 0, text.length(), 0);
35 | return spannableString;
36 | }
37 |
38 | public static CharSequence getGankInfoSequence(Context context,Gank mGank) {
39 | SpannableStringBuilder builder = new SpannableStringBuilder(mGank.desc).append(
40 | StringStyleUtils.format(context, " (via. " + mGank.who + ")", R.style.ViaTextAppearance));
41 | return builder.subSequence(0, builder.length());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/view/IMainView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.view;
21 |
22 | import com.gudong.gankio.data.entity.Soul;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Created by GuDong on 11/2/15 14:39.
28 | * Contact with gudong.name@gmail.com.
29 | */
30 | public interface IMainView extends ISwipeRefreshView {
31 | /**
32 | * load data successfully
33 | * @param data
34 | */
35 | void fillData(List data);
36 |
37 | /**
38 | * append data to history list(load more)
39 | * @param data
40 | */
41 | void appendMoreDataToView(List data);
42 |
43 | /**
44 | * no more data for show and this condition is hard to appear,it need you scroll main view long time
45 | * I think it has no body do it like this ,even though,I deal this condition also, In case someone does it.
46 | */
47 | void hasNoMoreData();
48 |
49 | /**
50 | * show change log info in a dialog
51 | * @param assetFileName the name of local html file like "changelog.html"
52 | */
53 | void showChangeLogInfo(String assetFileName);
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gank_item_normal.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
26 |
27 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/index_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
17 |
23 |
24 |
25 |
34 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/core/MainRetrofit.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.core;
21 |
22 | import com.google.gson.Gson;
23 | import com.google.gson.GsonBuilder;
24 | import com.squareup.okhttp.OkHttpClient;
25 |
26 | import java.util.concurrent.TimeUnit;
27 |
28 | import retrofit.RestAdapter;
29 | import retrofit.client.OkClient;
30 | import retrofit.converter.GsonConverter;
31 |
32 | /**
33 | * Created by GuDong on 15/10/8.
34 | * Contact with gudong.name@gmail.com
35 | */
36 | public class MainRetrofit {
37 |
38 | final GuDong mService;
39 |
40 | final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").serializeNulls().create();
41 |
42 | MainRetrofit() {
43 | OkHttpClient client = new OkHttpClient();
44 | client.setReadTimeout(21, TimeUnit.SECONDS);
45 | RestAdapter restAdapter = new RestAdapter.Builder()
46 | .setClient(new OkClient(client))
47 | .setEndpoint(MainFactory.HOST)
48 | .setConverter(new GsonConverter(gson))
49 | .setLogLevel(RestAdapter.LogLevel.FULL)
50 | .build();
51 | mService = restAdapter.create(GuDong.class);
52 | }
53 |
54 | public GuDong getService(){
55 | return mService;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/DateUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import java.text.DateFormat;
23 | import java.text.SimpleDateFormat;
24 | import java.util.Calendar;
25 | import java.util.Date;
26 |
27 | /**
28 | * Created by GuDong on 10/9/15 22:06.
29 | * Contact with gudong.name@gmail.com.
30 | */
31 | public class DateUtil {
32 |
33 | public static String toDate(Date date) {
34 | DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
35 | return dateFormat.format(date);
36 | }
37 |
38 | public static String toDate(Date date, int add) {
39 | Calendar calendar = Calendar.getInstance();
40 | calendar.setTime(date);
41 | calendar.add(Calendar.DATE, add);
42 | return toDate(calendar.getTime());
43 | }
44 |
45 | public static Date getLastdayDate(Date date) {
46 | Calendar calendar = Calendar.getInstance();
47 | calendar.setTime(date);
48 | calendar.add(Calendar.DATE, -1);
49 | return calendar.getTime();
50 | }
51 |
52 | public static Date getNextdayDate(Date date) {
53 | Calendar calendar = Calendar.getInstance();
54 | calendar.setTime(date);
55 | calendar.add(Calendar.DATE, 1);
56 | return calendar.getTime();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tb_munion_adview.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
12 |
13 |
20 |
21 |
24 |
25 |
32 |
33 |
39 |
40 |
47 |
48 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/DialogUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import android.content.Context;
23 | import android.support.v4.app.FragmentManager;
24 | import android.support.v7.app.AlertDialog;
25 |
26 | import com.gudong.gankio.R;
27 | import com.gudong.gankio.presenter.CustomDialogPresenter;
28 |
29 |
30 | /**
31 | * tool for dialog
32 | * Created by mao on 7/19/15.
33 | */
34 | public class DialogUtil {
35 | /**
36 | * show a dialog which it contain one point message only
37 | * @param context context
38 | */
39 | public static void showSinglePointDialog(Context context, String message){
40 | new AlertDialog.Builder(context)
41 | .setTitle(R.string.title_point)
42 | .setMessage(message)
43 | .setPositiveButton(R.string.dialog_confirm, null)
44 | .show();
45 | }
46 |
47 |
48 | /**
49 | * show a custom dialog use a local html file
50 | * @param context
51 | * @param fragmentManager
52 | * @param dialogTitle title
53 | * @param htmlFileName file name
54 | * @param tag
55 | */
56 | public static void showCustomDialog(Context context, FragmentManager fragmentManager, String dialogTitle, String htmlFileName, String tag) {
57 | int accentColor = AndroidUtils.getAccentColor(context);
58 | CustomDialogPresenter.create(dialogTitle, htmlFileName, accentColor)
59 | .show(fragmentManager, tag);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/data/entity/Gank.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.data.entity;
21 |
22 | import com.gudong.gankio.core.GankCategory;
23 |
24 | import java.io.Serializable;
25 | import java.util.Date;
26 |
27 | /**
28 | * Created by GuDong on 15/10/8.
29 | * Contact with gudong.name@gmail.com
30 | */
31 | public class Gank extends Soul implements Cloneable,Serializable{
32 |
33 | /**
34 | * createdAt : 2015-10-06T08:23:35.565Z
35 | * publishedAt : 2015-10-08T01:29:48.811Z
36 | * used : true
37 | * type : 休息视频
38 | * url : http://v.youku.com/v_show/id_XMTY4OTE3OTQ4.html
39 | * who : lxxself
40 | * desc : 耐克还有这广告,我良辰服气
41 | * updatedAt : 2015-10-08T01:29:49.219Z
42 | */
43 |
44 | public boolean used;
45 | public String type;
46 | public String url;
47 | public String who;
48 | public String desc;
49 | public Date updatedAt;
50 | public Date createdAt;
51 | public Date publishedAt;
52 |
53 | /**
54 | * this item is header type of gank or not,if true, this item will show category name
55 | */
56 | public boolean isHeader;
57 |
58 | public boolean is妹子(){
59 | return type.equals(GankCategory.福利.name());
60 | }
61 |
62 | @Override
63 | public Gank clone() {
64 | Gank gank = null;
65 | try{
66 | gank = (Gank)super.clone();
67 | }catch(CloneNotSupportedException e) {
68 | e.printStackTrace();
69 | }
70 | return gank;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
17 |
18 |
19 |
22 |
25 |
28 |
29 |
32 |
33 |
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
47 |
48 |
51 |
52 |
55 |
56 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/widget/RatioImageView.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.widget;
21 |
22 | import android.content.Context;
23 | import android.util.AttributeSet;
24 | import android.widget.ImageView;
25 |
26 | /**
27 | * Created by GuDong on 10/29/15 21:05.
28 | * Contact with gudong.name@gmail.com.
29 | */
30 | public class RatioImageView extends ImageView {
31 | private int originalWidth;
32 | private int originalHeight;
33 |
34 |
35 | private int measureWidth;
36 | private int measureHeight;
37 |
38 | public RatioImageView(Context context) {
39 | this(context, null);
40 | }
41 |
42 | public RatioImageView(Context context, AttributeSet attrs) {
43 | this(context, attrs, 0);
44 | }
45 |
46 | public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
47 | super(context, attrs, defStyleAttr);
48 | initView();
49 | }
50 |
51 | private void initView() {
52 | }
53 |
54 | public void setOriginalSize(int originalWidth, int originalHeight) {
55 | this.originalWidth = originalWidth;
56 | this.originalHeight = originalHeight;
57 | }
58 |
59 |
60 | @Override
61 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
62 | if(originalHeight>0 && originalWidth>0){
63 | float radio = (float)originalWidth/(float)originalHeight;
64 |
65 | measureWidth = MeasureSpec.getSize(widthMeasureSpec);
66 | measureHeight = MeasureSpec.getSize(heightMeasureSpec);
67 |
68 | if(measureWidth>0){
69 | measureHeight = (int) ((float)measureWidth/radio);
70 | }
71 | setMeasuredDimension(measureWidth,measureHeight);
72 | }else{
73 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/ToastUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import android.content.Context;
23 | import android.widget.Toast;
24 |
25 | import com.gudong.gankio.GankApp;
26 |
27 | /**
28 | * Created by drakeet on 9/27/14.
29 | */
30 | public class ToastUtils {
31 |
32 | Context mContext;
33 |
34 | private ToastUtils() {
35 | }
36 |
37 | private static void show(Context context, int resId, int duration) {
38 | Toast.makeText(context, resId, duration).show();
39 | }
40 |
41 | private static void show(Context context, String message, int duration) {
42 | Toast.makeText(context, message, duration).show();
43 | }
44 |
45 | public static void showShort(int resId) {
46 | Toast.makeText(GankApp.sContext, resId, Toast.LENGTH_SHORT).show();
47 | }
48 |
49 | public static void showShort(String message) {
50 | Toast.makeText(GankApp.sContext, message, Toast.LENGTH_SHORT).show();
51 | }
52 |
53 | public static void showLong(int resId) {
54 | Toast.makeText(GankApp.sContext, resId, Toast.LENGTH_LONG).show();
55 | }
56 |
57 | public static void showLong(String message) {
58 | Toast.makeText(GankApp.sContext, message, Toast.LENGTH_LONG).show();
59 | }
60 |
61 | public static void showLongLong(String message) {
62 | showLong(message);
63 | showLong(message);
64 | }
65 |
66 | public static void showLongLong(int resId) {
67 | showLong(resId);
68 | showLong(resId);
69 | }
70 |
71 | public static void showLongLongLong(int resId) {
72 | showLong(resId);
73 | showLong(resId);
74 | showShort(resId);
75 | }
76 |
77 | public static void showLongLongLong(String message) {
78 | showLong(message);
79 | showLong(message);
80 | showShort(message);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GankDaily
3 |
4 | Settings
5 | 关于GankDaily
6 | 关于干货集中营
7 | Github Tending
8 | 保存
9 | GirlDetailActivity
10 | 妹子们
11 | WebActivity
12 | 刷新
13 | 分享
14 | 复制链接
15 | 从浏览器打开链接
16 | 复制成功
17 | 打开链接失败
18 | 妹子还没有准备好
19 | 无法加载数据,请检查网络连接。点击可重试。
20 | 妹子见底了,没有更多啦。
21 | 没有更多干货啦(这个提示很难出现哦,看到这个不容易~)
22 | 返回顶部
23 | 图片保存失败,请再次尝试保存!
24 | 图片已保存至 %s 文件夹
25 |
26 | GitHub Trending
27 | Opinion
28 | https://github.com/trending/java
29 | https://github.com/maoruibin/GankDaily/issues
30 |
31 | 提示
32 | 知道了
33 | 确定
34 | 纯 • 妹子
35 | 未知
36 | 更新日志
37 | Version
38 | Rate this app
39 | Report an issue
40 | Having ab issue? Report it here
41 | Author
42 | Fork on Github
43 | Send an email
44 | Social
45 | Twitter
46 | Website
47 | gudong.name@gmail.com
48 | 给 GankDaily 的反馈
49 | Google+
50 | Weibo
51 | Zhihu
52 | Jianshu
53 | Github
54 | 咕咚
55 | 大侠咕咚
56 | maoruibin
57 | Describe
58 |
59 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # GankDaily
2 | 
3 |
4 | 每日提供技术干货的 App
5 |
6 | ## 下载
7 | [fir](http://fir.im/gankdaily)
8 |
9 | [酷安](http://www.coolapk.com/apk/com.gudong.gankio)
10 |
11 |
12 |
13 | ## 干货数据源
14 | 应用中的所有干货数据均来自[干货集中营](http://gank.io/)。
15 |
16 | ` 干货集中营是一个技术干货共享平台。每个工作日,网站都会分享一些技术干货信息,包括Android、iOS、App等技术干货,除此之外还有福利和休息视频可供你享用。
17 | 如果你是移动开发者,这个App一定很适合你。当然,如果你是一个宅男,也许你会对每天的福利更感兴趣。Enjoy it。`
18 |
19 | ## App设计
20 | 整个项目借鉴自 @drakeet 的[妹纸](https://github.com/drakeet/Meizhi)。但是在原项目基础上,
21 | 自己在代码层面和UI层面上做了自己的修改。
22 |
23 | ### UI设计
24 | 放弃使用瀑布式的妹子流做主页,转而让首页展示当天干货信息,更加注重干货内容(Content)的呈现,
25 | 如下所示,相比原妹纸项目,现在首屏只有一张`福利`图,如果觉得看的不过瘾,应用也提供了纯妹子视图入口,点击首页
26 | 右上角按钮,选择纯妹子,就可以看到所有的妹子们了,更加纯粹的妹子流。
27 |
28 | 
29 |
30 | ### 代码设计
31 | 原项目使用 Retrofit+RxJava 的组合获取网络数据,再加上使用Lambda表达式,代码已经变得很精简,所以把获取数据的代码放在 Activity 中也不显得混乱,
32 | 但是作为一个有追求的程序员,既然已经知道有 MVP 这种架构模式可以解决项目分层的问题,
33 | 那为什么不试着使用 MVP 去对代码进行进一步的优化呢,所以整个项目使用了 MVP 架构,将所有的数据请求、业务逻辑都提取到 Presenter 层中。
34 | 使用 MVP 后需要为每一个 Activity 编写一个对应一个 Presenter(控制器)类,让 Activity 担当纯粹的 View 角色,
35 | 这样 Activity 就主要负责一些界面更新操作,具体的业务逻辑都交托给 Presenter 层处理,代码结构因此也变得更加清晰。
36 |
37 | 更多关于项目中对 MVP 模式的实践,这里自己整理了一篇博客进行详细介绍。
38 |
39 | [MVP 模式在 GankDaily 中的应用](http://gudong.name/advanced/2015/11/23/gank_mvp_introduce.html)
40 |
41 | ## 依赖库
42 | * [RxJava](https://github.com/ReactiveX/RxJava)
43 | * [OkHttp](https://github.com/square/okhttp)
44 | * [Picasso](https://github.com/square/picasso)
45 | * [Retrofit](https://github.com/square/retrofit)
46 | * [Butterknife](https://github.com/JakeWharton/butterknife)
47 | * [Logger](https://github.com/orhanobut/logger)
48 |
49 | ## 参考资料
50 | * [drakeet/Meizhi](https://github.com/drakeet/Meizhi)
51 | * [浅谈 MVP in Android](http://blog.csdn.net/lmj623565791/article/details/46596109)
52 | * [Effective Android UI](https://github.com/pedrovgs/EffectiveAndroidUI)
53 |
54 | ## Author
55 | * [http://gudong.name](http://gudong.name)
56 | * [https://github.com/maoruibin](https://github.com/maoruibin)
57 | * [http://weibo.com/maoruibin](http://weibo.com/maoruibin)
58 |
59 | ## License
60 |
61 | /*
62 | *
63 | * Copyright (C) 2015 Drakeet
64 | * Copyright (C) 2015 GuDong
65 | *
66 | * Meizhi is free software: you can redistribute it and/or modify
67 | * it under the terms of the GNU General Public License as published by
68 | * the Free Software Foundation, either version 3 of the License, or
69 | * (at your option) any later version.
70 | *
71 | * Meizhi is distributed in the hope that it will be useful,
72 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
73 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 | * GNU General Public License for more details.
75 | *
76 | * You should have received a copy of the GNU General Public License
77 | * along with Meizhi. If not, see .
78 | */
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/presenter/WebPresenter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.presenter;
21 |
22 | import android.app.Activity;
23 | import android.graphics.Bitmap;
24 | import android.net.Uri;
25 | import android.text.TextUtils;
26 | import android.webkit.WebSettings;
27 | import android.webkit.WebView;
28 | import android.webkit.WebViewClient;
29 |
30 | import com.gudong.gankio.ui.view.IWebView;
31 |
32 | /**
33 | * Created by GuDong on 11/2/15 17:05.
34 | * Contact with gudong.name@gmail.com.
35 | */
36 | public class WebPresenter extends BasePresenter {
37 | public WebPresenter(Activity context, IWebView view) {
38 | super(context, view);
39 | }
40 |
41 | public void setUpWebView(WebView webView){
42 | WebSettings settings = webView.getSettings();
43 | settings.setJavaScriptEnabled(true);
44 | settings.setLoadWithOverviewMode(true);
45 | settings.setAppCacheEnabled(true);
46 | settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
47 | settings.setSupportZoom(true);
48 | webView.setWebViewClient(new LoveClient());
49 | }
50 |
51 | public void loadUrl(WebView webView,String url){
52 | webView.loadUrl(url);
53 | }
54 |
55 | private class LoveClient extends WebViewClient {
56 |
57 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
58 | if (TextUtils.isEmpty(url)){
59 | return true;
60 | }
61 | if(Uri.parse(url).getHost().equals("github.com")){
62 | return false;
63 | }
64 | view.loadUrl(url);
65 | return true;
66 | }
67 |
68 | @Override
69 | public void onPageStarted(WebView view, String url, Bitmap favicon) {
70 | super.onPageStarted(view, url, favicon);
71 | mView.showRefresh();
72 | }
73 |
74 | @Override
75 | public void onPageFinished(WebView view, String url) {
76 | super.onPageFinished(view, url);
77 | mView.hideRefresh();
78 | }
79 |
80 | @Override
81 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
82 | super.onReceivedError(view, errorCode, description, failingUrl);
83 | mView.hideRefresh();
84 | mView.showLoadErrorMessage(description);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/fragment/CustomWebViewDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.fragment;
21 |
22 | import android.app.Dialog;
23 | import android.content.Context;
24 | import android.os.Bundle;
25 | import android.support.annotation.NonNull;
26 | import android.support.v4.app.DialogFragment;
27 | import android.view.InflateException;
28 | import android.view.LayoutInflater;
29 | import android.view.View;
30 | import android.webkit.JavascriptInterface;
31 | import android.webkit.WebView;
32 | import android.widget.Toast;
33 |
34 | import com.gudong.gankio.R;
35 | import com.gudong.gankio.presenter.CustomDialogPresenter;
36 | import com.gudong.gankio.ui.view.ICustomDialog;
37 | import com.gudong.gankio.util.DialogUtil;
38 |
39 | /**
40 | * CustomWebViewDialog
41 | * @author mao
42 | */
43 | public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
44 | private CustomDialogPresenter mPresenter;
45 | private WebView mWebView;
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | mPresenter = new CustomDialogPresenter(getActivity(),this);
50 | }
51 |
52 | @NonNull
53 | @Override
54 | public Dialog onCreateDialog(Bundle savedInstanceState) {
55 | final View customView;
56 | try {
57 | customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
58 | mWebView = (WebView) customView.findViewById(R.id.webview);
59 | mWebView.addJavascriptInterface(new WebAppInterface(customView.getContext()),"Android");
60 | } catch (InflateException e) {
61 | throw new IllegalStateException("This device does not support Web Views.");
62 | }
63 | return mPresenter.makeOkDialog(this,customView);
64 | }
65 |
66 | public class WebAppInterface {
67 | Context mContext;
68 |
69 | /** Instantiate the interface and set the context */
70 | WebAppInterface(Context c) {
71 | mContext = c;
72 | }
73 |
74 | /** Show a toast from the web page */
75 | @JavascriptInterface
76 | public void showToast(String toast) {
77 | Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
78 | }
79 |
80 | /** Show a dialog about app **/
81 | @JavascriptInterface
82 | public void showAbout(){
83 | DialogUtil.showCustomDialog(getActivity(), getFragmentManager(), getString(R.string.action_about), "about_gank_app.html", "app");
84 | }
85 |
86 | /** Show a dialog about gank site **/
87 | @JavascriptInterface
88 | public void showAboutGank(){
89 | DialogUtil.showCustomDialog(getActivity(), getFragmentManager(), getString(R.string.action_about_gank), "about_gank_site.html", "site");
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/activity/BaseSwipeRefreshActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.activity;
21 |
22 | import android.os.Bundle;
23 | import android.support.annotation.CheckResult;
24 | import android.support.v4.widget.SwipeRefreshLayout;
25 |
26 | import com.gudong.gankio.R;
27 | import com.gudong.gankio.presenter.BasePresenter;
28 | import com.gudong.gankio.ui.view.ISwipeRefreshView;
29 |
30 | import butterknife.Bind;
31 |
32 | /**
33 | * base activity for that have a function with swipe refresh
34 | * Created by GuDong on 10/29/15 18:06.
35 | * Contact with gudong.name@gmail.com.
36 | */
37 | public abstract class BaseSwipeRefreshActivity
extends BaseActivity
implements ISwipeRefreshView {
38 |
39 | @Bind(R.id.swipe_refresh_layout)
40 | protected SwipeRefreshLayout mSwipeRefreshLayout;
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | initSwipeLayout();
46 | }
47 |
48 | private void initSwipeLayout(){
49 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark, R.color.colorAccent);
50 | mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
51 | @Override
52 | public void onRefresh() {
53 | if (prepareRefresh()) {
54 | onRefreshStarted();
55 | } else {
56 | //产生一个加载数据的假象
57 | hideRefresh();
58 | }
59 | }
60 | });
61 | }
62 |
63 | /**
64 | * check data status
65 | * @return return true indicate it should load data really else indicate don't refresh
66 | */
67 | protected boolean prepareRefresh(){
68 | return true;
69 | }
70 |
71 | /**
72 | * the method of get data
73 | */
74 | protected abstract void onRefreshStarted();
75 |
76 | @Override
77 | public void hideRefresh() {
78 | // 防止刷新消失太快,让子弹飞一会儿. do not use lambda!!
79 | mSwipeRefreshLayout.postDelayed(new Runnable() {
80 | @Override
81 | public void run() {
82 | if(mSwipeRefreshLayout != null){
83 | mSwipeRefreshLayout.setRefreshing(false);
84 | }
85 | }
86 | },1000);
87 | }
88 |
89 | @Override
90 | public void showRefresh() {
91 | mSwipeRefreshLayout.setRefreshing(true);
92 | }
93 |
94 | /**
95 | * check refresh layout is refreshing
96 | * @return if the refresh layout is refreshing return true else return false
97 | */
98 | @CheckResult
99 | protected boolean isRefreshing(){
100 | return mSwipeRefreshLayout.isRefreshing();
101 | }
102 |
103 | @Override
104 | public void getDataFinish() {
105 | hideRefresh();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.activity;
21 |
22 | import android.os.Bundle;
23 | import android.support.v7.app.AppCompatActivity;
24 | import android.support.v7.widget.Toolbar;
25 | import android.view.Menu;
26 | import android.view.MenuItem;
27 |
28 | import com.gudong.gankio.R;
29 | import com.gudong.gankio.presenter.BasePresenter;
30 | import com.umeng.analytics.MobclickAgent;
31 |
32 | import butterknife.Bind;
33 | import butterknife.ButterKnife;
34 |
35 | /**
36 | * Created by GuDong on 10/14/15 23:05.
37 | * Contact with gudong.name@gmail.com.
38 | */
39 | public abstract class BaseActivity
extends AppCompatActivity {
40 | @Bind(R.id.toolbar)
41 | protected Toolbar mToolbar;
42 | /**
43 | * the presenter of this Activity
44 | */
45 | protected P mPresenter;
46 |
47 | /**
48 | * TODO use Dagger2 instance Presenter
49 | */
50 | protected abstract void initPresenter();
51 |
52 | /**
53 | * set layout of this activity
54 | *
55 | * @return the id of layout
56 | */
57 | protected abstract int getLayout();
58 |
59 | @Override
60 | protected void onCreate(Bundle savedInstanceState) {
61 | super.onCreate(savedInstanceState);
62 | setContentView(getLayout());
63 | ButterKnife.bind(this);
64 | initPresenter();
65 | checkPresenterIsNull();
66 | initToolBar();
67 | }
68 |
69 | @Override
70 | protected void onResume() {
71 | super.onResume();
72 | MobclickAgent.onResume(this);
73 | }
74 |
75 | @Override
76 | protected void onPause() {
77 | super.onPause();
78 | MobclickAgent.onPause(this);
79 | }
80 |
81 | private void checkPresenterIsNull() {
82 | if (mPresenter == null) {
83 | throw new IllegalStateException("please init mPresenter in initPresenter() method ");
84 | }
85 | }
86 |
87 | /**
88 | * set the id of menu
89 | *
90 | * @return if values is less then zero ,and the activity will not show menu
91 | */
92 | protected int getMenuRes() {
93 | return -1;
94 | }
95 |
96 | ;
97 |
98 | @Override
99 | public boolean onCreateOptionsMenu(Menu menu) {
100 | if (getMenuRes() < 0) return true;
101 | getMenuInflater().inflate(getMenuRes(), menu);
102 | return true;
103 | }
104 |
105 | @Override
106 | public boolean onOptionsItemSelected(MenuItem item) {
107 | switch (item.getItemId()) {
108 | case android.R.id.home:
109 | //don't use finish() and use onBackPressed() will be a good practice , trust me !
110 | onBackPressed();
111 | break;
112 | }
113 | return super.onOptionsItemSelected(item);
114 | }
115 |
116 | final private void initToolBar() {
117 | if (mToolbar == null) {
118 | throw new NullPointerException("please add a Toolbar in your layout.");
119 | }
120 | setSupportActionBar(mToolbar);
121 | }
122 |
123 | public void setTitle(String strTitle, boolean showHome) {
124 | setTitle(strTitle);
125 | getSupportActionBar().setDisplayShowHomeEnabled(showHome);
126 | getSupportActionBar().setDisplayHomeAsUpEnabled(showHome);
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/drakeet/Applications/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -dontwarn com.squareup.okhttp.**
20 |
21 | -keep class butterknife.** { *; }
22 | -dontwarn butterknife.internal.**
23 | -keep class **$$ViewBinder { *; }
24 |
25 | -keepclasseswithmembernames class * {
26 | @butterknife.* ;
27 | }
28 |
29 | -keepclasseswithmembernames class * {
30 | @butterknife.* ;
31 | }
32 |
33 | -keepattributes *Annotation*
34 | -keepclassmembers class ** {
35 | @com.squareup.otto.Subscribe public *;
36 | @com.squareup.otto.Produce public *;
37 | }
38 |
39 |
40 | -keep public class com.gudong.gankio.R$*{
41 | public static final int *;
42 | }
43 |
44 | -keep public class com.umeng.fb.ui.ThreadView {}
45 |
46 | -keep class com.gudong.gankio.BuildConfig { *; }
47 | -keep public class * extends android.os.Binder
48 |
49 | # Keep the support library
50 | -keep class android.support.** { *; }
51 | -keep interface android.support.** { *; }
52 |
53 | # For using GSON @Expose annotation
54 | -keepattributes *Annotation*
55 |
56 | -keepattributes EnclosingMethod
57 |
58 | # Gson specific classes
59 | -keep class sun.misc.Unsafe { *; }
60 | -keep class com.google.gson.stream.** { *; }
61 |
62 | -keepclassmembers enum * {
63 | public static **[] values();
64 | public static ** valueOf(java.lang.String);
65 | }
66 |
67 | -keep class * implements android.os.Parcelable {
68 | public static final android.os.Parcelable$Creator *;
69 | }
70 |
71 | -keepattributes Signature
72 | -keep class **.R$* {*;}
73 | -ignorewarnings
74 |
75 | -verbose
76 | -keepclasseswithmembernames class * {
77 | native ;
78 | }
79 |
80 | -keep class com.gudong.gankio.** { *;}
81 |
82 | -keepclasseswithmembernames class * {
83 | native ;
84 | }
85 |
86 | -keep class android.support.v8.renderscript.** { *; }
87 |
88 | # ActiveAndroid
89 | -keep class com.activeandroid.** { *; }
90 | -keep class com.activeandroid.**.** { *; }
91 | -keep class * extends com.activeandroid.Model
92 | -keep class * extends com.activeandroid.serializer.TypeSerializer
93 |
94 |
95 | # Remove logging calls
96 | -assumenosideeffects class android.util.Log {
97 | public static boolean isLoggable(java.lang.String, int);
98 | public static int v(...);
99 | public static int i(...);
100 | public static int w(...);
101 | public static int d(...);
102 | public static int e(...);
103 | }
104 |
105 | # For Guava:
106 | -dontwarn javax.annotation.**
107 | -dontwarn javax.inject.**
108 | -dontwarn sun.misc.Unsafe
109 |
110 | # For RxJava:
111 | -dontwarn org.mockito.**
112 | -dontwarn org.junit.**
113 | -dontwarn org.robolectric.**
114 |
115 |
116 | -keepattributes Signature
117 | -keepattributes *Annotation*
118 | -keep class com.squareup.okhttp.** { *; }
119 | -keep interface com.squareup.okhttp.** { *; }
120 | -dontwarn com.squareup.okhttp.**
121 |
122 | -dontwarn rx.**
123 | -dontwarn retrofit.**
124 | -keep class retrofit.** { *; }
125 | -keepclasseswithmembers class * {
126 | @retrofit.http.* ;
127 | }
128 |
129 | -keep class sun.misc.Unsafe { *; }
130 |
131 | -dontwarn java.lang.invoke.*
132 |
133 | # 使用注解
134 | -keepattributes *Annotation*,Signature
135 |
136 | # 保持混淆时类的实名及行号(——————— 调试时打开 ———————)
137 | -keepattributes SourceFile,LineNumberTable
138 |
139 | # 枚举需要keep see http://proguard.sourceforge.net/manual/examples.html#enumerations
140 | -keepclassmembers enum * {
141 | **[] $VALUES;
142 | public *;
143 | }
144 |
145 | #glide
146 | -keep public class * implements com.bumptech.glide.module.GlideModule
147 | -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
148 | **[] $VALUES;
149 | public *;
150 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout-v9/umeng_common_download_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
27 |
28 |
29 |
35 |
36 |
46 |
47 |
55 |
56 |
66 |
67 |
68 |
78 |
79 |
85 |
86 |
92 |
93 |
94 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/umeng_common_download_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
27 |
28 |
29 |
35 |
36 |
46 |
47 |
55 |
56 |
66 |
67 |
68 |
78 |
79 |
87 |
88 |
95 |
96 |
97 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/util/AndroidUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.util;
21 |
22 | import android.content.ClipData;
23 | import android.content.ClipboardManager;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.SharedPreferences;
27 | import android.content.pm.PackageInfo;
28 | import android.content.res.Resources;
29 | import android.os.Build;
30 | import android.preference.PreferenceManager;
31 | import android.support.v7.widget.Toolbar;
32 | import android.util.TypedValue;
33 | import android.widget.TextView;
34 |
35 | import com.gudong.gankio.R;
36 |
37 | import java.lang.reflect.Field;
38 |
39 | /**
40 | * Created by GuDong on 10/14/15 22:22.
41 | * Contact with gudong.name@gmail.com.
42 | */
43 | public class AndroidUtils {
44 | public static void copyToClipBoard(Context context, String text, String success) {
45 | ClipData clipData = ClipData.newPlainText("meizhi_copy", text);
46 | ClipboardManager manager =
47 | (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
48 | manager.setPrimaryClip(clipData);
49 | ToastUtils.showShort(success);
50 | }
51 |
52 | /**
53 | * get accent color
54 | * @param context
55 | * @return
56 | */
57 | public static int getAccentColor(Context context){
58 | TypedValue typedValue = new TypedValue();
59 | Resources.Theme theme = context.getTheme();
60 | theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
61 | return typedValue.data;
62 | }
63 |
64 | public static boolean isAndroidL(){
65 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
66 | }
67 |
68 | /**
69 | * base on Toolbar get the TitleView by reflect way
70 | * @param obj Toolbar
71 | * @return the title text view in Toolbar
72 | */
73 | public static TextView getTitleViewInToolbar(Toolbar obj){
74 | TextView textView = null;
75 | try {
76 | Field title = obj.getClass().getDeclaredField("mTitleTextView");
77 | title.setAccessible(true);
78 | textView = (TextView) title.get(obj);
79 | } catch (NoSuchFieldException e) {
80 | e.printStackTrace();
81 | } catch (IllegalAccessException e) {
82 | e.printStackTrace();
83 | }
84 | return textView;
85 | }
86 |
87 | /**
88 | * get app version info
89 | * @param context context
90 | * @return app version info if occur exception return unknow
91 | */
92 | public static String getAppVersion(Context context){
93 | try {
94 | PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
95 | return info.versionName;
96 | } catch (Exception e) {
97 | e.printStackTrace();
98 | return context.getString(R.string.unknow);
99 | }
100 | }
101 |
102 | public static void setCurrentVersion(Context context,String version){
103 | putStringPreference(context,"current_version",version);
104 | }
105 |
106 | public static String getLocalVersion(Context context){
107 | return getStringPreference(context, "current_version", "");
108 | }
109 |
110 | public static String getStringPreference(Context context,String key,String def){
111 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
112 | return sp.getString(key, def);
113 | }
114 |
115 | public static void putStringPreference(Context context,String key,String value){
116 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
117 | sp.edit().putString(key, value).apply();
118 | }
119 |
120 | public static void shareText(Context context, String text){
121 | Intent sendIntent = new Intent();
122 | sendIntent.setAction(Intent.ACTION_SEND);
123 | sendIntent.putExtra(Intent.EXTRA_TEXT,text);
124 | sendIntent.setType("text/plain");
125 | context.startActivity(Intent.createChooser(sendIntent, "发送"));
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | def releaseTime() {
4 | return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
5 | }
6 |
7 | android {
8 | compileSdkVersion 25
9 | buildToolsVersion '25.0.2'
10 | defaultConfig {
11 | applicationId "com.gudong.gankio"
12 | //For use TYPE_TOAST
13 | minSdkVersion 19
14 | targetSdkVersion 25
15 | versionCode 9
16 | versionName "1.3"
17 | vectorDrawables.useSupportLibrary = true
18 | }
19 |
20 | signingConfigs {
21 | //指定名叫release的一个签名对象 会在下面的脚本(85行开始)中,动态根据配置文件设置属性
22 | release
23 | }
24 |
25 | buildTypes {
26 | release {
27 | println 'build - release'
28 | //设置是否混淆
29 | minifyEnabled true
30 | //设置压缩对齐
31 | zipAlignEnabled true
32 | //移除无用的资源文件
33 | shrinkResources true
34 | //设置混淆配置文件
35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
36 | //如果签名配置不为空 则设置签名信息
37 | if (signingConfigs.release != null) {
38 | signingConfig signingConfigs.release
39 | }
40 | //指定签名包得输入文件名称
41 | applicationVariants.all { variant ->
42 | variant.outputs.each { output ->
43 | def outputFile = output.outputFile
44 | if (outputFile != null && outputFile.name.endsWith('.apk')) {
45 | // 输出apk名称为GankDaily_v1.0_2015-01-15_wandoujia.apk
46 | def fileName = "GankDaily_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}_release.apk"
47 | output.outputFile = new File(outputFile.parent, fileName)
48 | }
49 | }
50 | }
51 | }
52 |
53 | debug{
54 | println 'build - debug'
55 | }
56 | }
57 |
58 | productFlavors {
59 | beta{
60 | manifestPlaceholders = [UMENG_CHANNEL_VALUE:"beta"]
61 | }
62 | xiaomi {
63 | manifestPlaceholders = [UMENG_CHANNEL_VALUE:"xiaomi"]
64 | }
65 | coolapk {
66 | manifestPlaceholders = [UMENG_CHANNEL_VALUE:"coolapk"]
67 | }
68 | wandoujia {
69 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"]
70 | }
71 | fir {
72 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "fir"]
73 | }
74 | umeng {
75 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "umeng"]
76 | }
77 | play {
78 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "play"]
79 | }
80 | }
81 |
82 | lintOptions {
83 | checkReleaseBuilds false
84 | // Or, if you prefer, you can continue to check for errors in release builds,
85 | // but continue the build even when errors are found:
86 | abortOnError false
87 | }
88 | }
89 |
90 | //set release sign info synchronously
91 | def Properties props = new Properties()
92 | def propFile = file('../gradle.properties')
93 | if (propFile.canRead()) {
94 | props.load(new FileInputStream(propFile))
95 | if (props != null &&
96 | props.containsKey('SIGN_FILE') && props.containsKey('SIGN_KEYSTORE_PASS') &&
97 | props.containsKey('SIGN_KEYSTORE_ALIAS') && props.containsKey('SIGN_KEYSTORE_ALIAS_PASS')) {
98 | println 'release build signing'
99 | android.signingConfigs.release.storeFile = file(props['SIGN_FILE'])
100 | android.signingConfigs.release.storePassword = props['SIGN_KEYSTORE_PASS']
101 | android.signingConfigs.release.keyAlias = props['SIGN_KEYSTORE_ALIAS']
102 | android.signingConfigs.release.keyPassword = props['SIGN_KEYSTORE_ALIAS_PASS']
103 | } else {
104 | println 'release build not found signing properties'
105 | android.buildTypes.release.signingConfig = null
106 | }
107 | } else {
108 | println 'release build not found signing file'
109 | android.buildTypes.release.signingConfig = null
110 | }
111 |
112 |
113 | dependencies {
114 | compile fileTree(dir: 'libs', include: ['*.jar'])
115 | compile 'com.android.support:appcompat-v7:25.3.1'
116 | compile 'com.android.support:recyclerview-v7:25.3.1'
117 | compile 'com.android.support:design:25.3.1'
118 |
119 | compile 'com.jakewharton:butterknife:7.0.1'
120 |
121 | compile 'io.reactivex:rxandroid:1.0.0'
122 |
123 | compile 'com.orhanobut:logger:1.4'
124 |
125 | compile 'com.squareup.okhttp:okhttp:2.5.0'
126 | compile 'com.squareup.retrofit:retrofit:1.9.0'
127 |
128 | compile 'com.github.chrisbanes:PhotoView:2.0.0'
129 |
130 | compile 'com.github.bumptech.glide:glide:3.7.0'
131 |
132 | compile 'com.umeng.analytics:analytics:latest.integration'
133 |
134 | compile 'com.github.daniel-stoneuk:material-about-library:1.8.2'
135 | }
136 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.gudong.gankio.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.net.Uri;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.content.ContextCompat;
9 | import android.view.MenuItem;
10 |
11 | import com.danielstone.materialaboutlibrary.ConvenienceBuilder;
12 | import com.danielstone.materialaboutlibrary.MaterialAboutActivity;
13 | import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
14 | import com.danielstone.materialaboutlibrary.model.MaterialAboutCard;
15 | import com.danielstone.materialaboutlibrary.model.MaterialAboutList;
16 | import com.gudong.gankio.R;
17 |
18 | import static com.gudong.gankio.R.string.website;
19 |
20 | public class AboutActivity extends MaterialAboutActivity {
21 |
22 | public static void gotoAboutActivity(Context context){
23 | context.startActivity(new Intent(context,AboutActivity.class));
24 | }
25 | @Override @NonNull protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
26 | MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
27 | try {
28 | appCardBuilder.addItem(
29 | ConvenienceBuilder.createVersionActionItem(
30 | context,
31 | ContextCompat.getDrawable(context, R.drawable.ic_issues),
32 | getString(R.string.version),
33 | false)
34 | );
35 | } catch (PackageManager.NameNotFoundException e) {
36 | e.printStackTrace();
37 | }
38 |
39 | appCardBuilder.addItem(ConvenienceBuilder.createRateActionItem(context, ContextCompat.getDrawable(context, R.drawable.ic_star_filled),
40 | getString(R.string.rate_app), null));
41 |
42 | appCardBuilder.addItem(new MaterialAboutActionItem.Builder()
43 | .text(R.string.report_issue)
44 | .subText(R.string.report_issue_here)
45 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_bug))
46 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("https://github.com/maoruibin/GankDaily/issues")))
47 | .build());
48 |
49 | MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
50 | authorCardBuilder.title(R.string.author);
51 | authorCardBuilder.addItem(new MaterialAboutActionItem.Builder()
52 | .text("咕咚")
53 | .subText("maoruibin")
54 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_profile))
55 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("http://gudong.name/")))
56 | .build());
57 | authorCardBuilder.addItem(new MaterialAboutActionItem.Builder()
58 | .text(R.string.fork_github)
59 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_github))
60 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("https://github.com/maoruibin/GankDaily")))
61 | .build());
62 |
63 | authorCardBuilder.addItem(ConvenienceBuilder.createEmailItem(context, ContextCompat.getDrawable(context, R.drawable.ic_email),
64 | getString(R.string.send_email), true, getString(R.string.email_address), getString(R.string.question_concerning_fasthub)));
65 |
66 | MaterialAboutCard.Builder logoAuthor = new MaterialAboutCard.Builder();
67 | logoAuthor.title(getString(R.string.contact));
68 |
69 | logoAuthor.addItem(new MaterialAboutActionItem.Builder()
70 | .text(website)
71 | .subText(R.string.website_sub)
72 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_brower))
73 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("http://gudong.name/")))
74 | .build());
75 | logoAuthor.addItem(new MaterialAboutActionItem.Builder()
76 | .text(R.string.weibo)
77 | .subText(R.string.weibo_nick)
78 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_profile))
79 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("http://weibo.com/maoruibin")))
80 | .build());
81 | logoAuthor.addItem(new MaterialAboutActionItem.Builder()
82 | .text(R.string.github)
83 | .subText(R.string.github_id)
84 | .icon(ContextCompat.getDrawable(context, R.drawable.ic_github))
85 | .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(AboutActivity.this, Uri.parse("https://github.com/maoruibin")))
86 | .build());
87 |
88 | return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), logoAuthor.build());
89 | }
90 |
91 | @Override protected CharSequence getActivityTitle() {
92 | return getString(R.string.app_name);
93 | }
94 |
95 |
96 | @Override public boolean onOptionsItemSelected(MenuItem item) {
97 | if (item.getItemId() == android.R.id.home) {
98 | finish();
99 | }
100 | return false;//override
101 | }
102 |
103 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/activity/WebActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.activity;
21 |
22 | import android.content.Intent;
23 | import android.net.Uri;
24 | import android.os.Bundle;
25 | import android.support.design.widget.Snackbar;
26 | import android.text.TextUtils;
27 | import android.view.KeyEvent;
28 | import android.view.MenuItem;
29 | import android.webkit.WebView;
30 | import android.widget.Toast;
31 |
32 | import com.gudong.gankio.R;
33 | import com.gudong.gankio.presenter.WebPresenter;
34 | import com.gudong.gankio.ui.view.IWebView;
35 | import com.gudong.gankio.util.AndroidUtils;
36 |
37 | import butterknife.Bind;
38 | import butterknife.ButterKnife;
39 |
40 | public class WebActivity extends BaseSwipeRefreshActivity implements IWebView{
41 | private static final String EXTRA_URL = "URL";
42 | private static final String EXTRA_TITLE = "TITLE";
43 |
44 | @Bind(R.id.wb_content)
45 | WebView mWbContent;
46 |
47 | public static void gotoWebActivity(BaseActivity context,String url,String title){
48 | Intent intent = new Intent(context,WebActivity.class);
49 | intent.putExtra(EXTRA_URL,url);
50 | intent.putExtra(EXTRA_TITLE, title);
51 | context.startActivity(intent);
52 | }
53 |
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 |
58 | String url = getIntent().getStringExtra(EXTRA_URL);
59 | String title = getIntent().getStringExtra(EXTRA_TITLE);
60 |
61 | if(!TextUtils.isEmpty(title)){
62 | setTitle(title,true);
63 | }
64 | mPresenter.setUpWebView(mWbContent);
65 | mPresenter.loadUrl(mWbContent,url);
66 | }
67 |
68 | @Override
69 | protected int getLayout() {
70 | return R.layout.activity_web;
71 | }
72 |
73 | @Override
74 | protected int getMenuRes() {
75 | return R.menu.menu_web;
76 | }
77 |
78 | @Override
79 | protected void onRefreshStarted() {
80 | refresh();
81 | }
82 |
83 | @Override
84 | protected void initPresenter() {
85 | mPresenter = new WebPresenter(this,this);
86 | }
87 |
88 | private void refresh(){
89 | mWbContent.reload();
90 | }
91 |
92 | @Override
93 | public boolean onOptionsItemSelected(MenuItem item) {
94 | int id = item.getItemId();
95 | switch (id) {
96 | case R.id.action_copy_url:
97 | String copyDone = getString(R.string.toast_copy_done);
98 | AndroidUtils.copyToClipBoard(this, mWbContent.getUrl(), copyDone);
99 | return true;
100 | case R.id.action_share_url:
101 | AndroidUtils.shareText(this, mWbContent.getUrl());
102 | return true;
103 | case R.id.action_open_url:
104 | Intent intent = new Intent();
105 | intent.setAction(Intent.ACTION_VIEW);
106 | Uri uri = Uri.parse(mWbContent.getUrl());
107 | intent.setData(uri);
108 | if (intent.resolveActivity(getPackageManager()) != null) {
109 | startActivity(intent);
110 | } else {
111 | Toast.makeText(WebActivity.this, R.string.toast_open_fail, Toast.LENGTH_SHORT).show();
112 | }
113 | return true;
114 | }
115 | return super.onOptionsItemSelected(item);
116 | }
117 |
118 | @Override
119 | public void showEmptyView() {
120 |
121 | }
122 |
123 | @Override
124 | public void showErrorView(Throwable throwable) {
125 | throwable.printStackTrace();
126 | }
127 |
128 | @Override
129 | protected void onResume() {
130 | super.onResume();
131 | if (mWbContent != null) mWbContent.onResume();
132 | }
133 |
134 | @Override
135 | protected void onDestroy() {
136 | super.onDestroy();
137 | if (mWbContent != null) mWbContent.destroy();
138 | ButterKnife.unbind(this);
139 | }
140 |
141 | @Override
142 | protected void onPause() {
143 | if (mWbContent != null) mWbContent.onPause();
144 | super.onPause();
145 | }
146 |
147 | @Override
148 | public void showLoadErrorMessage(String message) {
149 | Snackbar.make(mWbContent,message,Snackbar.LENGTH_SHORT).show();
150 | }
151 |
152 | @Override
153 | public boolean onKeyDown(int keyCode, KeyEvent event) {
154 | if ((keyCode == KeyEvent.KEYCODE_BACK) && mWbContent.canGoBack()) {
155 | mWbContent.goBack();
156 | return true;
157 | }
158 | return super.onKeyDown(keyCode, event);
159 | }
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/ui/adapter/ViewListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.ui.adapter;
21 |
22 | import android.content.Context;
23 | import android.graphics.ColorFilter;
24 | import android.graphics.ColorMatrix;
25 | import android.graphics.ColorMatrixColorFilter;
26 | import android.support.v7.widget.RecyclerView;
27 | import android.view.LayoutInflater;
28 | import android.view.View;
29 | import android.view.ViewGroup;
30 | import android.widget.TextView;
31 |
32 | import com.bumptech.glide.Glide;
33 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
34 | import com.bumptech.glide.request.target.SizeReadyCallback;
35 | import com.gudong.gankio.R;
36 | import com.gudong.gankio.data.entity.Girl;
37 | import com.gudong.gankio.ui.widget.RatioImageView;
38 | import com.gudong.gankio.util.DateUtil;
39 |
40 | import java.util.ArrayList;
41 | import java.util.List;
42 |
43 | import butterknife.Bind;
44 | import butterknife.ButterKnife;
45 |
46 | /**
47 | * 主页数据显示Adapter
48 | * Created by GuDong on 9/28/15.
49 | * Contact with gudong.name@gmail.com
50 | */
51 | public class ViewListAdapter extends RecyclerView.Adapter {
52 | private List mListData;
53 | private Context mContext;
54 | private IClickItem mIClickItem;
55 | //blur meizi
56 | private static ColorFilter mColorFilter;
57 | public ViewListAdapter(Context context) {
58 | mContext = context;
59 | mListData = new ArrayList<>();
60 |
61 | float[]array = new float[]{
62 | 1,0,0,0,-70,
63 | 0,1,0,0,-70,
64 | 0,0,1,0,-70,
65 | 0,0,0,1,0,
66 | };
67 | mColorFilter = new ColorMatrixColorFilter(new ColorMatrix(array));
68 | }
69 |
70 | public void setIClickItem(IClickItem IClickItem) {
71 | mIClickItem = IClickItem;
72 | }
73 |
74 | /**
75 | * before add data , it will remove history data
76 | * @param data
77 | */
78 | public void updateWithClear(List data){
79 | mListData.clear();
80 | mListData.addAll(data);
81 | notifyDataSetChanged();
82 | }
83 |
84 | /**
85 | * add data append to history data
86 | * @param data new data
87 | */
88 | public void update(List data){
89 | mListData.addAll(data);
90 | notifyDataSetChanged();
91 | }
92 |
93 | public Girl getGirl(int position){
94 | return mListData.get(position);
95 | }
96 |
97 | @Override
98 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
99 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.index_item, null);
100 | ViewHolder holder = new ViewHolder(view);
101 | return holder;
102 | }
103 |
104 | @Override
105 | public void onBindViewHolder(final ViewHolder holder,final int position) {
106 | Girl entity = mListData.get(position);
107 |
108 | Glide.with(mContext)
109 | .load(entity.url)
110 | .centerCrop()
111 | .diskCacheStrategy(DiskCacheStrategy.ALL)
112 | .dontAnimate()
113 | .into(holder.mIvIndexPhoto)
114 | .getSize(new SizeReadyCallback() {
115 | @Override
116 | public void onSizeReady(int width, int height) {
117 | //holder.mIvIndexPhoto.setColorFilter(mColorFilter);
118 | }
119 | });
120 | holder.mTvTime.setText(DateUtil.toDate(entity.publishedAt));
121 | if(mIClickItem!=null){
122 | holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
123 | @Override
124 | public void onClick(View v) {
125 | mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto,holder.mTvTime);
126 | }
127 | });
128 | }
129 | }
130 |
131 | public interface IClickItem{
132 | void onClickPhoto(int position,View view,View textView);
133 | }
134 |
135 | @Override
136 | public int getItemCount() {
137 | return mListData.size();
138 | }
139 |
140 | /**
141 | * This class contains all butterknife-injected Views & Layouts from layout file 'index_listitem.xml'
142 | * for easy to all layout elements.
143 | *
144 | * @author ButterKnifeZelezny, plugin for Android Studio by Avast Developers (http://github.com/avast)
145 | */
146 | public static class ViewHolder extends RecyclerView.ViewHolder{
147 | @Bind(R.id.iv_index_photo)
148 | RatioImageView mIvIndexPhoto;
149 | @Bind(R.id.tv_time)
150 | TextView mTvTime;
151 |
152 | ViewHolder(View view) {
153 | super(view);
154 | ButterKnife.bind(this, view);
155 |
156 | mIvIndexPhoto.setOriginalSize(50,50);
157 | }
158 | }
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gudong/gankio/presenter/GirlFacePresenter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package com.gudong.gankio.presenter;
21 |
22 | import android.app.Activity;
23 | import android.content.Context;
24 | import android.content.Intent;
25 | import android.graphics.Bitmap;
26 | import android.net.Uri;
27 | import android.os.AsyncTask;
28 | import android.os.Environment;
29 | import android.provider.MediaStore;
30 | import android.text.TextUtils;
31 | import android.widget.ImageView;
32 |
33 | import com.bumptech.glide.Glide;
34 | import com.gudong.gankio.R;
35 | import com.gudong.gankio.ui.view.IGirlFaceView;
36 | import com.gudong.gankio.util.TaskUtils;
37 | import com.orhanobut.logger.Logger;
38 |
39 | import java.io.File;
40 | import java.io.FileNotFoundException;
41 | import java.io.FileOutputStream;
42 | import java.io.IOException;
43 | import java.util.concurrent.ExecutionException;
44 |
45 | /**
46 | * Created by GuDong on 11/2/15 18:22.
47 | * Contact with gudong.name@gmail.com.
48 | */
49 | public class GirlFacePresenter extends BasePresenter {
50 | public GirlFacePresenter(Activity context, IGirlFaceView view) {
51 | super(context, view);
52 | }
53 |
54 | public void saveFace(final String url, final ImageView ivGirlDetail) {
55 | if (!TextUtils.isEmpty(url)) {
56 | final String fileName = url.substring(url.lastIndexOf("/")+1);
57 |
58 | ivGirlDetail.post(new Runnable() {
59 | @Override
60 | public void run() {
61 | int width = ivGirlDetail.getWidth();
62 | int height = ivGirlDetail.getHeight();
63 | saveImageToSdCard(mContext, url, fileName,width,height);
64 | }
65 | });
66 | }
67 | }
68 |
69 | private void saveImageToSdCard(final Context context, final String url, final String title, final int w, final int h){
70 | TaskUtils.executeAsyncTask(new AsyncTask