├── app
├── .gitignore
├── libs
│ ├── lite-orm-1.7.0.jar
│ ├── armeabi
│ │ └── libbspatch.so
│ └── umeng-update-v2.6.0.1.jar
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── icon.png
│ │ │ ├── list_activated_holo.9.png
│ │ │ ├── actionbar_back_indicator.png
│ │ │ ├── umeng_update_wifi_disable.png
│ │ │ ├── umeng_update_button_cancel_bg_tap.xml
│ │ │ ├── umeng_update_button_ok_bg_tap.xml
│ │ │ ├── umeng_update_dialog_bg.xml
│ │ │ ├── umeng_update_button_ok_bg_focused.xml
│ │ │ ├── umeng_update_button_cancel_bg_focused.xml
│ │ │ ├── umeng_update_button_cancel_bg_normal.xml
│ │ │ ├── umeng_update_button_ok_bg_normal.xml
│ │ │ ├── activated_background_holo_light.xml
│ │ │ ├── umeng_common_gradient_red.xml
│ │ │ ├── tb_munion_item_selector.xml
│ │ │ ├── umeng_common_gradient_green.xml
│ │ │ ├── umeng_common_gradient_orange.xml
│ │ │ ├── tb_munion_icon.xml
│ │ │ ├── shape_type.xml
│ │ │ ├── shape_type_ios.xml
│ │ │ ├── shape_type_relax.xml
│ │ │ ├── shape_type_android.xml
│ │ │ ├── shape_type_extend.xml
│ │ │ ├── umeng_update_title_bg.xml
│ │ │ ├── umeng_update_button_close_bg_selector.xml
│ │ │ ├── umeng_update_button_ok_bg_selector.xml
│ │ │ ├── umeng_update_button_cancel_bg_selector.xml
│ │ │ ├── actionbar_background.xml
│ │ │ ├── actionbar_btn_normal.xml
│ │ │ ├── actionbar_btn_pressed.xml
│ │ │ ├── actionbar_compat_button.xml
│ │ │ ├── umeng_update_button_check_selector.xml
│ │ │ └── actionbar_btn.xml
│ │ ├── drawable-hdpi
│ │ │ ├── icon.jpg
│ │ │ ├── ic_about.png
│ │ │ ├── ic_back.png
│ │ │ ├── ic_close.png
│ │ │ ├── ic_menu.png
│ │ │ ├── ic_drawer.png
│ │ │ ├── ic_github.png
│ │ │ ├── ic_trending.png
│ │ │ ├── drawer_shadow.9.png
│ │ │ ├── umeng_logo_big.png
│ │ │ ├── btn_bg_pressed.9.png
│ │ │ ├── btn_bg_selected.9.png
│ │ │ ├── ic_home_black_48dp.png
│ │ │ ├── actionbar_compat_logo.png
│ │ │ ├── ic_android_black_48dp.png
│ │ │ ├── ic_title_home_default.png
│ │ │ ├── ic_title_share_default.png
│ │ │ ├── umeng_example_banner_bg.png
│ │ │ ├── umeng_example_handler.png
│ │ │ ├── umeng_logo_big_subtitle.png
│ │ │ ├── actionbar_back_indicator.png
│ │ │ ├── ic_face_unlock_black_48dp.png
│ │ │ ├── ic_title_refresh_default.png
│ │ │ ├── umeng_update_close_bg_tap.png
│ │ │ ├── actionbar_compat_separator.9.png
│ │ │ ├── umeng_example_two_tab_left.png
│ │ │ ├── umeng_example_two_tab_right.png
│ │ │ ├── umeng_update_close_bg_normal.png
│ │ │ ├── actionbar_compat_background.9.png
│ │ │ ├── ic_perm_device_info_black_48dp.png
│ │ │ ├── umeng_example_common_banner_promotion.png
│ │ │ ├── umeng_update_btn_check_off_holo_light.png
│ │ │ ├── umeng_update_btn_check_on_holo_light.png
│ │ │ ├── umeng_update_btn_check_off_focused_holo_light.png
│ │ │ ├── umeng_update_btn_check_off_pressed_holo_light.png
│ │ │ ├── umeng_update_btn_check_on_focused_holo_light.png
│ │ │ └── umeng_update_btn_check_on_pressed_holo_light.png
│ │ ├── drawable-xxhdpi
│ │ │ └── meizhi.png
│ │ ├── drawable-xxxhdpi
│ │ │ ├── ic_back.png
│ │ │ ├── ic_done.png
│ │ │ ├── ic_home.png
│ │ │ ├── ic_ios.png
│ │ │ ├── ic_menu.png
│ │ │ ├── ic_save.png
│ │ │ ├── ic_android.png
│ │ │ ├── ic_close.png
│ │ │ ├── ic_github.png
│ │ │ ├── ic_meizhi.png
│ │ │ ├── ic_share.png
│ │ │ ├── ic_favorite.png
│ │ │ ├── ic_launcher.png
│ │ │ ├── ic_thumb_up.png
│ │ │ └── ic_trending.png
│ │ ├── values
│ │ │ ├── tb_munion_strings.xml
│ │ │ ├── colors_actionbar.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ ├── colors_umeng.xml
│ │ │ ├── strings.xml
│ │ │ ├── attrs_umeng.xml
│ │ │ ├── styles.xml
│ │ │ ├── umeng_update_string.xml
│ │ │ ├── umeng_common_strings.xml
│ │ │ ├── dimens_umeng.xml
│ │ │ ├── strings_umeng.xml
│ │ │ ├── styles_umeng.xml
│ │ │ └── update_example_strings.xml
│ │ ├── values-v21
│ │ │ └── styles.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── values-v11
│ │ │ └── styles.xml
│ │ ├── layout
│ │ │ ├── umeng_example_tab_indicator.xml
│ │ │ ├── fragment_article_list.xml
│ │ │ ├── umeng_example_auto_update.xml
│ │ │ ├── umeng_example_about_update.xml
│ │ │ ├── umeng_example_silent_update.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── item_meizhi.xml
│ │ │ ├── umeng_example_manual_update.xml
│ │ │ ├── umeng_example_home_dashboard_fragment.xml
│ │ │ ├── nav_header.xml
│ │ │ ├── activity_about.xml
│ │ │ ├── home_viewpager.xml
│ │ │ ├── umeng_example_update_main.xml
│ │ │ ├── activity_webview.xml
│ │ │ ├── activity_show_img.xml
│ │ │ ├── item_article.xml
│ │ │ ├── umeng_common_download_notification.xml
│ │ │ └── umeng_update_dialog.xml
│ │ ├── menu
│ │ │ ├── menu_about.xml
│ │ │ ├── menu_actions.xml
│ │ │ └── drawer_actions.xml
│ │ ├── values-zh
│ │ │ ├── umeng_update_string.xml
│ │ │ ├── umeng_common_strings.xml
│ │ │ └── strings.xml
│ │ └── layout-v9
│ │ │ └── umeng_common_download_notification.xml
│ │ ├── java
│ │ └── cn
│ │ │ └── chenyuanming
│ │ │ └── gankmeizhi
│ │ │ ├── constants
│ │ │ └── Constants.java
│ │ │ ├── beans
│ │ │ ├── db
│ │ │ │ ├── FavoriteBean.java
│ │ │ │ ├── ReadArticles.java
│ │ │ │ └── DbGoodsBean.java
│ │ │ └── CommonGoodsBean.java
│ │ │ ├── application
│ │ │ └── GankApplication.java
│ │ │ ├── utils
│ │ │ ├── ToastUtil.java
│ │ │ ├── ClipboardHelper.java
│ │ │ ├── ShareUtils.java
│ │ │ ├── DbHelper.java
│ │ │ ├── TimeHelper.java
│ │ │ ├── RecyclerViewLoadHelper.java
│ │ │ ├── RxMeizhi.java
│ │ │ └── PreferenceUtil.java
│ │ │ ├── fragment
│ │ │ ├── BaseFragment.java
│ │ │ └── GankFragment.java
│ │ │ ├── decoration
│ │ │ └── SpacesItemDecoration.java
│ │ │ ├── activity
│ │ │ ├── BaseActivity.java
│ │ │ ├── AboutActivity.java
│ │ │ ├── ShowBigImageActivity.java
│ │ │ ├── MainActivity.java
│ │ │ └── WebViewActivity.java
│ │ │ ├── adapter
│ │ │ ├── MeizhiAdapter.java
│ │ │ └── ArticleViewAdapter.java
│ │ │ ├── service
│ │ │ └── PrefetchService.java
│ │ │ └── api
│ │ │ └── GankApi.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshot
├── meizhi.jpg
├── Screenshot_1.png
├── Screenshot_2.png
├── Screenshot_3.png
├── Screenshot_4.png
└── Screenshot_5.png
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshot/meizhi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/meizhi.jpg
--------------------------------------------------------------------------------
/app/libs/lite-orm-1.7.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/libs/lite-orm-1.7.0.jar
--------------------------------------------------------------------------------
/screenshot/Screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/Screenshot_1.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/Screenshot_2.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/Screenshot_3.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/Screenshot_4.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/screenshot/Screenshot_5.png
--------------------------------------------------------------------------------
/app/libs/armeabi/libbspatch.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/libs/armeabi/libbspatch.so
--------------------------------------------------------------------------------
/app/libs/umeng-update-v2.6.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/libs/umeng-update-v2.6.0.1.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/icon.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_about.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/meizhi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxhdpi/meizhi.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_drawer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_drawer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_home.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_ios.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_ios.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_trending.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_trending.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_android.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_meizhi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_meizhi.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/drawer_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/drawer_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_logo_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_logo_big.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_favorite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_favorite.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_thumb_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_thumb_up.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_trending.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-xxxhdpi/ic_trending.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/btn_bg_pressed.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/btn_bg_pressed.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/btn_bg_selected.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/btn_bg_selected.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_home_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_home_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/list_activated_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable/list_activated_holo.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_back_indicator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable/actionbar_back_indicator.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_wifi_disable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable/umeng_update_wifi_disable.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/actionbar_compat_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/actionbar_compat_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_android_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_android_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_title_home_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_title_home_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_title_share_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_title_share_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_example_banner_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_example_banner_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_example_handler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_example_handler.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_logo_big_subtitle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_logo_big_subtitle.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/actionbar_back_indicator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/actionbar_back_indicator.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_face_unlock_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_face_unlock_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_title_refresh_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_title_refresh_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_close_bg_tap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_close_bg_tap.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/actionbar_compat_separator.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/actionbar_compat_separator.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_example_two_tab_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_example_two_tab_left.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_example_two_tab_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_example_two_tab_right.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_close_bg_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_close_bg_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/actionbar_compat_background.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/actionbar_compat_background.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_perm_device_info_black_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/ic_perm_device_info_black_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_example_common_banner_promotion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_example_common_banner_promotion.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_focused_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_focused_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_pressed_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_off_pressed_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_focused_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_focused_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_pressed_holo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cym4u/GankMeizhi/HEAD/app/src/main/res/drawable-hdpi/umeng_update_btn_check_on_pressed_holo_light.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_cancel_bg_tap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_ok_bg_tap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/tb_munion_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #e3e3e3
5 | 正在下载:
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_dialog_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_ok_bg_focused.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_cancel_bg_focused.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_cancel_bg_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_ok_bg_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.constants;
2 |
3 | /**
4 | * Created by Chen Yuanming on 2016/1/25.
5 | */
6 | public interface Constants {
7 | int LIMIT = 50;
8 | int START = 1;
9 | String ENDPOINT = "http://gank.avosapps.com/api";
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/activated_background_holo_light.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_common_gradient_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/tb_munion_item_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_common_gradient_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_common_gradient_orange.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/tb_munion_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_type.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_type_ios.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_type_relax.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_type_android.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_type_extend.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_title_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors_actionbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3A5FCD
4 | #3A5FCD
5 | #27408B
6 | #FFFFFF
7 | #FF7F00
8 | #EE7600
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/beans/db/FavoriteBean.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.beans.db;
2 |
3 | import com.litesuits.orm.db.annotation.PrimaryKey;
4 | import com.litesuits.orm.db.enums.AssignType;
5 |
6 | import java.util.TreeSet;
7 |
8 | /**
9 | * Created by Chen Yuanming on 2016/1/30.
10 | */
11 | public class FavoriteBean {
12 |
13 | @PrimaryKey(AssignType.BY_MYSELF)
14 | public int id;
15 | public TreeSet favorites = new TreeSet<>();
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 256dp
7 | 16dp
8 | 40dp
9 |
10 | 12dp
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_close_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #4000
7 | #000
8 | #2397fc
9 | #00bf96
10 | #fcb43f
11 | #fc765b
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/umeng_example_tab_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_ok_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/application/GankApplication.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.application;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | /**
7 | * Created by Chen Yuanming on 2016/1/25.
8 | */
9 | public class GankApplication extends Application {
10 | static GankApplication instance;
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | instance = this;
16 | }
17 |
18 | public static Context getContext() {
19 | return instance;
20 | }
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/umeng_update_button_cancel_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/beans/db/ReadArticles.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.beans.db;
2 |
3 | import com.litesuits.orm.db.annotation.PrimaryKey;
4 | import com.litesuits.orm.db.annotation.Table;
5 | import com.litesuits.orm.db.enums.AssignType;
6 |
7 | import java.io.Serializable;
8 | import java.util.TreeSet;
9 |
10 | /**
11 | * Created by Chen Yuanming on 2016/1/28.
12 | */
13 | @Table("ReadArticles")
14 | public class ReadArticles implements Serializable {
15 | @PrimaryKey(AssignType.BY_MYSELF)
16 | public int id;
17 | public TreeSet articles = new TreeSet<>();
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_article_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import android.widget.Toast;
4 |
5 | import cn.chenyuanming.gankmeizhi.application.GankApplication;
6 |
7 | /**
8 | * Created by Chen Yuanming on 2016/1/30.
9 | */
10 | public class ToastUtil {
11 | public static void showShortToast(String msg) {
12 | Toast.makeText(GankApplication.getContext(), msg, Toast.LENGTH_SHORT).show();
13 | }
14 |
15 | public static void showLongToast(String msg) {
16 | Toast.makeText(GankApplication.getContext(), msg, Toast.LENGTH_LONG).show();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.fragment;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | import com.umeng.analytics.MobclickAgent;
6 |
7 | /**
8 | * Created by Administrator on 2016/2/2.
9 | */
10 | public class BaseFragment extends Fragment {
11 | public void onResume() {
12 | super.onResume();
13 | MobclickAgent.onPageStart(getClass().getSimpleName()); //统计页面,"MainScreen"为页面名称,可自定义
14 | }
15 |
16 | public void onPause() {
17 | super.onPause();
18 | MobclickAgent.onPageEnd(getClass().getSimpleName());
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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 C:\dev\as_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 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_actions.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/ClipboardHelper.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.text.ClipboardManager;
6 |
7 | /**
8 | * Created by Chen Yuanming on 2016/2/2.
9 | */
10 | public class ClipboardHelper {
11 |
12 | /**
13 | * 实现文本复制功能
14 | *
15 | * @param content
16 | */
17 | @SuppressWarnings("deprecation")
18 | public static void copy(Context context, @NonNull String content) {
19 | // 得到剪贴板管理器
20 | ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
21 | cmb.setText(content.trim());
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/umeng_example_auto_update.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/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/layout/umeng_example_about_update.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/umeng_example_silent_update.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors_umeng.xml:
--------------------------------------------------------------------------------
1 |
2 | #ff000000
3 | #99000000
4 | #66000000
5 | #ffffffff
6 | #99ffffff
7 | #ff29549f
8 | #ffff549f
9 | #ffffffff
10 | #4d000000
11 | #ff222222
12 | #ff0fabff
13 | #ffdf1831
14 | #ff009939
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/decoration/SpacesItemDecoration.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.decoration;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | /**
8 | * Created by Chen Yuanming on 2016/1/28.
9 | */
10 | public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
11 |
12 | private int space;
13 |
14 | public SpacesItemDecoration(int space) {
15 | this.space = space;
16 | }
17 |
18 | @Override
19 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
20 | outRect.left = space;
21 | outRect.right = space;
22 | outRect.bottom = space;
23 | if (parent.getChildAdapterPosition(view) == 0) {
24 | outRect.top = space;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 干货·萌妹纸
3 | 干货·萌妹纸Debug
4 | 56b04542e0f55aecb9000f69
5 | 所有
6 | 妹纸
7 | Android
8 | iOS
9 | GitHub
10 | Trending
11 | 关于
12 | 发现了一款非常美观的App「干货·萌妹纸」,每天一张精选妹纸图、一个精选小视频(视频源地址播放),一篇程序猿干货,完全开源不收费,太赞了! 推荐~:http://fir.im/gankmeizhi
13 | 分享
14 | http://weibo.com/123466678
15 | https://github.com/enjoycodes/GankMeiZhi
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs_umeng.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/beans/db/DbGoodsBean.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.beans.db;
2 |
3 | import com.litesuits.orm.db.annotation.PrimaryKey;
4 | import com.litesuits.orm.db.annotation.Table;
5 | import com.litesuits.orm.db.enums.AssignType;
6 |
7 | import java.io.Serializable;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
12 |
13 | /**
14 | * Created by Chen Yuanming on 2016/1/25.
15 | */
16 | @Table("goods")
17 | public class DbGoodsBean implements Serializable {
18 | @PrimaryKey(AssignType.BY_MYSELF)
19 | public int id;
20 | public List allResults = new ArrayList<>();
21 | public List meizhiResults = new ArrayList<>();
22 | public List androidResults = new ArrayList<>();
23 | public List iosResults = new ArrayList<>();
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_meizhi.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
25 |
26 |
--------------------------------------------------------------------------------
/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/umeng_example_manual_update.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_btn_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
22 |
--------------------------------------------------------------------------------
/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/res/layout/umeng_example_home_dashboard_fragment.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
15 |
16 |
20 |
21 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_btn_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_compat_button.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.jude.swipbackhelper.SwipeBackHelper;
7 | import com.umeng.analytics.MobclickAgent;
8 |
9 | /**
10 | * Created by Chen Yuanming on 2016/2/1.
11 | */
12 | public abstract class BaseActivity extends AppCompatActivity {
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | SwipeBackHelper.onCreate(this);
17 | }
18 |
19 | @Override
20 | protected void onPostCreate(Bundle savedInstanceState) {
21 | super.onPostCreate(savedInstanceState);
22 | SwipeBackHelper.onPostCreate(this);
23 | }
24 |
25 | @Override
26 | protected void onDestroy() {
27 | super.onDestroy();
28 | SwipeBackHelper.onDestroy(this);
29 | }
30 |
31 | public void onResume() {
32 | super.onResume();
33 | MobclickAgent.onPageStart(getClass().getSimpleName());
34 | MobclickAgent.onResume(this);
35 | }
36 |
37 | public void onPause() {
38 | super.onPause();
39 | MobclickAgent.onPageEnd(getClass().getSimpleName());
40 | MobclickAgent.onPause(this);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/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/cn/chenyuanming/gankmeizhi/utils/ShareUtils.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 |
7 | import cn.chenyuanming.gankmeizhi.R;
8 |
9 | /**
10 | * Created by drakeet on 8/17/15.
11 | */
12 | public class ShareUtils {
13 |
14 | public static void share(Context context) {
15 | share(context, context.getString(R.string.share_text));
16 | }
17 |
18 |
19 | public static void shareImage(Context context, Uri uri, String title) {
20 | Intent shareIntent = new Intent();
21 | shareIntent.setAction(Intent.ACTION_SEND);
22 | shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
23 | shareIntent.setType("image/jpeg");
24 | context.startActivity(Intent.createChooser(shareIntent, title));
25 | }
26 |
27 |
28 | public static void share(Context context, String extraText) {
29 | Intent intent = new Intent(Intent.ACTION_SEND);
30 | intent.setType("text/plain");
31 | intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.action_share));
32 | intent.putExtra(Intent.EXTRA_TEXT, extraText);
33 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
34 | context.startActivity(
35 | Intent.createChooser(intent, context.getString(R.string.action_share)));
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens_umeng.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 10dp
19 | 10dp
20 | 14sp
21 | 18sp
22 | 18sp
23 | 18sp
24 | 36dp
25 | 8dp
26 | 100dp
27 |
28 | 45dip
29 | 45dip
30 | 45dip
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/DbHelper.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import com.litesuits.orm.LiteOrm;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import cn.chenyuanming.gankmeizhi.application.GankApplication;
9 |
10 | /**
11 | * Created by Chen Yuanming on 2016/1/28.
12 | */
13 | public class DbHelper {
14 | private static DbHelper helper;
15 |
16 | private DbHelper() {
17 | liteOrm = LiteOrm.newSingleInstance(GankApplication.getContext(), "gankmeizhi.db");
18 | }
19 |
20 | private LiteOrm liteOrm;
21 |
22 | public static DbHelper getHelper() {
23 | if (helper == null) {
24 | helper = new DbHelper();
25 | }
26 | return helper;
27 | }
28 |
29 | public LiteOrm getLiteOrm() {
30 | return liteOrm;
31 | }
32 |
33 |
34 | public List getData(Class clazz) {
35 | List list = getHelper().getLiteOrm().query(clazz);
36 | if (list == null || list.size() == 0) {
37 | list = new ArrayList<>();
38 | try {
39 | list.add(clazz.newInstance());
40 | getHelper().getLiteOrm().save(list);
41 | } catch (InstantiationException e) {
42 | e.printStackTrace();
43 | } catch (IllegalAccessException e) {
44 | e.printStackTrace();
45 | }
46 | }
47 | return list;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
27 |
28 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/TimeHelper.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 |
6 | /**
7 | * Created by Chen Yuanming on 2016/2/2.
8 | */
9 | public class TimeHelper {
10 | public static String getTime(long time) {
11 | long now = System.currentTimeMillis();
12 | if (now - time < 0) {
13 | return "来自未来";
14 | } else {
15 | float temp = now - time;
16 |
17 | temp /= 1000;
18 | if (temp < 60) {
19 | return (int) temp + "秒前";
20 | }
21 | temp /= 60;
22 | if (temp < 60) {
23 | return (int) temp + "分钟前";
24 | }
25 | temp /= 60;
26 | if (temp < 24) {
27 | return (int) temp + "小时前";
28 | }
29 | temp /= 24;
30 | if (temp < 30) {
31 | if ((int) temp == 1) {
32 | return "昨天";
33 | }
34 | if ((int) temp == 2) {
35 | return "前天";
36 | }
37 | return (int) temp + "天前";
38 | }
39 | // if (temp < 365) {
40 | // return (int) temp / 30 + "个月前";
41 | // }
42 | Date date = new Date(time);
43 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
44 | return sdf.format(date);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/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/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 统计分析
5 | 应用联盟
6 | 移动广告
7 | 工具
8 | 用户反馈
9 | 自动更新
10 | 社交分享
11 | Umeng For Publisher
12 | 嵌入容器
13 | 横幅
14 | "横幅\n(UFP)"
15 | 小把手
16 | "小把手\n(UFP)"
17 | 多页面
18 | 自定义样式
19 | Web页
20 | "Web页\n(UFP)"
21 | 文字链
22 | 轮播大图\n(UFP)
23 | 推送弹窗\n(UFP)
24 | 图标列表\n(UFP)
25 | 简单反馈
26 | 打开Activity失败
27 | 敬请期待
28 |
29 | 下面展示使用 js 调用友盟 自定义事件 APIs
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/actionbar_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
25 |
31 |
32 |
33 |
39 |
45 |
46 |
47 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/home_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
27 |
28 |
29 |
30 |
35 |
36 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_umeng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Analytics
4 | XP
5 | Ads
6 | Tools
7 | Feedback
8 | Update
9 | Socialize
10 | Umeng For Publisher
11 | Container
12 | Banner
13 | "Banner\n(UFP)"
14 | Handler
15 | "Handler\n(UFP)"
16 | Multi-Pages
17 | WebView
18 | Custom
19 | "WebView\n(UFP)"
20 | Push AD\n(UFP)
21 | Text Link
22 | LargeImage
23 | Icons \n(UFP)
24 | Simple Demo
25 | Failed to open intent…
26 | Coming soooooon
27 | The webview before show js call Umeng Analytics APIs
28 |
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gank.IO非官方客户端
2 | 借助[Gank.Io](http://gank.io/)提供的API开发的一个客户端,花了一周多时间完成,首次开源。如果对UI有更好的建议,欢迎联系我^_^。最后,欢迎star和fork。
3 |
4 | ###参考项目:
5 |
6 | 1、[xingrz](http://xingrz.me/)大神的开源项目[GankMeizhi](https://github.com/xingrz/GankMeizhi)
7 |
8 | 2、[drakeet](http://drakeet.me)大神的开源项目[Meizhi](https://github.com/drakeet/Meizhi)
9 |
10 | 3、[xiongwei-git](https://github.com/xiongwei-git)大神的开源项目[GankApp](https://github.com/xiongwei-git/GankApp)
11 |
12 | 4、开源项目[android-historian](https://github.com/mwolfson/android-historian)
13 |
14 | ###apk下载:
15 | ####[直接下载](http://fir.im/gankmeizhi)
16 |
17 | ###应用截图:
18 |
19 | 
20 |
21 |
22 | ###遗留功能:
23 | 1、按日期浏览
24 |
25 | ###支持版本:
26 | `minSdkVersion 14`
27 |
28 | ###依赖开源技术:
29 | ```
30 | compile 'com.android.support:appcompat-v7:23.1.1'
31 | compile 'com.android.support:design:23.1.1'
32 | compile 'com.android.support:cardview-v7:23.1.1'
33 | compile 'com.android.support:recyclerview-v7:23.1.1'
34 | compile 'com.android.support:palette-v7:23.1.1'
35 | compile 'com.android.support:percent:23.1.1'
36 | compile 'com.github.bumptech.glide:glide:3.6.0'
37 | compile 'de.hdodenhof:circleimageview:1.3.0'
38 | compile 'com.squareup.okio:okio:1.2.0'
39 | compile 'com.squareup.okhttp:okhttp:2.2.0'
40 | compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
41 | compile 'com.squareup.retrofit:retrofit:1.9.0'
42 | compile 'io.reactivex:rxandroid:0.24.0'
43 | compile 'com.jakewharton:butterknife:7.0.1'
44 | compile 'com.github.zzz40500:android-shapeLoadingView:1.0.3.2'
45 | compile 'de.hdodenhof:circleimageview:2.0.0'
46 | compile 'com.github.orangegangsters:swipy:1.1.0@aar'
47 | compile 'com.jude:swipebackhelper:2.1.5'
48 | compile('com.mikepenz:aboutlibraries:5.2.1@aar') { transitive = true; }
49 | compile 'com.umeng.analytics:analytics:latest.integration'
50 | ```
51 | ## 开源协议
52 |
53 | [Apache License 2.0](LICENSE)
54 |
55 |
56 | ## 关于我
57 |
58 | WeiBo:[@KeepCoding](http://weibo.com/123466678)
59 |
60 | Blog:[chenyuanming.cn](http://www.chenyuanming.cn)
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer_actions.xml:
--------------------------------------------------------------------------------
1 |
16 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/umeng_example_update_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
24 |
25 |
27 |
31 |
32 |
38 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles_umeng.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
31 |
32 |
38 |
44 |
48 |
52 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'me.tatarka.retrolambda'
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.2"
7 | dexOptions {
8 | // jumboMode = true
9 | incremental true//--incremental is not supported with --multi-dex
10 | javaMaxHeapSize "4g"
11 | }
12 | defaultConfig {
13 | applicationId "cn.chenyuanming.gankmeizhi"
14 | minSdkVersion 14
15 | targetSdkVersion 23
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | }
20 | buildTypes {
21 | debug {
22 | applicationIdSuffix ".debug"
23 | manifestPlaceholders = [APP_NAME: "@string/app_name_debug",UMENG_APP_KEY: "@string/umeng_app_key"]
24 |
25 | }
26 | release {
27 | manifestPlaceholders = [APP_NAME: "@string/app_name",UMENG_APP_KEY: "@string/umeng_app_key"]
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
30 | }
31 |
32 |
33 | }
34 | compileOptions {
35 | targetCompatibility 1.8
36 | sourceCompatibility 1.8
37 | }
38 | lintOptions {
39 | checkReleaseBuilds false
40 | // Or, if you prefer, you can continue to check for errors in release builds,
41 | // but continue the build even when errors are found:
42 | abortOnError false
43 | }
44 | }
45 |
46 | dependencies {
47 | compile fileTree(dir: 'libs', include: ['*.jar'])
48 | compile 'com.android.support:appcompat-v7:23.1.1'
49 | compile 'com.android.support:design:23.1.1'
50 | compile 'com.android.support:cardview-v7:23.1.1'
51 | compile 'com.android.support:recyclerview-v7:23.1.1'
52 | compile 'com.android.support:palette-v7:23.1.1'
53 | compile 'com.android.support:percent:23.1.1'
54 | compile 'com.github.bumptech.glide:glide:3.6.0'
55 | compile 'de.hdodenhof:circleimageview:1.3.0'
56 | compile 'com.squareup.okio:okio:1.2.0'
57 | compile 'com.squareup.okhttp:okhttp:2.2.0'
58 | compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
59 | compile 'com.squareup.retrofit:retrofit:1.9.0'
60 | compile 'io.reactivex:rxandroid:0.24.0'
61 | compile 'com.jakewharton:butterknife:7.0.1'
62 | compile 'com.github.zzz40500:android-shapeLoadingView:1.0.3.2'
63 | compile 'de.hdodenhof:circleimageview:2.0.0'
64 | compile 'com.github.orangegangsters:swipy:1.1.0@aar'
65 | compile 'com.jude:swipebackhelper:2.1.5'
66 | compile('com.mikepenz:aboutlibraries:5.2.1@aar') { transitive = true; }
67 | compile 'com.umeng.analytics:analytics:latest.integration'
68 | }
69 |
--------------------------------------------------------------------------------
/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/cn/chenyuanming/gankmeizhi/adapter/MeizhiAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | import butterknife.Bind;
18 | import butterknife.ButterKnife;
19 | import cn.chenyuanming.gankmeizhi.R;
20 | import cn.chenyuanming.gankmeizhi.activity.ShowBigImageActivity;
21 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
22 |
23 | /**
24 | * Created by Chen Yuanming on 2016/1/28.
25 | */
26 | public class MeizhiAdapter extends RecyclerView.Adapter {
27 | private List mDatas = new ArrayList<>();
28 | private Context context;
29 |
30 | public MeizhiAdapter(Context context, List list) {
31 | this.context = context;
32 | if (list != null) {
33 | mDatas.addAll(list);
34 | }
35 | }
36 |
37 | @Override
38 | public MeizhiViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
39 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_meizhi, viewGroup, false);
40 | return new MeizhiViewHolder(view);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(MeizhiViewHolder meizhiViewHolder, int position) {
45 | // meizhiViewHolder.imageView.setImageResource(mDatas.get(position).getImg());
46 | Glide.with(context).load(mDatas.get(position).url).diskCacheStrategy(DiskCacheStrategy.ALL).into(meizhiViewHolder.imageView);
47 | // meizhiViewHolder.textView.setText(mDatas.get(position).desc);
48 | meizhiViewHolder.mainView.setOnClickListener((v) -> {
49 | Intent intent = new Intent(context, ShowBigImageActivity.class);
50 | intent.putExtra("data", mDatas.get(position));
51 | context.startActivity(intent);
52 | });
53 | }
54 |
55 | @Override
56 | public int getItemCount() {
57 | return mDatas.size();
58 | }
59 |
60 | public static class MeizhiViewHolder extends RecyclerView.ViewHolder {
61 | @Bind(R.id.imageView)
62 | ImageView imageView;
63 | // @Bind(R.id.textView)
64 | // TextView textView;
65 | View mainView;
66 |
67 | public MeizhiViewHolder(View itemView) {
68 | super(itemView);
69 | ButterKnife.bind(this, itemView);
70 | mainView = itemView;
71 | }
72 |
73 | }
74 |
75 | public List getDatas() {
76 | return mDatas;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_webview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
37 |
42 |
43 |
44 |
49 |
50 |
54 |
55 |
56 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_show_img.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
27 |
28 |
35 |
36 |
41 |
42 |
43 |
50 |
51 |
55 |
56 |
63 |
64 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/RecyclerViewLoadHelper.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import android.support.v7.widget.GridLayoutManager;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.support.v7.widget.StaggeredGridLayoutManager;
7 |
8 | /**
9 | * Created by Chen Yuanming on 2016/1/28.
10 | */
11 | public class RecyclerViewLoadHelper {
12 |
13 |
14 | public static boolean isToBottom(RecyclerView recyclerView) {
15 | int lastVisibleItemPosition = -1;
16 | int[] lastPositions;
17 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
18 | if (null != layoutManager) {
19 | LAYOUT_MANAGER_TYPE layoutManagerType;
20 | if (layoutManager instanceof LinearLayoutManager) {
21 | layoutManagerType = LAYOUT_MANAGER_TYPE.LINEAR;
22 | } else if (layoutManager instanceof GridLayoutManager) {
23 | layoutManagerType = LAYOUT_MANAGER_TYPE.GRID;
24 | } else if (layoutManager instanceof StaggeredGridLayoutManager) {
25 | layoutManagerType = LAYOUT_MANAGER_TYPE.STAGGERED_GRID;
26 | } else {
27 | throw new ClassCastException(
28 | "Unsupported LayoutManager used. Valid ones are LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager");
29 | }
30 |
31 | switch (layoutManagerType) {
32 | case LINEAR:
33 | lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
34 | break;
35 | case GRID:
36 | lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
37 | break;
38 | case STAGGERED_GRID:
39 | StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
40 | lastPositions = new int[staggeredGridLayoutManager.getSpanCount()];
41 | staggeredGridLayoutManager.findLastVisibleItemPositions(lastPositions);
42 | lastVisibleItemPosition = findMax(lastPositions);
43 |
44 | break;
45 | }
46 |
47 | int visibleItemCount = layoutManager.getChildCount();
48 | int totalItemCount = layoutManager.getItemCount();
49 | if ((visibleItemCount > 0 && (lastVisibleItemPosition) >= totalItemCount - 1)) {
50 | //到达最后
51 | return true;
52 | }
53 |
54 | }
55 | return false;
56 | }
57 |
58 | private static int findMax(int[] lastPositions) {
59 | int max = lastPositions[0];
60 | for (int value : lastPositions) {
61 | if (value > max) {
62 | max = value;
63 | }
64 | }
65 | return max;
66 | }
67 |
68 | public enum LAYOUT_MANAGER_TYPE {
69 | LINEAR,
70 | GRID,
71 | STAGGERED_GRID
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/service/PrefetchService.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.IBinder;
6 | import android.support.annotation.Nullable;
7 | import android.support.annotation.UiThread;
8 | import android.util.Log;
9 | import android.webkit.WebChromeClient;
10 | import android.webkit.WebSettings;
11 | import android.webkit.WebView;
12 | import android.webkit.WebViewClient;
13 |
14 | import java.text.ParseException;
15 | import java.text.SimpleDateFormat;
16 | import java.util.Date;
17 |
18 | import cn.chenyuanming.gankmeizhi.api.GankApi;
19 | import cn.chenyuanming.gankmeizhi.constants.Constants;
20 | import rx.Observable;
21 | import rx.android.schedulers.AndroidSchedulers;
22 |
23 | /**
24 | * Created by Chen Yuanming on 2016/1/28.
25 | */
26 | public class PrefetchService extends Service {
27 | private static final String TAG = "PrefetchService";
28 |
29 | @Nullable
30 | @Override
31 | public IBinder onBind(Intent intent) {
32 | return null;
33 | }
34 |
35 | int limit = Constants.LIMIT;
36 | int pageIndex = Constants.START;
37 |
38 | @Override
39 | public void onCreate() {
40 | super.onCreate();
41 | GankApi.getInstance().getBenefitsGoods(limit, pageIndex).subscribe(goodsBean -> {
42 | Observable.from(goodsBean.results).observeOn(AndroidSchedulers.mainThread()).subscribe(results -> {
43 | //每天的结果
44 | try {
45 | Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(results.updatedAt);
46 | } catch (ParseException e) {
47 | e.printStackTrace();
48 | }
49 | load(results.url);
50 | });
51 | });
52 | }
53 |
54 | @UiThread
55 | private void load(String url) {
56 | WebView webView = new WebView(this);
57 | webView.setWebChromeClient(new WebChromeClient() {
58 | @Override
59 | public void onProgressChanged(WebView view, int newProgress) {
60 | super.onProgressChanged(view, newProgress);
61 | if (newProgress == 100) {
62 | Log.d(TAG, "onProgressChanged: " + view.getUrl());
63 | }
64 | }
65 | });
66 | webView.setWebViewClient(new WebViewClient());
67 | webView.getSettings().setBuiltInZoomControls(true);
68 | webView.getSettings().setJavaScriptEnabled(true);
69 | webView.getSettings().setDomStorageEnabled(true);
70 | webView.getSettings().setDatabaseEnabled(true);
71 | webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
72 | String cacheDirPath = getFilesDir().getAbsolutePath() + "/webviewcache";
73 | webView.getSettings().setDatabasePath(cacheDirPath);
74 | webView.getSettings().setAppCachePath(cacheDirPath);
75 | webView.getSettings().setAppCacheEnabled(true);
76 |
77 | webView.requestFocus();
78 | webView.getSettings().getAllowFileAccess();
79 |
80 | webView.loadUrl(url);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/RxMeizhi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Drakeet
3 | *
4 | * This file is part of Meizhi
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 cn.chenyuanming.gankmeizhi.utils;
21 |
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.graphics.Bitmap;
25 | import android.net.Uri;
26 | import android.os.Environment;
27 |
28 | import com.bumptech.glide.Glide;
29 |
30 | import java.io.File;
31 | import java.io.FileOutputStream;
32 | import java.io.IOException;
33 | import java.util.concurrent.ExecutionException;
34 |
35 | import rx.Observable;
36 | import rx.Subscriber;
37 | import rx.schedulers.Schedulers;
38 |
39 | /**
40 | * 简单重构了下,并且修复了重复插入图片问题
41 | * Created by drakeet on 8/10/15.
42 | */
43 | public class RxMeizhi {
44 |
45 | public static Observable saveImageAndGetPathObservable(Context context, String url, String title) {
46 | return Observable.create(new Observable.OnSubscribe() {
47 | @Override
48 | public void call(Subscriber super Bitmap> subscriber) {
49 | Bitmap bitmap = null;
50 | try {
51 | bitmap = Glide.with(context).load(url).asBitmap().into(-1, -1).get();
52 | } catch (InterruptedException e) {
53 | e.printStackTrace();
54 | } catch (ExecutionException e) {
55 | e.printStackTrace();
56 | }
57 | if (bitmap == null) {
58 | subscriber.onError(new Exception("无法下载到图片"));
59 | }
60 | subscriber.onNext(bitmap);
61 | subscriber.onCompleted();
62 | }
63 | }).flatMap(bitmap -> {
64 | File appDir = new File(Environment.getExternalStorageDirectory(), "Meizhi");
65 | if (!appDir.exists()) {
66 | appDir.mkdir();
67 | }
68 | String fileName = title.replace('/', '-') + ".jpg";
69 | File file = new File(appDir, fileName);
70 | try {
71 | FileOutputStream fos = new FileOutputStream(file);
72 | assert bitmap != null;
73 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
74 | fos.flush();
75 | fos.close();
76 | } catch (IOException e) {
77 | e.printStackTrace();
78 | }
79 |
80 | Uri uri = Uri.fromFile(file);
81 | // 通知图库更新
82 | Intent scannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
83 | context.sendBroadcast(scannerIntent);
84 | return Observable.just(uri);
85 | }).subscribeOn(Schedulers.io());
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
44 |
47 |
50 |
51 |
52 |
53 |
54 |
55 |
58 |
59 |
62 |
63 |
66 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.activity;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.graphics.PorterDuff;
7 | import android.graphics.drawable.Drawable;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.view.Menu;
11 | import android.view.MenuInflater;
12 | import android.view.MenuItem;
13 |
14 | import com.mikepenz.aboutlibraries.Libs;
15 | import com.mikepenz.aboutlibraries.LibsBuilder;
16 | import com.mikepenz.aboutlibraries.ui.LibsActivity;
17 |
18 | import cn.chenyuanming.gankmeizhi.R;
19 | import cn.chenyuanming.gankmeizhi.utils.PreferenceUtil;
20 | import cn.chenyuanming.gankmeizhi.utils.ShareUtils;
21 |
22 | /**
23 | * Created by Chen Yuanming on 2016/2/2.
24 | */
25 | public class AboutActivity extends LibsActivity {
26 |
27 | @Override
28 | public void onCreate(Bundle savedInstanceState) {
29 | setIntent(new LibsBuilder()
30 | .withActivityTitle(getResources().getString(R.string.nav_about))
31 | .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
32 | .withAboutAppName(getResources().getString(R.string.app_name))
33 | .withAboutDescription("http://chenyuanming.cn @KeepCoding")
34 | .withAboutVersionShown(true)
35 | .withAboutIconShown(true)
36 | .withAboutVersionShownCode(true)
37 | .withAboutVersionShownName(true)
38 | .withLicenseShown(true)
39 | .intent(this));
40 |
41 | super.onCreate(savedInstanceState);
42 | }
43 |
44 | @Override
45 | public void onBackPressed() {
46 | super.onBackPressed();
47 | overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_right);
48 | }
49 |
50 |
51 | @Override
52 | public boolean onCreateOptionsMenu(Menu menu) {
53 | MenuInflater inflater = getMenuInflater();
54 | inflater.inflate(R.menu.menu_about, menu);
55 | return super.onCreateOptionsMenu(menu);
56 | }
57 |
58 | @Override
59 | public boolean onPrepareOptionsMenu(Menu menu) {
60 | MenuItem item;
61 | for (int i = 0; i < menu.size(); i++) {
62 | item = menu.getItem(i);
63 | Drawable drawable = item.getIcon();
64 | drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
65 | if (item.getItemId() == R.id.action_like && PreferenceUtil.getInstance().getBooleanDefaultFalse("like")) {
66 | drawable.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
67 | }
68 | item.setIcon(drawable);
69 | }
70 | return super.onPrepareOptionsMenu(menu);
71 | }
72 |
73 |
74 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
75 | @Override
76 | public boolean onOptionsItemSelected(MenuItem item) {
77 | switch (item.getItemId()) {
78 | case android.R.id.home:
79 | finish();
80 | break;
81 | case R.id.action_share:
82 | ShareUtils.share(this);
83 | break;
84 | case R.id.action_like:
85 | Drawable drawable = item.getIcon();
86 | boolean isLiked = PreferenceUtil.getInstance().getBooleanDefaultFalse("like");
87 | if (!isLiked) {
88 | drawable.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
89 | go2StarPage();
90 |
91 | } else {
92 | drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
93 | }
94 | PreferenceUtil.getInstance().putBoolean("like", !isLiked);
95 | item.setIcon(drawable);
96 |
97 | break;
98 |
99 | }
100 | return super.onOptionsItemSelected(item);
101 | }
102 |
103 | private void go2StarPage() {
104 | Intent intent = new Intent(this, WebViewActivity.class);
105 | intent.putExtra("url", getString(R.string.project_url));
106 | intent.putExtra("objectId", "");
107 | intent.putExtra("useCache", false);
108 | startActivity(intent);
109 | }
110 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/utils/PreferenceUtil.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.content.SharedPreferences.Editor;
6 |
7 | import java.util.Map;
8 |
9 | import cn.chenyuanming.gankmeizhi.application.GankApplication;
10 |
11 | /**
12 | * Created by Chen Yuanming on 2016/2/2.
13 | */
14 | public class PreferenceUtil {
15 |
16 | private Context mContext = GankApplication.getContext();
17 | private String mName = "default";
18 |
19 | public PreferenceUtil(Context context, String name) {
20 | this.mContext = context;
21 | this.mName = name;
22 | }
23 |
24 | private SharedPreferences getSharedPreferences() {
25 | return mContext.getSharedPreferences(mName, Context.MODE_APPEND);
26 | }
27 |
28 | static PreferenceUtil instance = new PreferenceUtil(GankApplication.getContext(),"default");
29 |
30 | public static PreferenceUtil getInstance() {
31 | return instance;
32 | }
33 |
34 | public void putString(String key, String value) {
35 | SharedPreferences sharedPreferences = getSharedPreferences();
36 | Editor editor = sharedPreferences.edit();
37 | editor.putString(key, value);
38 | editor.commit();
39 | }
40 |
41 | public void putInt(String key, int value) {
42 | SharedPreferences sharedPreferences = getSharedPreferences();
43 | Editor editor = sharedPreferences.edit();
44 | editor.putInt(key, value);
45 | editor.commit();
46 | }
47 |
48 | public void putBoolean(String key, Boolean value) {
49 | SharedPreferences sharedPreferences = getSharedPreferences();
50 | Editor editor = sharedPreferences.edit();
51 | editor.putBoolean(key, value);
52 | editor.commit();
53 | }
54 |
55 | public void putLong(String key, long value) {
56 | SharedPreferences sharedPreferences = getSharedPreferences();
57 | Editor editor = sharedPreferences.edit();
58 | editor.putLong(key, value);
59 | editor.commit();
60 | }
61 |
62 | public String getString(String key) {
63 | SharedPreferences sharedPreferences = getSharedPreferences();
64 | return sharedPreferences.getString(key, "");
65 | }
66 |
67 | public String getString(String key, String aDefault) {
68 | SharedPreferences sharedPreferences = getSharedPreferences();
69 | return sharedPreferences.getString(key, aDefault);
70 | }
71 |
72 | public int getInt(String key) {
73 | SharedPreferences sharedPreferences = getSharedPreferences();
74 | return sharedPreferences.getInt(key, 0);
75 | }
76 |
77 | public int getInt(String key, int defValue) {
78 | SharedPreferences sharedPreferences = getSharedPreferences();
79 | return sharedPreferences.getInt(key, defValue);
80 | }
81 |
82 | public boolean getBoolean(String key) {
83 | SharedPreferences sharedPreferences = getSharedPreferences();
84 | return sharedPreferences.getBoolean(key, true);
85 | }
86 |
87 | public boolean getBooleanDefaultFalse(String key) {
88 | SharedPreferences sharedPreferences = getSharedPreferences();
89 | return sharedPreferences.getBoolean(key, false);
90 | }
91 |
92 | public long getLong(String key) {
93 | SharedPreferences sharedPreferences = getSharedPreferences();
94 | return sharedPreferences.getLong(key, 0);
95 | }
96 |
97 | public long getLongDefault(String key, long defValue) {
98 | SharedPreferences sharedPreferences = getSharedPreferences();
99 | return sharedPreferences.getLong(key, defValue);
100 | }
101 |
102 | public Object getValue(String key) {
103 | SharedPreferences sharedPreferences = getSharedPreferences();
104 | Map map = sharedPreferences.getAll();
105 | if (map != null && !map.isEmpty()) {
106 | return map.get(key);
107 | }
108 | return null;
109 | }
110 |
111 | public Map getAll() {
112 | SharedPreferences sharedPreferences = getSharedPreferences();
113 | Map map = sharedPreferences.getAll();
114 | return map;
115 | }
116 |
117 | public void clearData() {
118 | SharedPreferences sharedPreferences = getSharedPreferences();
119 | sharedPreferences.edit().clear().commit();
120 | }
121 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/api/GankApi.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.api;
2 |
3 | import com.google.gson.Gson;
4 | import com.squareup.okhttp.Cache;
5 | import com.squareup.okhttp.OkHttpClient;
6 |
7 | import java.io.File;
8 |
9 | import cn.chenyuanming.gankmeizhi.application.GankApplication;
10 | import cn.chenyuanming.gankmeizhi.beans.DayGoodsBean;
11 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
12 | import cn.chenyuanming.gankmeizhi.constants.Constants;
13 | import retrofit.RestAdapter;
14 | import retrofit.client.OkClient;
15 | import retrofit.converter.GsonConverter;
16 | import retrofit.http.GET;
17 | import retrofit.http.Path;
18 | import rx.Observable;
19 |
20 | /**
21 | * Created by Chen Yuanming on 2016/1/25.
22 | */
23 | public class GankApi {
24 | private static GankApi instance;
25 |
26 | private final GankService gankService;
27 | private GankApi(){
28 | Cache cache;
29 | OkHttpClient okHttpClient = null;
30 | try {
31 | File cacheDir = new File(GankApplication.getContext().getCacheDir().getPath(), "gank_cache.json");
32 | cache = new Cache(cacheDir, 10 * 1024 * 1024);
33 | okHttpClient = new OkHttpClient();
34 | okHttpClient.setCache(cache);
35 | } catch (Exception e) {
36 | e.printStackTrace();
37 | }
38 |
39 | RestAdapter restAdapter = new RestAdapter.Builder()
40 | .setEndpoint(Constants.ENDPOINT)
41 | .setClient(new OkClient(okHttpClient))
42 | .setConverter(new GsonConverter(new Gson()))
43 | // .setRequestInterceptor(mRequestInterceptor)
44 | .build();
45 | gankService = restAdapter.create(GankService.class);
46 | }
47 |
48 | public static GankApi getInstance() {
49 | if(instance==null){
50 | synchronized (GankApi.class){
51 | if(instance==null){
52 | instance = new GankApi();
53 | }
54 | }
55 | }
56 | return instance;
57 | }
58 |
59 | public interface GankService {
60 |
61 | @GET("/data/Android/{limit}/{page}")
62 | Observable getAndroidGoods(
63 | @Path("limit") int limit,
64 | @Path("page") int page
65 | );
66 |
67 | @GET("/data/iOS/{limit}/{page}")
68 | Observable getIosGoods(
69 | @Path("limit") int limit,
70 | @Path("page") int page
71 | );
72 |
73 | @GET("/data/all/{limit}/{page}")
74 | Observable getAllGoods(
75 | @Path("limit") int limit,
76 | @Path("page") int page
77 | );
78 |
79 | @GET("/data/福利/{limit}/{page}")
80 | Observable getBenefitsGoods(
81 | @Path("limit") int limit,
82 | @Path("page") int page
83 | );
84 |
85 | @GET("/day/{year}/{month}/{day}")
86 | Observable getGoodsByDay(
87 | @Path("year") int year,
88 | @Path("month") int month,
89 | @Path("day") int day
90 | );
91 | }
92 |
93 | public Observable getCommonGoods(String type, int limit, int page) {
94 | if("Android".equalsIgnoreCase(type)){
95 | return gankService.getAndroidGoods(limit, page);
96 | }
97 | if("IOS".equalsIgnoreCase(type)){
98 | return gankService.getIosGoods(limit, page);
99 | }
100 | return gankService.getAndroidGoods(limit, page);
101 | }
102 |
103 | public Observable getAndroidGoods(int limit, int page) {
104 | return gankService.getAndroidGoods(limit, page);
105 | }
106 |
107 | public Observable getIosGoods(int limit, int page) {
108 | return gankService.getIosGoods(limit, page);
109 | }
110 |
111 | public Observable getAllGoods(int limit, int page) {
112 | return gankService.getAllGoods(limit, page);
113 | }
114 |
115 | public Observable getBenefitsGoods(int limit, int page) {
116 | return gankService.getBenefitsGoods(limit, page);
117 | }
118 |
119 | public Observable getGoodsByDay(int year,int month,int day) {
120 | return gankService.getGoodsByDay(year, month,day);
121 | }
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/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/item_article.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
20 |
21 |
22 |
27 |
28 |
38 |
39 |
40 |
41 |
42 |
51 |
52 |
59 |
60 |
67 |
68 |
75 |
76 |
82 |
83 |
92 |
93 |
100 |
101 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/activity/ShowBigImageActivity.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.activity;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.PorterDuff;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.ImageView;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
14 |
15 | import java.util.TreeSet;
16 |
17 | import butterknife.Bind;
18 | import butterknife.ButterKnife;
19 | import butterknife.OnClick;
20 | import cn.chenyuanming.gankmeizhi.R;
21 | import cn.chenyuanming.gankmeizhi.beans.db.FavoriteBean;
22 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
23 | import cn.chenyuanming.gankmeizhi.utils.DbHelper;
24 | import cn.chenyuanming.gankmeizhi.utils.RxMeizhi;
25 | import cn.chenyuanming.gankmeizhi.utils.ShareUtils;
26 | import cn.chenyuanming.gankmeizhi.utils.ToastUtil;
27 | import rx.android.schedulers.AndroidSchedulers;
28 |
29 | /**
30 | * Created by livin on 2016/1/28.
31 | */
32 | public class ShowBigImageActivity extends BaseActivity {
33 | @Bind(R.id.toolbar)
34 | Toolbar toolbar;
35 | @Bind(R.id.iv_meizhi)
36 | ImageView ivMeizhi;
37 | @Bind(R.id.iv_save)
38 | ImageView ivSave;
39 | @Bind(R.id.iv_share)
40 | ImageView ivShare;
41 | @Bind(R.id.iv_favorite)
42 | ImageView ivFavorite;
43 | CommonGoodsBean.Results data;
44 |
45 | FavoriteBean favorite = DbHelper.getHelper().getData(FavoriteBean.class).get(0);
46 |
47 | @SuppressWarnings("ConstantConditions")
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.activity_show_img);
52 | ButterKnife.bind(this);
53 |
54 | setSupportActionBar(toolbar);
55 |
56 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
57 | Object object = getIntent().getSerializableExtra("data");
58 | if (object instanceof CommonGoodsBean.Results) {
59 | data = (CommonGoodsBean.Results) object;
60 | Glide.with(this).load(data.url).diskCacheStrategy(DiskCacheStrategy.ALL).into(ivMeizhi);
61 | changeFavoriteIcon(ivFavorite, favorite.favorites, data.objectId);
62 | }
63 |
64 | }
65 |
66 |
67 | @Override
68 | public boolean onOptionsItemSelected(MenuItem item) {
69 | switch (item.getItemId()) {
70 | case android.R.id.home:
71 | finish();
72 | return true;
73 | }
74 | return super.onOptionsItemSelected(item);
75 | }
76 |
77 | @OnClick({R.id.iv_save, R.id.iv_share, R.id.iv_favorite})
78 | public void onClick(View v) {
79 | switch (v.getId()) {
80 | case R.id.iv_save:
81 | ToastUtil.showShortToast("保存中...");
82 | RxMeizhi.saveImageAndGetPathObservable(this, data.url, data.desc).observeOn(AndroidSchedulers.mainThread()).subscribe(uri -> {
83 | ToastUtil.showShortToast("保存成功");
84 | });
85 | break;
86 | case R.id.iv_share:
87 | RxMeizhi.saveImageAndGetPathObservable(this, data.url, data.desc).subscribe(uri -> {
88 | ShareUtils.shareImage(ShowBigImageActivity.this, uri, data.desc);
89 | });
90 | break;
91 | case R.id.iv_favorite:
92 | onFavoriteClicked(ivFavorite, favorite.favorites, data.objectId);
93 | DbHelper.getHelper().getLiteOrm().save(favorite);
94 | break;
95 | }
96 | }
97 |
98 | private void onFavoriteClicked(ImageView ivFavorite, TreeSet favorites, String objectId) {
99 | if (favorites.contains(objectId)) {
100 | favorites.remove(objectId);
101 | } else {
102 | favorites.add(objectId);
103 | }
104 | changeFavoriteIcon(ivFavorite, favorites, objectId);
105 | }
106 |
107 | private void changeFavoriteIcon(ImageView ivFavorite, TreeSet favorites, String objectId) {
108 | Drawable drawable = ivFavorite.getDrawable();
109 | if (favorites.contains(objectId)) {
110 | drawable.setColorFilter(Color.parseColor("#ff0000"), PorterDuff.Mode.SRC_IN);
111 | ivFavorite.setImageDrawable(drawable);
112 | } else {
113 | ivFavorite.setImageResource(R.drawable.ic_favorite);
114 | }
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/res/layout/umeng_update_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
17 |
18 |
21 |
29 |
30 |
37 |
38 |
48 |
49 |
50 |
51 |
52 |
53 |
57 |
58 |
59 |
64 |
65 |
69 |
70 |
79 |
80 |
81 |
82 |
83 |
84 |
91 |
92 |
93 |
94 |
97 |
98 |
110 |
111 |
123 |
124 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/beans/CommonGoodsBean.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.beans;
2 |
3 | import com.litesuits.orm.db.annotation.PrimaryKey;
4 | import com.litesuits.orm.db.annotation.Table;
5 | import com.litesuits.orm.db.enums.AssignType;
6 |
7 | import java.io.Serializable;
8 | import java.util.List;
9 |
10 | /**
11 | * Created by Chen Yuanming on 2016/1/25.
12 | */
13 | public class CommonGoodsBean implements Serializable {
14 |
15 | /**
16 | * error : false
17 | * results : [{"who":"LHF","publishedAt":"2016-01-22T05:14:47.818Z","desc":"转战WebApp: 最适合Android开发者的WebApp框架","type":"Android","url":"http://linfaxin.com/2016/01/20/%E8%BD%AC%E6%88%98WebApp-%E6%9C%80%E9%80%82%E5%90%88Android%E5%BC%80%E5%8F%91%E8%80%85%E7%9A%84WebApp%E6%A1%86%E6%9E%B6/","used":true,"objectId":"569fa47779bc440059dac6b4","createdAt":"2016-01-20T15:15:03.976Z","updatedAt":"2016-01-22T05:14:48.413Z"},{"who":"mthli","publishedAt":"2016-01-21T04:50:42.994Z","desc":"Link Bubble 浏览器开源","type":"Android","url":"https://github.com/brave/browser-android","used":true,"objectId":"56a050f12e958a00593e84a3","createdAt":"2016-01-21T03:30:57.645Z","updatedAt":"2016-01-21T04:50:43.558Z"},{"who":"MVP","publishedAt":"2016-01-21T04:50:42.993Z","desc":"react-native-maps,一个react-native的MapView组件,适用于android和iOS","type":"Android","url":"https://github.com/lelandrichardson/react-native-maps","used":true,"objectId":"56a04c56d342d30054ddd6e4","createdAt":"2016-01-21T03:11:18.527Z","updatedAt":"2016-01-21T04:50:43.565Z"},{"who":"MVP","publishedAt":"2016-01-21T04:50:42.991Z","desc":"Picasso 图片转换器","type":"Android","url":"https://github.com/wasabeef/picasso-transformations","used":true,"objectId":"56a04c381532bc0053baa7dd","createdAt":"2016-01-21T03:10:48.317Z","updatedAt":"2016-01-21T04:50:43.515Z"},{"who":"Dear宅学长","publishedAt":"2016-01-21T04:50:42.985Z","desc":"图片处理SDK(功能蛮丰富的)","type":"Android","url":"https://github.com/jarlen/PhotoEditDemo?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io","used":true,"objectId":"569f30431532bc005411db91","createdAt":"2016-01-20T06:59:15.772Z","updatedAt":"2016-01-21T04:50:43.511Z"},{"who":"Jason","publishedAt":"2016-01-21T04:50:42.978Z","desc":"渐变的圆形进度条与轻量横向进度条","type":"Android","url":"https://github.com/lingochamp/MagicProgressWidget","used":true,"objectId":"568de0e4e4b055624a0deca3","createdAt":"2016-01-07T03:52:04.081Z","updatedAt":"2016-01-21T04:50:43.558Z"},{"who":"Jason","publishedAt":"2016-01-21T04:50:42.976Z","desc":"仿iOS的loading效果","type":"Android","url":"https://github.com/Kaopiz/KProgressHUD","used":true,"objectId":"568ddde6e4b055624a0dd880","createdAt":"2016-01-07T03:39:18.034Z","updatedAt":"2016-01-21T04:50:43.504Z"},{"who":"mthli","publishedAt":"2016-01-20T04:59:02.797Z","desc":"BlockCanary 开源了,轻松找出Android App界面卡顿元凶","type":"Android","url":"https://github.com/moduth/blockcanary","used":true,"objectId":"569efc6b7db2a20052189c7c","createdAt":"2016-01-20T03:18:03.377Z","updatedAt":"2016-01-20T04:59:03.472Z"},{"who":"Dear宅学长","publishedAt":"2016-01-20T04:59:02.796Z","desc":"仿苹果手表Launcher","type":"Android","url":"https://github.com/ZhaoKaiQiang/AppleWatchView","used":true,"objectId":"569efc68d342d30053be5ffe","createdAt":"2016-01-20T03:18:00.886Z","updatedAt":"2016-01-20T04:59:03.520Z"},{"who":"Jason","publishedAt":"2016-01-20T04:59:02.791Z","desc":"Android主题应用引擎","type":"Android","url":"https://github.com/afollestad/app-theme-engine","used":true,"objectId":"569e607379bc440059d0fe7e","createdAt":"2016-01-19T16:12:35.568Z","updatedAt":"2016-01-20T04:59:03.474Z"}]
18 | */
19 |
20 | public boolean error;
21 | /**
22 | * who : LHF
23 | * publishedAt : 2016-01-22T05:14:47.818Z
24 | * desc : 转战WebApp: 最适合Android开发者的WebApp框架
25 | * type : Android
26 | * url : http://linfaxin.com/2016/01/20/%E8%BD%AC%E6%88%98WebApp-%E6%9C%80%E9%80%82%E5%90%88Android%E5%BC%80%E5%8F%91%E8%80%85%E7%9A%84WebApp%E6%A1%86%E6%9E%B6/
27 | * used : true
28 | * objectId : 569fa47779bc440059dac6b4
29 | * createdAt : 2016-01-20T15:15:03.976Z
30 | * updatedAt : 2016-01-22T05:14:48.413Z
31 | */
32 |
33 | public List results;
34 |
35 | @Table("Info")
36 | public static class Results implements Serializable {
37 | public String who;
38 | public String publishedAt;
39 | public String desc;
40 | public String type;
41 | public String url;
42 | public boolean used;
43 | @PrimaryKey(AssignType.BY_MYSELF)
44 | public String objectId;
45 | public String createdAt;
46 | public String updatedAt;
47 | public boolean isRead;
48 |
49 | @Override
50 | public String toString() {
51 | return "Results{" +
52 | "who='" + who + '\'' +
53 | ", publishedAt='" + publishedAt + '\'' +
54 | ", desc='" + desc + '\'' +
55 | ", type='" + type + '\'' +
56 | ", url='" + url + '\'' +
57 | ", used=" + used +
58 | ", objectId='" + objectId + '\'' +
59 | ", createdAt='" + createdAt + '\'' +
60 | ", updatedAt='" + updatedAt + '\'' +
61 | '}';
62 | }
63 |
64 | @Override
65 | public boolean equals(Object o) {
66 | if (this == o) return true;
67 | if (!(o instanceof Results)) return false;
68 |
69 | Results results = (Results) o;
70 |
71 | if (desc != null ? !desc.equals(results.desc) : results.desc != null) return false;
72 | if (url != null ? !url.equals(results.url) : results.url != null) return false;
73 | return objectId != null ? objectId.equals(results.objectId) : results.objectId == null;
74 |
75 | }
76 |
77 | @Override
78 | public int hashCode() {
79 | int result = desc != null ? desc.hashCode() : 0;
80 | result = 31 * result + (url != null ? url.hashCode() : 0);
81 | result = 31 * result + (objectId != null ? objectId.hashCode() : 0);
82 | return result;
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.NavigationView;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.app.FragmentManager;
9 | import android.support.v4.app.FragmentPagerAdapter;
10 | import android.support.v4.view.GravityCompat;
11 | import android.support.v4.view.ViewPager;
12 | import android.support.v4.widget.DrawerLayout;
13 | import android.support.v7.app.AppCompatActivity;
14 | import android.support.v7.widget.Toolbar;
15 | import android.view.MenuItem;
16 |
17 | import com.umeng.update.UmengUpdateAgent;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | import butterknife.Bind;
23 | import butterknife.ButterKnife;
24 | import cn.chenyuanming.gankmeizhi.R;
25 | import cn.chenyuanming.gankmeizhi.fragment.GankFragment;
26 | import cn.chenyuanming.gankmeizhi.utils.ClipboardHelper;
27 | import cn.chenyuanming.gankmeizhi.utils.ToastUtil;
28 |
29 | public class MainActivity extends AppCompatActivity {
30 | @Bind(R.id.drawerLayout)
31 | DrawerLayout drawerLayout;
32 | @Bind(R.id.toolbar)
33 | Toolbar toolbar;
34 | @Bind(R.id.viewPager)
35 | ViewPager viewPager;
36 | @Bind(R.id.tabLayout)
37 | TabLayout tabLayout;
38 | @Bind(R.id.navigationView)
39 | NavigationView navigationView;
40 | public static final int DEFAULT_FRAG = 0;
41 | public static final String EXTRA_FRAG_TYPE = "extraFragType";
42 |
43 | @SuppressWarnings("ConstantConditions")
44 | @Override
45 | protected void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.activity_main);
48 | ButterKnife.bind(this);
49 | UmengUpdateAgent.update(this);
50 | setSupportActionBar(toolbar);
51 |
52 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
53 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
54 |
55 | setupDrawerContent(navigationView);
56 |
57 | setupViewPager(viewPager);
58 | viewPager.setCurrentItem(getIntent().getIntExtra(EXTRA_FRAG_TYPE, DEFAULT_FRAG));
59 | tabLayout.setupWithViewPager(viewPager);
60 | // startService(new Intent(this, PrefetchService.class));
61 | }
62 |
63 | @Override
64 | public boolean onOptionsItemSelected(MenuItem item) {
65 | switch (item.getItemId()) {
66 | case android.R.id.home:
67 | drawerLayout.openDrawer(GravityCompat.START);
68 | return true;
69 | }
70 | return super.onOptionsItemSelected(item);
71 | }
72 |
73 | private void setupViewPager(ViewPager viewPager) {
74 | viewPager.setOffscreenPageLimit(4);
75 | Adapter adapter = new Adapter(getSupportFragmentManager());
76 |
77 | addTab(adapter, GankFragment.FRAG_TYPE_ALL, getResources().getString(R.string.nav_all));
78 | addTab(adapter, GankFragment.FRAG_TYPE_MEIZHI, getResources().getString(R.string.nav_mm));
79 | addTab(adapter, GankFragment.FRAG_TYPE_ANDROID, getResources().getString(R.string.nav_android));
80 | addTab(adapter, GankFragment.FRAG_TYPE_IOS, getResources().getString(R.string.nav_ios));
81 |
82 | viewPager.setAdapter(adapter);
83 | }
84 |
85 | private void addTab(Adapter adapter, int fragType, String title) {
86 | adapter.addFragment(GankFragment.newInstance(fragType), title);
87 | }
88 |
89 | private void setupDrawerContent(final NavigationView navigationView) {
90 | navigationView.getHeaderView(0).findViewById(R.id.nav_weibo).setOnClickListener(v -> {
91 | ClipboardHelper.copy(MainActivity.this, getResources().getString(R.string.weibo));
92 | ToastUtil.showShortToast("微博地址[http://weibo.com/123466678]已经复制到剪贴板╮(╯_╰)╭");
93 | });
94 | navigationView.setNavigationItemSelectedListener(
95 | menuItem -> {
96 | switch (menuItem.getItemId()) {
97 | case R.id.nav_avatar:
98 | case R.id.nav_weibo:
99 |
100 | break;
101 | case R.id.nav_all:
102 | viewPager.setCurrentItem(0);
103 | drawerLayout.closeDrawers();
104 | break;
105 | case R.id.nav_mm:
106 | viewPager.setCurrentItem(1);
107 | drawerLayout.closeDrawers();
108 | break;
109 | case R.id.nav_android:
110 | viewPager.setCurrentItem(2);
111 | drawerLayout.closeDrawers();
112 | break;
113 | case R.id.nav_ios:
114 | viewPager.setCurrentItem(3);
115 | drawerLayout.closeDrawers();
116 | break;
117 | case R.id.nav_github:
118 | drawerLayout.closeDrawers();
119 | jump2Url("https://github.com/login");
120 | break;
121 | case R.id.nav_trending:
122 | drawerLayout.closeDrawers();
123 | jump2Url("https://github.com/trending?l=java");
124 | break;
125 | case R.id.nav_about:
126 | drawerLayout.closeDrawers();
127 | startActivity(new Intent(this, AboutActivity.class));
128 | break;
129 |
130 | default:
131 | return true;
132 | }
133 | return true;
134 | });
135 | }
136 |
137 | private void jump2Url(String value) {
138 | Intent intent = new Intent(MainActivity.this, WebViewActivity.class);
139 | intent.putExtra("url", value);
140 | startActivity(intent);
141 | }
142 |
143 | static class Adapter extends FragmentPagerAdapter {
144 | private final List mFragments = new ArrayList<>();
145 | private final List mFragmentTitles = new ArrayList<>();
146 |
147 | public Adapter(FragmentManager fm) {
148 | super(fm);
149 | }
150 |
151 | public void addFragment(Fragment fragment, String title) {
152 | mFragments.add(fragment);
153 | mFragmentTitles.add(title);
154 | }
155 |
156 |
157 | @Override
158 | public Fragment getItem(int position) {
159 | return mFragments.get(position);
160 | }
161 |
162 | @Override
163 | public int getCount() {
164 | return mFragments.size();
165 | }
166 |
167 | @Override
168 | public CharSequence getPageTitle(int position) {
169 | return mFragmentTitles.get(position);
170 | }
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/app/src/main/res/values/update_example_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 示例说明
6 | - 自动更新
7 | - 手动更新
8 | - 静默下载
9 | - 设置参数
10 | - 自定义流程
11 |
12 | 自动更新
13 | 手动更新
14 | 静默下载
15 | Open navigation drawer
16 | Close navigation drawer
17 | 该应用示例像您展示了自动更新SDK的各种功能,三种主要的应用场景:自动更新,手动更新,静默下载。以及自动更新各种参数的作用,最后向您展示了完全自定义流程的更新如何完成。
18 | 点击左上角打开导航列表,右上角的删除按钮用来删除已经下载好的文件和取消忽略更新,您可能会需要这个功能。
19 | 检测更新
20 | 自动更新示例,该情景模式下,如果处于wifi环境,会在进入页面时检测更新,并弹出对话框提示更新,只需要一行代码就可以实现:
21 | UmengUpdateAgent.update(context);
22 | 手动更新示例,该情景模式下,无论处于wifi环境还是移动网络环境,都会去检测更新,并且即使用户忽略了该版本也会弹出对话框提示更新,只需要一行代码就可以实现:
23 | UmengUpdateAgent.forceUpdate(context);
24 | 静默下载更新示例,该情景模式下,只有当wifi环境时才会去检测更新,发现更新后会在后台静默下载,下载成功时会弹出通知栏提示更新,只需要一行代码就可以实现:
25 | UmengUpdateAgent.silentUpdate(context);
26 | UmengUpdateAgent.setDefault();
27 | 恢复默认
28 | true
29 | false
30 | 通过这些设置函数,您可以自定义更新参数,实现不一样的更新方式。
31 | 因为以下这些设置是静态的参数,如果在应用中不止一次调用了检测更新的方法,而每次的设置都不一样,请在每次检测更新的函数之前先恢复默认设置再设置参数,避免在其他地方设置的参数影响到这次更新。
32 | 设置进行更新的网络环境, true(默认)只在wifi环境下检测更新, false在所有网络环境中均检测更新。
33 | UmengUpdateAgent.setUpdateOnlyWifi(true);
34 | UmengUpdateAgent.setUpdateOnlyWifi(false);
35 | 设置增量/全量更新, true(默认)使用增量更新, false使用全量更新。
36 | 注意:如果旧版本的apk和线上上传过的apk不完全一样,则会请求全量更新。
37 | UmengUpdateAgent.setDeltaUpdate(true);
38 | UmengUpdateAgent.setDeltaUpdate(false);
39 | 设置自动弹出更新提示,如果您要自己处理更新回调,选择自己对用户进行更新提示,请关闭自动弹出提示,避免重复弹出提示。
40 | UmengUpdateAgent.setUpdateAutoPopup(true);
41 | UmengUpdateAgent.setUpdateAutoPopup(false);
42 | 设置更新下载通知栏是否启动高级样式,高级样式在4.1及以上系统中会显示暂停/继续,取消按钮。
43 | UmengUpdateAgent.setRichNotification(true);
44 | UmengUpdateAgent.setRichNotification(false);
45 | 设置更新提示方式,我们默认的更新提示方式有两种:对话框提示和通知栏提示,通过该方法设置更新提示的样式。\nUpdateStatus.STYLE_DIALOG(默认)使用对话框进行更新提示,\nUpdateStatus.STYLE_NOTIFICATION使用通知栏进行更新提示。
46 | UmengUpdateAgent.setUpdateUIStyle(UpdateStatus.STYLE_DIALOG);
47 | UmengUpdateAgent.setUpdateUIStyle(UpdateStatus.STYLE_NOTIFICATION);
48 | UpdateStatus.STYLE_DIALOG
49 | UpdateStatus.STYLE_NOTIFICATION
50 | 您可以通过下面的方法设置回调监听,来自主处理更新检测结果,用户按键选择结果,下载状态。
51 | 因为以下这些回调监听是静态的,如果在应用中不止一次调用了检测更新的方法,而每次的设置都不一样,请在每次检测更新的函数之前先恢复默认设置再设置回调监听,避免在其他地方设置的回调监听影响到这次更新。
52 | 您可以设置更新回调来监听到检测更新的返回结果,自己处理检测更新的结果。
53 | 设置更新回调
54 | UmengUpdateAgent.setUpdateListener(null);
55 | UmengUpdateAgent.setUpdateListener(listener);
56 | 您可以设置对话框按键回调接口来监听用户的按键操作,对于选择使用通知栏提醒用户更新的方式,该回调函数监听点击通知栏后弹出的对话框按键操作。
57 | 设置对话框按键回调
58 | UmengUpdateAgent.setDialogListener(null);
59 | UmengUpdateAgent.setDialogListener(listener);
60 | 您可以设置下载回调接口,这样在自动更新下载APK开始,进行,结束或者失败的时候,可以使用该接口来做出相应的反应。
61 | 设置下载回调
62 | UmengUpdateAgent.setDownloadListener(null);
63 | UmengUpdateAgent.setDownloadListener(listener);
64 | 您可以自定义提醒更新的UI交互,通过设置更新回调和我们提供的功能函数也可以完成全部更新功能。下面展示完全自定义的更新流程:
65 | 首先您需要关闭自动弹窗,避免重复弹出提示。
66 | 您需要设置更新回调,来监听检测更新返回的结果,进行相应的处理。
67 | 现在检测更新,来检测是否有新版本。
68 | 检测更新返回的结果:
69 | \@Override\npublic void onUpdateReturned(int updateStatus, UpdateResponse response) {
70 | }
71 | \t
72 | if (updateStatus == UpdateStatus.Yes) {
73 | Toast.makeText(context, "发现更新", Toast.LENGTH_SHORT).show();
74 | if (updateStatus == UpdateStatus.No) {
75 | Toast.makeText(context, "没有更新", Toast.LENGTH_SHORT).show();
76 | if (updateStatus == UpdateStatus.NoneWifi) {
77 | Toast.makeText(context, "没有wifi", Toast.LENGTH_SHORT).show();
78 | if (updateStatus == UpdateStatus.Timeout) {
79 | Toast.makeText(context, "超时", Toast.LENGTH_SHORT).show();
80 | 现在您可以使用我们默认的UI展现方式来提示更新,并自动完成后续所有相应,也可以完全自己来处理更新提示和更新流程。
81 | 默认UI
82 | 自定义UI
83 | 默认提供了两种方式来展示更新提示:
84 | 显示对话框
85 | 显示通知栏
86 | UmengUpdateAgent.showUpdateDialog(context, response);
87 | UmengUpdateAgent.showUpdateNotification(context, response);
88 | 您也可以通过这些方法来获取到展示更新信息需要的信息来自定义更新提示界面:
89 | UmengUpdateAgent.isIgnore(context, response);
90 | 确认忽略版本
91 | UmengUpdateAgent.downloadedFile(context, response);
92 | 查找已下载文件
93 | 您可以根据这些信息构建自己的通知提示。
94 | 自定义提示
95 | UmengUpdateAgent.startDownload(context, response);
96 | 开始下载
97 | UmengUpdateAgent.startInstall(context, file);
98 | 开始安装
99 | UmengUpdateAgent.ignoreUpdate(context, response);
100 | 忽略更新
101 |
102 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/activity/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.activity;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.annotation.TargetApi;
5 | import android.graphics.Color;
6 | import android.graphics.PorterDuff;
7 | import android.graphics.drawable.Drawable;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.support.v7.widget.Toolbar;
11 | import android.text.TextUtils;
12 | import android.view.KeyEvent;
13 | import android.view.Menu;
14 | import android.view.MenuInflater;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.webkit.WebChromeClient;
18 | import android.webkit.WebSettings;
19 | import android.webkit.WebView;
20 | import android.webkit.WebViewClient;
21 | import android.widget.FrameLayout;
22 |
23 | import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout;
24 | import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection;
25 |
26 | import java.util.TreeSet;
27 |
28 | import butterknife.Bind;
29 | import butterknife.ButterKnife;
30 | import cn.chenyuanming.gankmeizhi.R;
31 | import cn.chenyuanming.gankmeizhi.beans.db.FavoriteBean;
32 | import cn.chenyuanming.gankmeizhi.utils.DbHelper;
33 | import cn.chenyuanming.gankmeizhi.utils.ShareUtils;
34 |
35 | /**
36 | * Created by Chen Yuanming on 2016/1/28.
37 | */
38 | public class WebViewActivity extends BaseActivity {
39 | @Bind(R.id.loadingFrame)
40 | FrameLayout loadingFrame;
41 | @Bind(R.id.toolbar)
42 | Toolbar toolbar;
43 | @Bind(R.id.webView)
44 | WebView webView;
45 | // @Bind(R.id.progressBar)
46 | // ProgressBar progressBar;
47 |
48 | @Bind(R.id.swipeRefreshLayout)
49 | SwipyRefreshLayout swipeRefreshLayout;
50 | String objectId = "";
51 |
52 |
53 | @SuppressWarnings("ConstantConditions")
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | setContentView(R.layout.activity_webview);
58 | ButterKnife.bind(this);
59 | setupSwipeRefreshLayout();
60 | setSupportActionBar(toolbar);
61 |
62 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
63 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close);
64 | initWebView(webView);
65 |
66 | String url = getIntent().getStringExtra("url");
67 | objectId = getIntent().getStringExtra("objectId");
68 | boolean useCache = getIntent().getBooleanExtra("useCache", true);
69 | if (useCache) {
70 | webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
71 | } else {
72 | webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
73 | }
74 | webView.loadUrl(url);
75 | }
76 |
77 | private void setupSwipeRefreshLayout() {
78 | //设置卷内的颜色
79 | swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);
80 | swipeRefreshLayout.setDirection(SwipyRefreshLayoutDirection.TOP);
81 | //设置下拉刷新监听
82 | swipeRefreshLayout.setOnRefreshListener((direction) -> {
83 | webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
84 | webView.reload();
85 | });
86 | }
87 |
88 | @Override
89 | public boolean onCreateOptionsMenu(Menu menu) {
90 | MenuInflater inflater = getMenuInflater();
91 | inflater.inflate(R.menu.menu_actions, menu);
92 | return super.onCreateOptionsMenu(menu);
93 | }
94 |
95 | @Override
96 | public boolean onPrepareOptionsMenu(Menu menu) {
97 | MenuItem item;
98 | for (int i = 0; i < menu.size(); i++) {
99 | item = menu.getItem(i);
100 | Drawable drawable = item.getIcon();
101 | drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
102 | item.setIcon(drawable);
103 | if (item.getItemId() == R.id.action_favorite) {
104 | changeFavoriteIcon(item, favorite.favorites, objectId);
105 | }
106 | }
107 |
108 | return super.onPrepareOptionsMenu(menu);
109 | }
110 |
111 | FavoriteBean favorite = DbHelper.getHelper().getData(FavoriteBean.class).get(0);
112 |
113 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
114 | @Override
115 | public boolean onOptionsItemSelected(MenuItem item) {
116 | switch (item.getItemId()) {
117 | case android.R.id.home:
118 | onBack();
119 | return true;
120 | case R.id.action_share:
121 | //TODO
122 | ShareUtils.share(this, webView.getTitle() + " " + webView.getUrl());
123 | return true;
124 | case R.id.action_favorite:
125 | onFavoriteClicked(item, favorite.favorites, objectId);
126 | return true;
127 | }
128 | return super.onOptionsItemSelected(item);
129 | }
130 |
131 | @SuppressLint("SetJavaScriptEnabled")
132 | private void initWebView(WebView webView) {
133 | webView.setWebChromeClient(new WebChromeClient() {
134 | @Override
135 | public void onProgressChanged(WebView view, int newProgress) {
136 | super.onProgressChanged(view, newProgress);
137 | // progressBar.setProgress(newProgress);
138 | if (newProgress == 100) {
139 | loadingFrame.setVisibility(View.GONE);
140 | }
141 | swipeRefreshLayout.setRefreshing(newProgress != 100);
142 | }
143 |
144 | });
145 | webView.setWebViewClient(new WebViewClient() {
146 | @Override
147 | public void onPageFinished(WebView view, String url) {
148 | super.onPageFinished(view, url);
149 | setHomeIndicator(view);
150 | }
151 | });
152 | webView.getSettings().setBuiltInZoomControls(true);
153 | webView.getSettings().setJavaScriptEnabled(true);
154 | webView.getSettings().setDomStorageEnabled(true);
155 | webView.getSettings().setDatabaseEnabled(true);
156 | webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
157 | String cacheDirPath = getFilesDir().getAbsolutePath() + "/webviewcache";
158 | webView.getSettings().setDatabasePath(cacheDirPath);
159 | webView.getSettings().setAppCachePath(cacheDirPath);
160 | webView.getSettings().setAppCacheEnabled(true);
161 |
162 | webView.requestFocus();
163 | webView.getSettings().getAllowFileAccess();
164 | }
165 |
166 | @Override
167 | public boolean onKeyDown(int keyCode, KeyEvent event) {
168 | if (keyCode == KeyEvent.KEYCODE_BACK) {
169 | onBack();
170 | }
171 | return true;
172 | }
173 |
174 | private void onBack() {
175 | if (webView != null && webView.canGoBack()) {
176 | webView.goBack();
177 | setHomeIndicator(webView);
178 | } else {
179 | finish();
180 | }
181 | }
182 |
183 | private void setHomeIndicator(WebView webView) {
184 | if (webView.canGoBack()) {
185 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back);
186 | } else {
187 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close);
188 | }
189 | }
190 |
191 | private void onFavoriteClicked(MenuItem item, TreeSet favorites, String objectId) {
192 | if (favorites.contains(objectId)) {
193 | favorites.remove(objectId);
194 | } else {
195 | favorites.add(objectId);
196 | }
197 | DbHelper.getHelper().getLiteOrm().save(favorite);
198 | changeFavoriteIcon(item, favorites, objectId);
199 | }
200 |
201 | private void changeFavoriteIcon(MenuItem item, TreeSet favorites, String objectId) {
202 | Drawable drawable = item.getIcon();
203 |
204 | if (!TextUtils.isEmpty(objectId) && favorite.favorites.contains(objectId)) {
205 | drawable.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
206 | item.setIcon(drawable);
207 | } else {
208 | drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
209 | item.setIcon(drawable);
210 | }
211 | }
212 |
213 | }
214 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/adapter/ArticleViewAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.graphics.PorterDuff;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.webkit.WebChromeClient;
13 | import android.webkit.WebSettings;
14 | import android.webkit.WebView;
15 | import android.webkit.WebViewClient;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 |
19 | import com.bumptech.glide.Glide;
20 |
21 | import java.text.ParseException;
22 | import java.text.SimpleDateFormat;
23 | import java.util.ArrayList;
24 | import java.util.Date;
25 | import java.util.List;
26 | import java.util.TreeSet;
27 |
28 | import butterknife.Bind;
29 | import butterknife.ButterKnife;
30 | import cn.chenyuanming.gankmeizhi.R;
31 | import cn.chenyuanming.gankmeizhi.activity.ShowBigImageActivity;
32 | import cn.chenyuanming.gankmeizhi.activity.WebViewActivity;
33 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
34 | import cn.chenyuanming.gankmeizhi.beans.db.FavoriteBean;
35 | import cn.chenyuanming.gankmeizhi.beans.db.ReadArticles;
36 | import cn.chenyuanming.gankmeizhi.utils.DbHelper;
37 | import cn.chenyuanming.gankmeizhi.utils.ShareUtils;
38 | import cn.chenyuanming.gankmeizhi.utils.TimeHelper;
39 |
40 | /**
41 | * Created by Chen Yuanming on 2016/1/28.
42 | */
43 | public class ArticleViewAdapter extends RecyclerView.Adapter {
44 |
45 | private List mDatas = new ArrayList<>();
46 |
47 | FavoriteBean favorite = DbHelper.getHelper().getData(FavoriteBean.class).get(0);
48 | ReadArticles readArticles = DbHelper.getHelper().getData(ReadArticles.class).get(0);
49 | static Drawable defaultShare;
50 | Date currDate = new Date();
51 |
52 | public static class ViewHolder extends RecyclerView.ViewHolder {
53 | @Bind(R.id.iv_meizhi)
54 | ImageView iv_meizhi;
55 | @Bind(R.id.tv_type)
56 | TextView tv_type;
57 | @Bind(R.id.tv_title)
58 | TextView tv_title;
59 | @Bind(R.id.tv_time)
60 | TextView tv_time;
61 | @Bind(R.id.tv_author)
62 | TextView tv_author;
63 | @Bind(R.id.iv_share)
64 | ImageView iv_share;
65 | @Bind(R.id.iv_favorite)
66 | ImageView ivFavorite;
67 | @Bind(R.id.webView)
68 | WebView webView;
69 | View mainView;
70 |
71 | public ViewHolder(View view) {
72 | super(view);
73 | ButterKnife.bind(this, view);
74 | mainView = view;
75 | defaultShare = iv_share.getDrawable();
76 | defaultShare.setColorFilter(Color.parseColor("#bfc8d6"), PorterDuff.Mode.SRC_IN);
77 | iv_share.setImageDrawable(defaultShare);
78 | }
79 | }
80 |
81 | public String getValueAt(int position) {
82 | return mDatas.get(position).desc;
83 | }
84 |
85 | Context context;
86 | int fragType;
87 |
88 | public ArticleViewAdapter(Context context, List items, int fragType) {
89 | this.context = context;
90 | if (items != null) {
91 | mDatas.addAll(items);
92 | }
93 | this.fragType = fragType;
94 | }
95 |
96 | @Override
97 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
98 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_article, parent, false);
99 | return new ViewHolder(view);
100 | }
101 |
102 | @Override
103 | public void onBindViewHolder(final ViewHolder holder, int position) {
104 | CommonGoodsBean.Results data = mDatas.get(position);
105 |
106 | holder.tv_title.setText(data.desc);
107 |
108 | try {
109 | Date publishDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(data.publishedAt);
110 | holder.tv_time.setText(TimeHelper.getTime(publishDate.getTime()));
111 | } catch (ParseException e) {
112 | holder.tv_time.setText(data.updatedAt.substring(0, data.updatedAt.indexOf("T")));
113 | e.printStackTrace();
114 | }
115 |
116 | holder.tv_author.setText("by @" + data.who);
117 | holder.tv_type.setText(data.type);
118 | if (readArticles.articles.contains(data.objectId)) {
119 | holder.tv_title.setTextColor(context.getResources().getColor(R.color.lightBlack));
120 | } else {
121 | holder.tv_title.setTextColor(context.getResources().getColor(R.color.black));
122 | }
123 |
124 |
125 | if (data.type.equals("福利") || data.type.equals("休息视频")) {
126 | if (data.type.equals("休息视频")) {
127 | holder.tv_title.setVisibility(View.GONE);
128 | holder.webView.setVisibility(View.VISIBLE);
129 | holder.iv_meizhi.setVisibility(View.GONE);
130 | initWebview(holder.webView);
131 | holder.webView.loadUrl(data.url);
132 | holder.webView.setOnClickListener(v -> {
133 | Intent intent = new Intent(context, WebViewActivity.class);
134 | intent.putExtra("url", mDatas.get(position).url);
135 | intent.putExtra("objectId", mDatas.get(position).objectId);
136 | context.startActivity(intent);
137 | });
138 | } else {
139 | holder.tv_title.setVisibility(View.GONE);
140 | holder.webView.setVisibility(View.GONE);
141 | holder.webView.stopLoading();
142 | holder.iv_meizhi.setVisibility(View.VISIBLE);
143 | Glide.with(context).load(data.url).into(holder.iv_meizhi);
144 | holder.mainView.setOnClickListener((v) -> {
145 | Intent intent = new Intent(context, ShowBigImageActivity.class);
146 | intent.putExtra("data", mDatas.get(position));
147 | context.startActivity(intent);
148 | });
149 | }
150 | } else {
151 | holder.tv_title.setVisibility(View.VISIBLE);
152 | holder.webView.setVisibility(View.GONE);
153 | holder.webView.stopLoading();
154 | holder.iv_meizhi.setVisibility(View.GONE);
155 | holder.mainView.setOnClickListener(v -> {
156 | holder.tv_title.setTextColor(context.getResources().getColor(R.color.lightBlack));
157 | Intent intent = new Intent(context, WebViewActivity.class);
158 | intent.putExtra("url", mDatas.get(position).url);
159 | intent.putExtra("objectId", mDatas.get(position).objectId);
160 | context.startActivity(intent);
161 | readArticles.articles.add(data.objectId);
162 | DbHelper.getHelper().getLiteOrm().save(readArticles);
163 | });
164 | }
165 |
166 | setFavoriteIcon(holder.ivFavorite, favorite.favorites, data.objectId);
167 | holder.ivFavorite.setOnClickListener(v -> {
168 | onFavoriteClicked(holder.ivFavorite, favorite.favorites, data.objectId);
169 | DbHelper.getHelper().getLiteOrm().save(favorite);
170 | });
171 |
172 | holder.iv_share.setOnClickListener(v -> ShareUtils.share(context, data.desc + data.url));
173 |
174 | switch (data.type) {
175 | case "Android":
176 | holder.tv_type.setBackgroundResource(R.drawable.shape_type_android);
177 | break;
178 | case "iOS":
179 | holder.tv_type.setBackgroundResource(R.drawable.shape_type_ios);
180 | break;
181 | case "拓展资源":
182 | case "App":
183 | holder.tv_type.setBackgroundResource(R.drawable.shape_type_extend);
184 | break;
185 | case "休息视频":
186 | default:
187 | holder.tv_type.setBackgroundResource(R.drawable.shape_type_relax);
188 | break;
189 | }
190 | }
191 |
192 | private void initWebview(WebView webView) {
193 | webView.setWebChromeClient(new WebChromeClient());
194 | webView.setWebViewClient(new WebViewClient());
195 | webView.getSettings().setBuiltInZoomControls(true);
196 | webView.getSettings().setJavaScriptEnabled(true);
197 | webView.getSettings().setDomStorageEnabled(true);
198 | webView.getSettings().setDatabaseEnabled(true);
199 | webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
200 | webView.getSettings().setAppCacheEnabled(true);
201 |
202 | webView.requestFocus();
203 | webView.getSettings().getAllowFileAccess();
204 | }
205 |
206 | private void onFavoriteClicked(ImageView ivFavorite, TreeSet favorites, String objectId) {
207 | if (favorites.contains(objectId)) {
208 | favorites.remove(objectId);
209 | } else {
210 | favorites.add(objectId);
211 | }
212 | setFavoriteIcon(ivFavorite, favorites, objectId);
213 | }
214 |
215 | private void setFavoriteIcon(ImageView ivFavorite, TreeSet favorites, String objectId) {
216 | Drawable drawable = ivFavorite.getDrawable();
217 | if (favorites.contains(objectId)) {
218 | drawable.setColorFilter(Color.parseColor("#ff0000"), PorterDuff.Mode.SRC_IN);
219 | ivFavorite.setImageDrawable(drawable);
220 | } else {
221 | drawable.setColorFilter(Color.parseColor("#bfc8d6"), PorterDuff.Mode.SRC_IN);
222 | ivFavorite.setImageDrawable(drawable);
223 | }
224 | }
225 |
226 | @Override
227 | public int getItemCount() {
228 | return mDatas.size();
229 | }
230 |
231 | public List getDatas() {
232 | return mDatas;
233 | }
234 |
235 | }
236 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/chenyuanming/gankmeizhi/fragment/GankFragment.java:
--------------------------------------------------------------------------------
1 | package cn.chenyuanming.gankmeizhi.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.support.v7.widget.StaggeredGridLayoutManager;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 |
17 | import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout;
18 | import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import java.util.concurrent.TimeUnit;
23 |
24 | import butterknife.Bind;
25 | import butterknife.ButterKnife;
26 | import cn.chenyuanming.gankmeizhi.R;
27 | import cn.chenyuanming.gankmeizhi.adapter.ArticleViewAdapter;
28 | import cn.chenyuanming.gankmeizhi.adapter.MeizhiAdapter;
29 | import cn.chenyuanming.gankmeizhi.api.GankApi;
30 | import cn.chenyuanming.gankmeizhi.beans.CommonGoodsBean;
31 | import cn.chenyuanming.gankmeizhi.beans.db.DbGoodsBean;
32 | import cn.chenyuanming.gankmeizhi.constants.Constants;
33 | import cn.chenyuanming.gankmeizhi.decoration.SpacesItemDecoration;
34 | import cn.chenyuanming.gankmeizhi.utils.DbHelper;
35 | import rx.Observable;
36 | import rx.android.schedulers.AndroidSchedulers;
37 | import rx.functions.Action1;
38 |
39 | public class GankFragment extends BaseFragment {
40 | @Bind(R.id.recyclerview)
41 | RecyclerView recyclerView;
42 |
43 | @Bind(R.id.swipeRefreshLayout)
44 | SwipyRefreshLayout swipeRefreshLayout;
45 |
46 | private static final String TAG = "GankFragment";
47 | public static final int FRAG_TYPE_ALL = 1;
48 | public static final int FRAG_TYPE_MEIZHI = 2;
49 | public static final int FRAG_TYPE_ANDROID = 3;
50 | public static final int FRAG_TYPE_IOS = 4;
51 |
52 | public static final String ARG_FRAG_TYPE = "frag_arg_type";
53 |
54 | private int thisFragType = 1;
55 | static int limit = Constants.LIMIT;
56 | static int currentPage = Constants.START;
57 | ArticleViewAdapter allAdapter;
58 | MeizhiAdapter meizhiAdapter;
59 |
60 | Handler handler = new Handler() {
61 | @Override
62 | public void handleMessage(Message msg) {
63 | super.handleMessage(msg);
64 | swipeRefreshLayout.setRefreshing(true);
65 | }
66 | };
67 |
68 | public static Fragment newInstance(int type) {
69 | GankFragment fragment = new GankFragment();
70 | Bundle bundle = new Bundle();
71 | bundle.putInt(ARG_FRAG_TYPE, type);
72 | fragment.setArguments(bundle);
73 | return fragment;
74 | }
75 |
76 |
77 | @Nullable
78 | @Override
79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
80 | View view = inflater.inflate(R.layout.fragment_article_list, container, false);
81 | ButterKnife.bind(this, view);
82 | setupAdapter();
83 | setupSwipeRefreshLayout();
84 | currentPage = Constants.START;
85 |
86 | return view;
87 | }
88 |
89 | @Override
90 | public void onResume() {
91 | super.onResume();
92 | if (!isLoadCache()) {
93 | loadData(currentPage);
94 | handler.sendEmptyMessageDelayed(0, 1);
95 | }
96 | }
97 |
98 | private void setupSwipeRefreshLayout() {
99 | //设置卷内的颜色
100 | swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);
101 | swipeRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH);
102 | //设置下拉刷新监听
103 | swipeRefreshLayout.setOnRefreshListener((direction) -> {
104 |
105 |
106 | clearAdapterCache(direction);
107 | clearDbCache();
108 | loadData(currentPage);
109 | });
110 |
111 |
112 | }
113 |
114 | private void clearDbCache() {
115 | switch (thisFragType) {
116 | case FRAG_TYPE_ALL:
117 | dbGoodsBean.allResults.clear();
118 | break;
119 | case FRAG_TYPE_MEIZHI:
120 | dbGoodsBean.meizhiResults.clear();
121 | break;
122 | case FRAG_TYPE_ANDROID:
123 | dbGoodsBean.androidResults.clear();
124 | break;
125 | case FRAG_TYPE_IOS:
126 | dbGoodsBean.iosResults.clear();
127 | break;
128 | }
129 | }
130 |
131 | private void clearAdapterCache(SwipyRefreshLayoutDirection direction) {
132 | if (direction == SwipyRefreshLayoutDirection.TOP) {
133 | currentPage = Constants.START;
134 | if (allAdapter != null) {
135 | allAdapter.getDatas().clear();
136 | }
137 | if (meizhiAdapter != null) {
138 | meizhiAdapter.getDatas().clear();
139 | }
140 | }
141 | }
142 |
143 | private void setupAdapter() {
144 | thisFragType = getArguments().getInt(ARG_FRAG_TYPE, 0);
145 | if (thisFragType == FRAG_TYPE_MEIZHI) {
146 | recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
147 | SpacesItemDecoration decoration = new SpacesItemDecoration(16);
148 | recyclerView.addItemDecoration(decoration);
149 | meizhiAdapter = new MeizhiAdapter(getActivity(), null);
150 | recyclerView.setAdapter(meizhiAdapter);
151 | } else {
152 | recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
153 | allAdapter = new ArticleViewAdapter(getActivity(), null, thisFragType);
154 | recyclerView.setAdapter(allAdapter);
155 | }
156 | }
157 |
158 | private void loadData(int pageIndex) {
159 | //timeout
160 | Observable.timer(10, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(time -> swipeRefreshLayout.setRefreshing(false));
161 | switch (thisFragType) {
162 | case FRAG_TYPE_ALL:
163 | GankApi.getInstance().getAllGoods(limit, pageIndex).observeOn(AndroidSchedulers.mainThread()).subscribe(getGoodsBeanAction(), e -> showNoNetWorkToast(e));
164 | break;
165 | case FRAG_TYPE_MEIZHI:
166 | GankApi.getInstance().getBenefitsGoods(limit, pageIndex).observeOn(AndroidSchedulers.mainThread()).subscribe(getGoodsBeanAction(), e -> showNoNetWorkToast(e));
167 | break;
168 | case FRAG_TYPE_ANDROID:
169 | GankApi.getInstance().getAndroidGoods(limit, pageIndex).observeOn(AndroidSchedulers.mainThread()).subscribe(getGoodsBeanAction(), e -> showNoNetWorkToast(e));
170 | break;
171 | case FRAG_TYPE_IOS:
172 | GankApi.getInstance().getIosGoods(limit, pageIndex).observeOn(AndroidSchedulers.mainThread()).subscribe(getGoodsBeanAction(), e -> showNoNetWorkToast(e));
173 | break;
174 | }
175 | }
176 |
177 | private void showNoNetWorkToast(Throwable e) {
178 | Log.d(TAG, "showNoNetWorkToast() called with: " + "e = [" + e + "]");
179 | if (swipeRefreshLayout.isRefreshing()) {
180 | swipeRefreshLayout.setRefreshing(false);
181 | }
182 | // ToastUtil.showShortToast("网络不给力,请稍后再试");
183 | }
184 |
185 | private boolean isLoadCache() {
186 | List datas = loadDataFromDb();
187 | if (datas != null && datas.size() > 0) {
188 | currentPage = datas.size() / Constants.LIMIT; //如果有缓存,加载更多处理
189 | setupRecyclerView(datas);
190 | return true;
191 | }
192 | return false;
193 | }
194 |
195 | private List loadDataFromDb() {
196 | DbGoodsBean dbGoodsBean = DbHelper.getHelper().getData(DbGoodsBean.class).get(0);
197 | List datas = new ArrayList<>();
198 | switch (thisFragType) {
199 | case FRAG_TYPE_ALL:
200 | datas = dbGoodsBean.allResults;
201 | break;
202 | case FRAG_TYPE_MEIZHI:
203 | datas = dbGoodsBean.meizhiResults;
204 | break;
205 | case FRAG_TYPE_ANDROID:
206 | datas = dbGoodsBean.androidResults;
207 | break;
208 | case FRAG_TYPE_IOS:
209 | datas = dbGoodsBean.iosResults;
210 | break;
211 | }
212 | return datas;
213 | }
214 |
215 | DbGoodsBean dbGoodsBean = DbHelper.getHelper().getData(DbGoodsBean.class).get(0);
216 |
217 | @NonNull
218 | private Action1 getGoodsBeanAction() {
219 | return goodsBean -> {
220 |
221 | setupRecyclerView(goodsBean.results);
222 | saveData2Db(goodsBean);
223 | Log.i(TAG, thisFragType + "onCreateView: " + goodsBean.results);
224 | };
225 | }
226 |
227 | private void saveData2Db(CommonGoodsBean goodsBean) {
228 | switch (thisFragType) {
229 | case FRAG_TYPE_ALL:
230 | dbGoodsBean.allResults.addAll(goodsBean.results);
231 | break;
232 | case FRAG_TYPE_MEIZHI:
233 | dbGoodsBean.meizhiResults.addAll(goodsBean.results);
234 | break;
235 | case FRAG_TYPE_ANDROID:
236 | dbGoodsBean.androidResults.addAll(goodsBean.results);
237 | break;
238 | case FRAG_TYPE_IOS:
239 | dbGoodsBean.iosResults.addAll(goodsBean.results);
240 | break;
241 | }
242 |
243 | DbHelper.getHelper().getLiteOrm().save(dbGoodsBean);
244 | }
245 |
246 | private void setupRecyclerView(List results) {
247 | if (swipeRefreshLayout.isRefreshing()) {
248 | swipeRefreshLayout.setRefreshing(false);
249 | }
250 | if (results.size() > 0) {
251 | currentPage++;
252 | }
253 | switch (thisFragType) {
254 | case (FRAG_TYPE_MEIZHI):
255 | if (currentPage == Constants.START) {
256 | meizhiAdapter.getDatas().clear();
257 | }
258 | results.removeAll(meizhiAdapter.getDatas());
259 | meizhiAdapter.getDatas().addAll(results);
260 | // meizhiAdapter.notifyItemRangeChanged(meizhiAdapter.getItemCount() - results.size(), results.size());
261 | meizhiAdapter.notifyDataSetChanged();
262 | break;
263 | default:
264 | if (currentPage == Constants.START) {
265 | allAdapter.getDatas().clear();
266 | }
267 | results.removeAll(allAdapter.getDatas());
268 | allAdapter.getDatas().addAll(results);
269 | // allAdapter.notifyItemRangeChanged(allAdapter.getItemCount() - results.size(), results.size());
270 | allAdapter.notifyDataSetChanged();
271 | break;
272 | }
273 | }
274 |
275 |
276 | }
--------------------------------------------------------------------------------