├── app
├── .gitignore
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── logo.png
│ │ │ │ ├── default_avatar.png
│ │ │ │ ├── ic_item_like.png
│ │ │ │ ├── ic_item_liked.png
│ │ │ │ ├── ic_item_comment.png
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ ├── ic_close_white_24dp.png
│ │ │ │ ├── ic_done_white_24dp.png
│ │ │ │ ├── ic_home_theme_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_share_white_24dp.png
│ │ │ │ ├── main_nav_header_bg.png
│ │ │ │ ├── ic_delete_white_24dp.png
│ │ │ │ ├── ic_favorite_grey_24dp.png
│ │ │ │ ├── ic_home_grey600_24dp.png
│ │ │ │ ├── ic_refresh_white_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_subject_theme_24dp.png
│ │ │ │ ├── ic_arrow_back_white_24dp.png
│ │ │ │ ├── ic_comment_grey600_18dp.png
│ │ │ │ ├── ic_comment_grey600_24dp.png
│ │ │ │ ├── ic_favorite_grey600_24dp.png
│ │ │ │ ├── ic_favorite_theme_24dp.png
│ │ │ │ ├── ic_subject_grey600_24dp.png
│ │ │ │ ├── ic_thumb_up_grey600_18dp.png
│ │ │ │ ├── ic_description_theme_24dp.png
│ │ │ │ ├── abc_ic_menu_share_mtrl_alpha.png
│ │ │ │ ├── ic_description_grey600_24dp.png
│ │ │ │ ├── main_nav_ic_setting_grey_24dp.png
│ │ │ │ ├── main_nav_ic_feedback_grey_24dp.png
│ │ │ │ ├── ic_assignment_turned_in_theme_24dp.png
│ │ │ │ ├── abc_ic_menu_moreoverflow_mtrl_alpha.png
│ │ │ │ └── ic_assignment_turned_in_grey600_24dp.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── main_nav_header_bg.png
│ │ │ ├── drawable
│ │ │ │ ├── btn_grid_nopress.xml
│ │ │ │ ├── btn_grid_press.xml
│ │ │ │ ├── ic_banner_bottom_bg.xml
│ │ │ │ ├── ic_nav_header_bg.xml
│ │ │ │ ├── ic_banner_indicator_selected.xml
│ │ │ │ ├── ic_banner_indicator_unselected.xml
│ │ │ │ ├── side_nav_bar.xml
│ │ │ │ ├── btn_gridview.xml
│ │ │ │ ├── ic_arrow_back_black_24dp.xml
│ │ │ │ ├── web_progress_bar.xml
│ │ │ │ ├── bg_launch.xml
│ │ │ │ └── ic_download_24dp.xml
│ │ │ ├── layout
│ │ │ │ ├── view_home_choice_header_item.xml
│ │ │ │ ├── activity_launch.xml
│ │ │ │ ├── fragment_home_find.xml
│ │ │ │ ├── fragment_home_subscribe.xml
│ │ │ │ ├── msg_notice.xml
│ │ │ │ ├── view_home_banner.xml
│ │ │ │ ├── app_bar_main.xml
│ │ │ │ ├── content_main.xml
│ │ │ │ ├── activity_feedback.xml
│ │ │ │ ├── activity_business_coop.xml
│ │ │ │ ├── common_titlebar.xml
│ │ │ │ ├── fragment_home_choice.xml
│ │ │ │ ├── fragment_share.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── view_banner_item.xml
│ │ │ │ ├── nav_header_main.xml
│ │ │ │ ├── fragment_home.xml
│ │ │ │ ├── view_home_choice_item.xml
│ │ │ │ ├── activity_notedetails.xml
│ │ │ │ └── activity_setting.xml
│ │ │ ├── anim
│ │ │ │ ├── bottom_show.xml
│ │ │ │ └── bottom_dismiss.xml
│ │ │ ├── drawable-v21
│ │ │ │ ├── ic_menu_send.xml
│ │ │ │ ├── ic_menu_slideshow.xml
│ │ │ │ ├── ic_menu_gallery.xml
│ │ │ │ ├── ic_menu_manage.xml
│ │ │ │ ├── ic_menu_camera.xml
│ │ │ │ └── ic_menu_share.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_add_share.xml
│ │ │ │ ├── menu_add_subject.xml
│ │ │ │ ├── main.xml
│ │ │ │ ├── menu_home.xml
│ │ │ │ ├── activity_notedetail_toolsbar.xml
│ │ │ │ └── activity_main_drawer.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── drawables.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ └── strings.xml
│ │ │ ├── xml
│ │ │ │ └── setting.xml
│ │ │ └── values-v21
│ │ │ │ └── styles.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── hhl
│ │ │ │ └── devheadline
│ │ │ │ ├── core
│ │ │ │ ├── Core.java
│ │ │ │ └── net
│ │ │ │ │ ├── ApiService.java
│ │ │ │ │ └── RetrofitFactory.java
│ │ │ │ ├── ui
│ │ │ │ ├── iview
│ │ │ │ │ ├── ISettingView.java
│ │ │ │ │ ├── IFeedbackView.java
│ │ │ │ │ ├── IHomeFindView.java
│ │ │ │ │ ├── INavShareView.java
│ │ │ │ │ ├── IHomeSubscribeView.java
│ │ │ │ │ ├── INoteDetailsView.java
│ │ │ │ │ ├── IMainView.java
│ │ │ │ │ ├── IBaseView.java
│ │ │ │ │ ├── ILaunchView.java
│ │ │ │ │ ├── INavHomeView.java
│ │ │ │ │ └── IHomeChoiceView.java
│ │ │ │ ├── fragment
│ │ │ │ │ ├── HomeFindFragment.java
│ │ │ │ │ ├── HomeSubscribeFragment.java
│ │ │ │ │ ├── ShareFragment.java
│ │ │ │ │ ├── BaseFragment.java
│ │ │ │ │ ├── HomeFragment.java
│ │ │ │ │ └── HomeChoiceFragment.java
│ │ │ │ ├── view
│ │ │ │ │ ├── DHLSwipeRefreshLayout.java
│ │ │ │ │ └── ColorUtils.java
│ │ │ │ ├── activity
│ │ │ │ │ ├── BusinessCoopActivity.java
│ │ │ │ │ ├── FeedbackActivity.java
│ │ │ │ │ ├── LaunchActivity.java
│ │ │ │ │ ├── SettingActivity.java
│ │ │ │ │ ├── BaseActivity.java
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ └── NoteDetailsActivity.java
│ │ │ │ └── adapter
│ │ │ │ │ ├── RecyclerViewBaseAdapter.java
│ │ │ │ │ ├── HomeAdapter.java
│ │ │ │ │ └── HomeChoiceAdapter.java
│ │ │ │ ├── model
│ │ │ │ ├── resp
│ │ │ │ │ ├── BaseResp.java
│ │ │ │ │ ├── BannerResp.java
│ │ │ │ │ └── ArticleResp.java
│ │ │ │ ├── Banner.java
│ │ │ │ └── Article.java
│ │ │ │ ├── presenter
│ │ │ │ ├── MainPresenter.java
│ │ │ │ ├── SettingPresenter.java
│ │ │ │ ├── FeedbackPresenter.java
│ │ │ │ ├── HomeFindPresenter.java
│ │ │ │ ├── NavSharePresenter.java
│ │ │ │ ├── NoteDetailsPresenter.java
│ │ │ │ ├── HomeSubscribePresenter.java
│ │ │ │ ├── LaunchPresenter.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ ├── NavHomePresenter.java
│ │ │ │ └── HomeChoicePresenter.java
│ │ │ │ ├── DevHeadLineApplication.java
│ │ │ │ └── utils
│ │ │ │ ├── L.java
│ │ │ │ ├── ToastUtils.java
│ │ │ │ └── AppTools.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── hhl
│ │ │ └── devheadline
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── hhl
│ │ └── devheadline
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
├── gradlew.bat
└── gradlew
├── settings.gradle
├── screenshot
├── home.png
└── devheadline.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── Project.md
├── README.md
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshot/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/screenshot/home.png
--------------------------------------------------------------------------------
/screenshot/devheadline.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/screenshot/devheadline.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/default_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_item_like.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_item_like.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_item_liked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_item_liked.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_item_comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_item_comment.png
--------------------------------------------------------------------------------
/Project.md:
--------------------------------------------------------------------------------
1 | # 项目工程结构图
2 | 目前项目构思是这样
3 |
4 | # 包结构
5 | * com.hhl.devheadline.model.** 下面的
6 | 为了防止方法数超过65535这个极限值,所有的model属性采用public,禁止private属性,禁止添加set和get方法
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_home_theme_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_home_theme_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/main_nav_header_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/main_nav_header_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/main_nav_header_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xxhdpi/main_nav_header_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorite_grey_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_favorite_grey_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_home_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_home_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_refresh_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_refresh_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_subject_theme_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_subject_theme_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_comment_grey600_18dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_comment_grey600_18dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_comment_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_comment_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorite_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_favorite_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorite_theme_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_favorite_theme_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_subject_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_subject_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_thumb_up_grey600_18dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_thumb_up_grey600_18dp.png
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/core/Core.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.core;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/16.
5 | */
6 | public class Core {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_description_theme_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_description_theme_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/abc_ic_menu_share_mtrl_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/abc_ic_menu_share_mtrl_alpha.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_description_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_description_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/main_nav_ic_setting_grey_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/main_nav_ic_setting_grey_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/main_nav_ic_feedback_grey_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/main_nav_ic_feedback_grey_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_assignment_turned_in_theme_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_assignment_turned_in_theme_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/abc_ic_menu_moreoverflow_mtrl_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/abc_ic_menu_moreoverflow_mtrl_alpha.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_assignment_turned_in_grey600_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanhailong/DevHeadLine/HEAD/app/src/main/res/drawable-xhdpi/ic_assignment_turned_in_grey600_24dp.png
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/ISettingView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/15.
5 | */
6 | public interface ISettingView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IFeedbackView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/15.
5 | */
6 | public interface IFeedbackView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IHomeFindView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/16.
5 | */
6 | public interface IHomeFindView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/INavShareView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/15.
5 | */
6 | public interface INavShareView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_grid_nopress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_grid_press.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IHomeSubscribeView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/16.
5 | */
6 | public interface IHomeSubscribeView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/INoteDetailsView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by Administrator on 2016/3/29.
5 | */
6 | public interface INoteDetailsView extends IBaseView {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IMainView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/15.
5 | */
6 | public interface IMainView extends IBaseView {
7 |
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IBaseView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * the base interface of all views
5 | *
6 | * Created by HanHailong on 16/3/15.
7 | */
8 | public interface IBaseView {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/model/resp/BaseResp.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.model.resp;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/16.
5 | */
6 | public class BaseResp {
7 | public int errcode;
8 | public int ret;
9 | public String msg;
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/ILaunchView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/15.
5 | */
6 | public interface ILaunchView extends IBaseView {
7 | /**
8 | * 跳转到主页面
9 | */
10 | void goMain();
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_banner_bottom_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_header_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_home_choice_header_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/bottom_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/bottom_dismiss.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_banner_indicator_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launch.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_banner_indicator_unselected.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home_find.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home_subscribe.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/msg_notice.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.IMainView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/15.
7 | */
8 | public class MainPresenter extends BasePresenter {
9 |
10 | public MainPresenter(IMainView view) {
11 | super(view);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_add_share.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_add_subject.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/SettingPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.ISettingView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/15.
7 | */
8 | public class SettingPresenter extends BasePresenter {
9 | public SettingPresenter(ISettingView view) {
10 | super(view);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/FeedbackPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.IFeedbackView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/15.
7 | */
8 | public class FeedbackPresenter extends BasePresenter {
9 | public FeedbackPresenter(IFeedbackView view) {
10 | super(view);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/HomeFindPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.IHomeFindView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/16.
7 | */
8 | public class HomeFindPresenter extends BasePresenter {
9 | public HomeFindPresenter(IHomeFindView view) {
10 | super(view);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/INavHomeView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | import com.hhl.devheadline.ui.fragment.BaseFragment;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by HanHailong on 16/3/15.
9 | */
10 | public interface INavHomeView extends IBaseView {
11 |
12 | void loadTabData(List list, List titles);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_gridview.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/NavSharePresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.INavShareView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/15.
7 | */
8 | public class NavSharePresenter extends BasePresenter {
9 |
10 | public NavSharePresenter(INavShareView view) {
11 | super(view);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_home_banner.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/NoteDetailsPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.INoteDetailsView;
4 |
5 | /**
6 | * Created by Administrator on 2016/3/29.
7 | */
8 | public class NoteDetailsPresenter extends BasePresenter {
9 | public NoteDetailsPresenter(INoteDetailsView view){
10 | super(view);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hhl/devheadline/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/HomeSubscribePresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.iview.IHomeSubscribeView;
4 |
5 | /**
6 | * Created by HanHailong on 16/3/16.
7 | */
8 | public class HomeSubscribePresenter extends BasePresenter {
9 | public HomeSubscribePresenter(IHomeSubscribeView view) {
10 | super(view);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hhl/devheadline/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/web_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 210dp
5 |
6 | 16dp
7 | 16dp
8 | 16dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_launch.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/model/resp/BannerResp.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.model.resp;
2 |
3 | import com.hhl.devheadline.model.Banner;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by HanHailong on 16/3/16.
9 | */
10 | public class BannerResp extends BaseResp {
11 |
12 | private List data;
13 |
14 | public List getData() {
15 | return data;
16 | }
17 |
18 | public void setData(List data) {
19 | this.data = data;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DevHeadLine
2 | 高仿开发者头条,高仿程度尽量逼真真实,目前完成了初步的UI,我打算整体架构采用主流的MVP设计模式,网络请求采用Retrofit2+RxJava,
3 | 图片采用Fresco,如果用到数据库的话采用Realm,总之,尽量采用目前主流框架和设计模式!!!
4 |
5 | # 效果图
6 |
7 | 16/3/18新添加静态效果图
8 | 
9 |
10 | 动态效果图
11 |
12 | 
13 |
14 | # 修改日期
15 |
16 | * 16/5/24 修改启动页,解决app初始启动时不显示logo的bug
17 | * 16/3/18 添加首页数据
18 | * 16/3/17 封装Retrofit2+RxJava,添加首页Banner,并集成开发者头条的Banner接口
19 | * 16/3/16 添加Retrofit2.0
20 | * 16/3/15 添加MVP、fresco
21 |
22 | # TODO
23 |
24 | 1. 构建MVP
25 | 2. 抓包开发者头条数据
26 | 3. 其他
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_feedback.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | ### Android template
10 | # Built application files
11 | *.apk
12 | *.ap_
13 |
14 | # Files for the Dalvik VM
15 | *.dex
16 |
17 | # Java class files
18 | *.class
19 |
20 | # Generated files
21 | bin/
22 | gen/
23 |
24 | # Gradle files
25 | .gradle/
26 | build/
27 |
28 | # Local configuration file (sdk path, etc)
29 | local.properties
30 |
31 | # Proguard folder generated by Eclipse
32 | proguard/
33 |
34 | # Log Files
35 | *.log
36 |
37 | # Android Studio Navigation editor temp files
38 | .navigation/
39 | .idea
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_business_coop.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_notedetail_toolsbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/LaunchPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import android.os.Handler;
4 |
5 | import com.hhl.devheadline.ui.iview.ILaunchView;
6 |
7 | /**
8 | * Created by HanHailong on 16/3/15.
9 | */
10 | public class LaunchPresenter extends BasePresenter {
11 |
12 | public LaunchPresenter(ILaunchView view) {
13 | super(view);
14 | }
15 |
16 | /**
17 | * 跳转到主页面
18 | */
19 | public void launchToMain() {
20 | new Handler().postDelayed(new Runnable() {
21 | @Override
22 | public void run() {
23 | mView.goMain();
24 | }
25 | }, 1500);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/common_titlebar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/HanHailong/Library/Android/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/java/com/hhl/devheadline/DevHeadLineApplication.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.drawee.backends.pipeline.Fresco;
6 |
7 | /**
8 | * Created by HanHailong on 16/3/15.
9 | */
10 | public class DevHeadLineApplication extends Application {
11 |
12 | private static DevHeadLineApplication mInstance;
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 |
18 | Fresco.initialize(this);
19 | mInstance = this;
20 | }
21 |
22 | /**
23 | * 获取唯一Application
24 | *
25 | * @return
26 | */
27 | public static DevHeadLineApplication getInstance() {
28 | return mInstance;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/core/net/ApiService.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.core.net;
2 |
3 | import com.hhl.devheadline.model.resp.ArticleResp;
4 | import com.hhl.devheadline.model.resp.BannerResp;
5 |
6 | import retrofit2.http.GET;
7 | import rx.Observable;
8 |
9 | /**
10 | * Created by HanHailong on 16/3/16.
11 | */
12 | public interface ApiService {
13 |
14 | /**
15 | * 获取Banner列表
16 | */
17 | @GET("banner?app_key=u1ntgkc99st7sdhqjo5p×tamp=1458135621&signature=de53ae34c31ce857ea881102a100c7fb2d76aa36")
18 | Observable loadBannerList();
19 |
20 | @GET("dailies/latest?app_key=u1ntgkc99st7sdhqjo5p×tamp=1458230053&signature=0eeb89c7d2355de81c007d74869d9567e39210f2")
21 | Observable loadArticleList();
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/HomeFindFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.view.View;
4 |
5 | import com.hhl.devheadline.R;
6 | import com.hhl.devheadline.presenter.HomeFindPresenter;
7 | import com.hhl.devheadline.ui.iview.IHomeFindView;
8 |
9 | /**
10 | * Created by HanHailong on 16/3/15.
11 | */
12 | public class HomeFindFragment extends BaseFragment implements IHomeFindView {
13 | @Override
14 | protected int getContentView() {
15 | return R.layout.fragment_home_find;
16 | }
17 |
18 | @Override
19 | protected HomeFindPresenter getPresenter() {
20 | return new HomeFindPresenter(this);
21 | }
22 |
23 | @Override
24 | protected void init(View view) {
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/iview/IHomeChoiceView.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.iview;
2 |
3 | import com.hhl.devheadline.model.Article;
4 | import com.hhl.devheadline.model.Banner;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by HanHailong on 16/3/16.
10 | */
11 | public interface IHomeChoiceView extends IBaseView {
12 |
13 | /**
14 | * 填充Banner列表数据
15 | *
16 | * @param list
17 | */
18 | void fillBannerData(List list);
19 |
20 | /**
21 | * 加载失败
22 | *
23 | * @param e
24 | */
25 | void loadError(Throwable e);
26 |
27 | /**
28 | * 加载完成
29 | */
30 | void loadComplete();
31 |
32 | /**
33 | * 填充
34 | *
35 | * @param list
36 | */
37 | void fillArticleList(List list);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/HomeSubscribeFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.view.View;
4 |
5 | import com.hhl.devheadline.R;
6 | import com.hhl.devheadline.presenter.HomeSubscribePresenter;
7 | import com.hhl.devheadline.ui.iview.IHomeSubscribeView;
8 |
9 | /**
10 | * Created by HanHailong on 16/3/15.
11 | */
12 | public class HomeSubscribeFragment extends BaseFragment implements IHomeSubscribeView {
13 | @Override
14 | protected int getContentView() {
15 | return R.layout.fragment_home_subscribe;
16 | }
17 |
18 | @Override
19 | protected HomeSubscribePresenter getPresenter() {
20 | return new HomeSubscribePresenter(this);
21 | }
22 |
23 | @Override
24 | protected void init(View view) {
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/view/DHLSwipeRefreshLayout.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.view;
2 |
3 | import android.content.Context;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 | import android.util.AttributeSet;
6 |
7 | import com.hhl.devheadline.R;
8 |
9 | /**
10 | * Created by HanHailong on 16/3/15.
11 | */
12 | public class DHLSwipeRefreshLayout extends SwipeRefreshLayout {
13 |
14 | public DHLSwipeRefreshLayout(Context context) {
15 | super(context);
16 | init(context);
17 | }
18 |
19 | public DHLSwipeRefreshLayout(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | init(context);
22 | }
23 |
24 | private void init(Context context) {
25 | //noinspection deprecation
26 | setColorSchemeColors(getResources().getColor(R.color.color_red));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/BusinessCoopActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.hhl.devheadline.R;
6 | import com.hhl.devheadline.presenter.BasePresenter;
7 | import com.hhl.devheadline.presenter.FeedbackPresenter;
8 | import com.hhl.devheadline.ui.iview.IFeedbackView;
9 |
10 | /**
11 | * 商务合作
12 | */
13 | public class BusinessCoopActivity extends BaseActivity implements IFeedbackView {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 |
19 |
20 | }
21 |
22 | @Override
23 | protected int getContentView() {
24 | return R.layout.activity_business_coop;
25 | }
26 |
27 | @Override
28 | protected BasePresenter getPresenter() {
29 | return new FeedbackPresenter(this);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/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/drawable/ic_download_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ff27b5ee
4 | #ff159cd1
5 | #ff0288d1
6 | #8f27b5ee
7 |
8 | #000000
9 | #555555
10 | #808080
11 | #aaaaaa
12 | #f4f4f4
13 | #d3d3d3
14 | #ff0000
15 | #ffffff
16 | #f2f2f2
17 | #ffeef1f3
18 | #f24949
19 | #e8e8e8
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/adapter/RecyclerViewBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.ViewGroup;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * //TODO 简单封装 {@link android.support.v7.widget.RecyclerView.Adapter}
11 | * 防止冗余代码
12 | * Created by HanHailong on 16/3/16.
13 | */
14 | public abstract class RecyclerViewBaseAdapter extends RecyclerView.Adapter {
15 |
16 | protected List dataList = new ArrayList();
17 |
18 |
19 | @Override
20 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
21 |
22 | return null;
23 | }
24 |
25 | @Override
26 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
27 |
28 | }
29 |
30 | @Override
31 | public int getItemCount() {
32 | return 0;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/utils/L.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.utils;
2 |
3 | import android.util.Log;
4 |
5 | import com.hhl.devheadline.BuildConfig;
6 |
7 | /**
8 | * 日志工具类
9 | * Created by HanHailong on 16/5/26.
10 | */
11 |
12 | public class L {
13 |
14 | private static final boolean DEBUG = BuildConfig.DEBUG;
15 |
16 | public static void e(String tag, String msg) {
17 | if (DEBUG) {
18 | Log.e(tag, msg);
19 | }
20 | }
21 |
22 | public static void d(String tag, String msg) {
23 | if (DEBUG) {
24 | Log.d(tag, msg);
25 | }
26 | }
27 |
28 | public static void w(String tag, String msg) {
29 | if (DEBUG) {
30 | Log.e(tag, msg);
31 | }
32 | }
33 |
34 | public static void i(String tag, String msg) {
35 | if (DEBUG) {
36 | Log.e(tag, msg);
37 | }
38 | }
39 |
40 | public static void v(String tag, String msg) {
41 | if (DEBUG) {
42 | Log.e(tag, msg);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/utils/ToastUtils.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.utils;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 | import android.support.annotation.StringRes;
6 | import android.widget.Toast;
7 |
8 | import com.hhl.devheadline.DevHeadLineApplication;
9 |
10 | /**
11 | * Toast工具类,可以在任何线程都可以Toast的工具类
12 | * Created by HanHailong on 16/4/4.
13 | */
14 | public class ToastUtils {
15 |
16 | /**
17 | * Toast
18 | *
19 | * @param content
20 | */
21 | public static void toast(final String content) {
22 | new Handler(Looper.getMainLooper()).post(new Runnable() {
23 | @Override
24 | public void run() {
25 | Toast.makeText(DevHeadLineApplication.getInstance(), content, Toast.LENGTH_SHORT).show();
26 | }
27 | });
28 | }
29 |
30 | /**
31 | * Toast
32 | *
33 | * @param id
34 | */
35 | public static void toast(@StringRes int id) {
36 | toast(DevHeadLineApplication.getInstance().getResources().getString(id));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.core.net.ApiService;
4 | import com.hhl.devheadline.core.net.RetrofitFactory;
5 | import com.hhl.devheadline.ui.iview.IBaseView;
6 |
7 | import java.lang.ref.Reference;
8 | import java.lang.ref.WeakReference;
9 |
10 | /**
11 | * the base presenter of all presenters
12 | * if you use a presenter,it must be extends {@link BasePresenter}
13 | * Created by HanHailong on 16/3/15.
14 | */
15 | public abstract class BasePresenter {
16 |
17 | private Reference mViewRef;
18 | protected V mView;
19 |
20 | protected static final ApiService mApiService = RetrofitFactory.getApiService();
21 |
22 | public BasePresenter(V view) {
23 | mViewRef = new WeakReference(view);
24 | this.mView = mViewRef.get();
25 | }
26 |
27 | /**
28 | * 解除presenter与view的关联
29 | */
30 | public void detachView() {
31 | if (mViewRef != null) {
32 | mViewRef.clear();
33 | mViewRef = null;
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/utils/AppTools.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.utils;
2 |
3 | import java.io.UnsupportedEncodingException;
4 |
5 | /**
6 | * Created by Administrator on 2016/3/29.
7 | */
8 | public class AppTools {
9 | /**
10 | * 截取长字符
11 | * @param str
12 | * @return
13 | */
14 | public static String clipLongText(String str) {
15 | if (str != null) {
16 | final String encoding = "GBK";
17 | try {
18 | byte[] b = str.getBytes(encoding);
19 | if (b.length > 20) {
20 | int end = 16;
21 | String result = new String(b, 0, end, encoding);
22 | if (str.indexOf(result) == -1) {
23 | return new String(b, 0, end - 1, encoding) + "...";
24 | }
25 | return result + "...";
26 | }
27 | } catch (UnsupportedEncodingException e) {
28 | // TODO Auto-generated catch block
29 | e.printStackTrace();
30 | }
31 |
32 | }
33 | return str;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/NavHomePresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.ui.fragment.BaseFragment;
4 | import com.hhl.devheadline.ui.fragment.HomeChoiceFragment;
5 | import com.hhl.devheadline.ui.fragment.HomeFindFragment;
6 | import com.hhl.devheadline.ui.fragment.HomeSubscribeFragment;
7 | import com.hhl.devheadline.ui.iview.INavHomeView;
8 |
9 | import java.util.ArrayList;
10 | import java.util.Arrays;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by HanHailong on 16/3/15.
15 | */
16 | public class NavHomePresenter extends BasePresenter {
17 |
18 | public NavHomePresenter(INavHomeView view) {
19 | super(view);
20 | }
21 |
22 | List mFragmentList = new ArrayList<>();
23 |
24 | public CharSequence[] mTitles = {"精选", "订阅", "发现"};
25 |
26 | public void initTabLayout() {
27 | mFragmentList.clear();
28 |
29 | mFragmentList.add(new HomeChoiceFragment());
30 | mFragmentList.add(new HomeSubscribeFragment());
31 | mFragmentList.add(new HomeFindFragment());
32 |
33 | mView.loadTabData(mFragmentList, Arrays.asList(mTitles));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/FeedbackActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import com.hhl.devheadline.R;
8 | import com.hhl.devheadline.presenter.FeedbackPresenter;
9 | import com.hhl.devheadline.ui.iview.IFeedbackView;
10 |
11 | public class FeedbackActivity extends BaseActivity implements IFeedbackView {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
18 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
19 | }
20 |
21 | @Override
22 | protected int getContentView() {
23 | return R.layout.activity_feedback;
24 | }
25 |
26 | @Override
27 | protected FeedbackPresenter getPresenter() {
28 | return new FeedbackPresenter(this);
29 | }
30 |
31 | /**
32 | * @param context
33 | */
34 | public static void launch(Context context) {
35 | Intent intent = new Intent(context, FeedbackActivity.class);
36 | context.startActivity(intent);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/LaunchActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.hhl.devheadline.R;
7 | import com.hhl.devheadline.presenter.LaunchPresenter;
8 | import com.hhl.devheadline.ui.iview.ILaunchView;
9 |
10 | public class LaunchActivity extends BaseActivity implements ILaunchView {
11 |
12 | @Override
13 | protected void onCreate(@Nullable Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | mPresenter.launchToMain();
16 | }
17 |
18 | @Override
19 | protected int getContentView() {
20 | return R.layout.activity_launch;
21 | }
22 |
23 | @Override
24 | protected LaunchPresenter getPresenter() {
25 | return new LaunchPresenter(this);
26 | }
27 |
28 | @Override
29 | protected boolean isNeedToolbar() {
30 | return false;
31 | }
32 |
33 | @Override
34 | public void goMain() {
35 | MainActivity.launch(LaunchActivity.this);
36 | finish();
37 | }
38 |
39 | @Override
40 | public void onBackPressed() {
41 | //禁用返回键
42 | // super.onBackPressed();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_banner_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
20 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/adapter/HomeAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.adapter;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import com.hhl.devheadline.ui.fragment.BaseFragment;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by HanHailong on 16/3/15.
14 | */
15 | public class HomeAdapter extends FragmentPagerAdapter {
16 |
17 | private List mFragmentList = new ArrayList<>();
18 | private List mTitleList = new ArrayList<>();
19 |
20 | public HomeAdapter(FragmentManager fm) {
21 | super(fm);
22 | }
23 |
24 | public void addDataList(List fragments, List titles) {
25 | if (fragments != null && titles != null) {
26 | mFragmentList.clear();
27 | mTitleList.clear();
28 |
29 | mFragmentList.addAll(fragments);
30 | mTitleList.addAll(titles);
31 | }
32 | notifyDataSetChanged();
33 | }
34 |
35 | @Override
36 | public Fragment getItem(int position) {
37 | return mFragmentList.get(position);
38 | }
39 |
40 | @Override
41 | public int getCount() {
42 | return mTitleList.size();
43 | }
44 |
45 | @Override
46 | public CharSequence getPageTitle(int position) {
47 | return mTitleList.get(position);
48 | }
49 |
50 | @Override
51 | public int getItemPosition(Object object) {
52 | return POSITION_NONE;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/view/ColorUtils.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.view;
2 |
3 | import android.content.res.ColorStateList;
4 |
5 | /**
6 | * Generate thumb and background color state list use tintColor
7 | * Created by kyle on 15/11/4.
8 | */
9 | public class ColorUtils {
10 | private static final int ENABLE_ATTR = android.R.attr.state_enabled;
11 | private static final int CHECKED_ATTR = android.R.attr.state_checked;
12 | private static final int PRESSED_ATTR = android.R.attr.state_pressed;
13 |
14 | public static ColorStateList generateThumbColorWithTintColor(final int tintColor) {
15 | int[][] states = new int[][]{
16 | {-ENABLE_ATTR, CHECKED_ATTR},
17 | {-ENABLE_ATTR},
18 | {PRESSED_ATTR, -CHECKED_ATTR},
19 | {PRESSED_ATTR, CHECKED_ATTR},
20 | {CHECKED_ATTR},
21 | {-CHECKED_ATTR}
22 | };
23 |
24 | int[] colors = new int[] {
25 | tintColor - 0xAA000000,
26 | 0xFFBABABA,
27 | tintColor - 0x99000000,
28 | tintColor - 0x99000000,
29 | tintColor | 0xFF000000,
30 | 0xFFEEEEEE
31 | };
32 | return new ColorStateList(states, colors);
33 | }
34 |
35 | public static ColorStateList generateBackColorWithTintColor(final int tintColor) {
36 | int[][] states = new int[][]{
37 | {-ENABLE_ATTR, CHECKED_ATTR},
38 | {-ENABLE_ATTR},
39 | {CHECKED_ATTR, PRESSED_ATTR},
40 | {-CHECKED_ATTR, PRESSED_ATTR},
41 | {CHECKED_ATTR},
42 | {-CHECKED_ATTR}
43 | };
44 |
45 | int[] colors = new int[] {
46 | tintColor - 0xE1000000,
47 | 0x10000000,
48 | tintColor - 0xD0000000,
49 | 0x20000000,
50 | tintColor - 0xD0000000,
51 | 0x20000000
52 | };
53 | return new ColorStateList(states, colors);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/SettingActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import com.hhl.devheadline.R;
8 | import com.hhl.devheadline.presenter.SettingPresenter;
9 | import com.hhl.devheadline.ui.iview.ISettingView;
10 |
11 | public class SettingActivity extends BaseActivity implements ISettingView {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
17 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
18 |
19 | // if (savedInstanceState == null) {
20 | // getFragmentManager().beginTransaction().replace(R.id.container,
21 | // new SettingFragment()).commit();
22 | // }
23 | }
24 |
25 | @Override
26 | protected int getContentView() {
27 | return R.layout.activity_setting;
28 | }
29 |
30 | @Override
31 | protected SettingPresenter getPresenter() {
32 | return new SettingPresenter(this);
33 | }
34 |
35 | /**
36 | * @param context
37 | */
38 | public static void launch(Context context) {
39 | Intent intent = new Intent(context, SettingActivity.class);
40 | context.startActivity(intent);
41 | }
42 |
43 | // public static class SettingFragment extends PreferenceFragment {
44 | //
45 | // @Override
46 | // public void onCreate(@Nullable Bundle savedInstanceState) {
47 | // super.onCreate(savedInstanceState);
48 | // addPreferencesFromResource(R.xml.setting);
49 | // }
50 | // }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
21 |
22 |
28 |
29 |
34 |
35 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
23 |
24 |
31 |
32 |
33 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 开发者头条
3 |
4 | Open navigation drawer
5 | Close navigation drawer
6 |
7 | Settings
8 |
9 |
10 | Hello blank fragment
11 |
12 |
13 | 首页
14 | 我的分享
15 | 我创建的主题
16 | 我订阅的主题
17 | 我的收藏
18 | 意见反馈
19 | 设置
20 | 详情
21 | "选择 韩海龙\n龚勇峰 创建 | 作者 抛物线"
22 | "韩海龙"
23 | "韩海龙龚勇峰"
24 | "联系我们"
25 | "商务合作"
26 | "我们以开放的心态寻求合作"
27 | "通知"
28 | "接受消息推送"
29 | "及时为您推荐精选文章"
30 | "分享"
31 | "监听剪切板"
32 | "发现url格式将自动打开分享页面"
33 | "其他"
34 | "检查更新"
35 | "清除缓存"
36 | "推荐App给好友"
37 | "为应用评分"
38 | "关于"
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/model/Banner.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.model;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/16.
5 | */
6 | public class Banner {
7 |
8 | /**
9 | * content_type : article
10 | * ad_id : 0
11 | * title : 程序员如何优雅地挣零花钱?
12 | * image : http://7rf34y.com1.z0.glb.clouddn.com/post%2F14448688e2474ef09d49af67aac45042
13 | * article : {"id":288872}
14 | * webpage : null
15 | */
16 |
17 | private String content_type;
18 | private int ad_id;
19 | private String title;
20 | private String image;
21 | /**
22 | * id : 288872
23 | */
24 |
25 | private ArticleBean article;
26 | private String webpage;
27 |
28 | public String getContent_type() {
29 | return content_type;
30 | }
31 |
32 | public void setContent_type(String content_type) {
33 | this.content_type = content_type;
34 | }
35 |
36 | public int getAd_id() {
37 | return ad_id;
38 | }
39 |
40 | public void setAd_id(int ad_id) {
41 | this.ad_id = ad_id;
42 | }
43 |
44 | public String getTitle() {
45 | return title;
46 | }
47 |
48 | public void setTitle(String title) {
49 | this.title = title;
50 | }
51 |
52 | public String getImage() {
53 | return image;
54 | }
55 |
56 | public void setImage(String image) {
57 | this.image = image;
58 | }
59 |
60 | public ArticleBean getArticle() {
61 | return article;
62 | }
63 |
64 | public void setArticle(ArticleBean article) {
65 | this.article = article;
66 | }
67 |
68 | public String getWebpage() {
69 | return webpage;
70 | }
71 |
72 | public void setWebpage(String webpage) {
73 | this.webpage = webpage;
74 | }
75 |
76 | public static class ArticleBean {
77 | private int id;
78 |
79 | public int getId() {
80 | return id;
81 | }
82 |
83 | public void setId(int id) {
84 | this.id = id;
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
53 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
22 |
26 |
30 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/model/resp/ArticleResp.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.model.resp;
2 |
3 | import com.hhl.devheadline.model.Article;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by HanHailong on 16/3/18.
9 | */
10 | public class ArticleResp extends BaseResp {
11 |
12 | private Data data;
13 |
14 | public Data getData() {
15 | return data;
16 | }
17 |
18 | public void setData(Data data) {
19 | this.data = data;
20 | }
21 |
22 | public static class Data {
23 | /**
24 | * date : 2016-03-17
25 | * pre_date : 2016-03-16
26 | * next_date :
27 | * is_today : true
28 | * share_url : http://toutiao.io
29 | */
30 |
31 | private String date;
32 | private String pre_date;
33 | private String next_date;
34 | private boolean is_today;
35 | private String share_url;
36 | private List article;
37 |
38 | public String getDate() {
39 | return date;
40 | }
41 |
42 | public void setDate(String date) {
43 | this.date = date;
44 | }
45 |
46 | public String getPre_date() {
47 | return pre_date;
48 | }
49 |
50 | public void setPre_date(String pre_date) {
51 | this.pre_date = pre_date;
52 | }
53 |
54 | public String getNext_date() {
55 | return next_date;
56 | }
57 |
58 | public void setNext_date(String next_date) {
59 | this.next_date = next_date;
60 | }
61 |
62 | public boolean isIs_today() {
63 | return is_today;
64 | }
65 |
66 | public void setIs_today(boolean is_today) {
67 | this.is_today = is_today;
68 | }
69 |
70 | public String getShare_url() {
71 | return share_url;
72 | }
73 |
74 | public void setShare_url(String share_url) {
75 | this.share_url = share_url;
76 | }
77 |
78 | public List getArticle() {
79 | return article;
80 | }
81 |
82 | public void setArticle(List article) {
83 | this.article = article;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/core/net/RetrofitFactory.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.core.net;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.GsonBuilder;
5 | import com.hhl.devheadline.utils.L;
6 |
7 | import java.io.IOException;
8 |
9 | import okhttp3.Interceptor;
10 | import okhttp3.OkHttpClient;
11 | import okhttp3.Request;
12 | import okhttp3.Response;
13 | import retrofit2.Retrofit;
14 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
15 | import retrofit2.converter.gson.GsonConverterFactory;
16 | import rx.schedulers.Schedulers;
17 |
18 | /**
19 | * Created by HanHailong on 16/3/16.
20 | */
21 | public class RetrofitFactory {
22 |
23 | /**
24 | * 开发者头条BaseUrl
25 | */
26 | private static final String host = "http://api.toutiao.io/v2/";
27 |
28 | private static final Gson gson = new GsonBuilder()
29 | .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").serializeNulls()
30 | .create();
31 |
32 | private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder()
33 | .addInterceptor(new Interceptor() {
34 | @Override
35 | public Response intercept(Chain chain) throws IOException {
36 | Request request = chain.request();
37 | String url = request.url().toString();
38 | L.e("请求的url", url);
39 |
40 | // TODO: (hhl) 拦截返回的结果
41 | Response response = chain.proceed(chain.request());
42 |
43 |
44 | // TODO: (hhl) 以后优化
45 |
46 | return response;
47 | }
48 | }).build();
49 |
50 | public static ApiService getApiService() {
51 | return SingletonHolder.apiService;
52 | }
53 |
54 | /**
55 | * 采用精通内部类的方式来实现单例
56 | */
57 | private static class SingletonHolder {
58 | static Retrofit retrofit = new Retrofit.Builder()
59 | .baseUrl(host)
60 | .client(OK_HTTP_CLIENT)
61 | .addConverterFactory(GsonConverterFactory.create(gson))
62 | .addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io()))
63 | .build();
64 |
65 | private static final ApiService apiService = retrofit.create(ApiService.class);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | def config = rootProject.ext.configuration
4 | def libs = rootProject.ext.libraries
5 |
6 | android {
7 | compileSdkVersion 23
8 | buildToolsVersion "22.0.1"
9 |
10 | defaultConfig {
11 | applicationId config.PACKAGE_NAME
12 | minSdkVersion config.MIN_SDK
13 | targetSdkVersion config.TARGET_SDK
14 | versionCode config.VERSION_CODE
15 | versionName config.VERSION_NAME
16 | }
17 |
18 | dexOptions {
19 | preDexLibraries = false
20 | javaMaxHeapSize "4g"
21 | }
22 |
23 | productFlavors {
24 | dev {
25 | //目的,加速编译,利用ART
26 | minSdkVersion 18
27 | }
28 | pro {
29 | minSdkVersion config.MIN_SDK
30 | }
31 | }
32 |
33 | buildTypes {
34 | release {
35 | minifyEnabled true
36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
37 | }
38 | debug {
39 | applicationIdSuffix ".debug"
40 | }
41 | }
42 |
43 | // 注释冲突
44 | packagingOptions {
45 | exclude 'META-INF/services/javax.annotation.processing.Processor'
46 | }
47 | }
48 |
49 | dependencies {
50 | compile fileTree(include: ['*.jar'], dir: 'libs')
51 | testCompile 'junit:junit:4.12'
52 | //support
53 | compile 'com.android.support:appcompat-v7:23.2.0'
54 | compile 'com.android.support:design:23.2.0'
55 | compile 'com.android.support:support-v4:23.2.0'
56 | //butterknife依赖注入
57 | compile "com.jakewharton:butterknife:${libs.VERSION_BUTTERKNIFE}"
58 | //ReactiveX
59 | compile "io.reactivex:rxandroid:${libs.VERSION_RX}"
60 | compile "io.reactivex:rxjava:${libs.VERSION_RX}"
61 | //retrofit2网络请求
62 | compile "com.squareup.retrofit2:retrofit:${libs.VERSION_RETROFIT}"
63 | compile "com.squareup.retrofit2:converter-gson:${libs.VERSION_RETROFIT_GSON}"
64 | compile "com.squareup.retrofit2:adapter-rxjava:${libs.VERSION_RETROFIT_RXJAVA}"
65 | //fresco图片加载
66 | compile "com.facebook.fresco:fresco:${libs.VERSION_FRESCO}"
67 | //轮播图
68 | compile "com.bigkoo:convenientbanner:${libs.VERSION_CONVENIENT_BANNER}"
69 | //带addHeaderView和addFooterView的Recyclerview
70 | compile "com.github.iwgang:familiarrecyclerview:${libs.VERSION_FAMILIER_RECYCLERVIEW}"
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_home_choice_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
25 |
26 |
32 |
33 |
34 |
39 |
40 |
47 |
48 |
56 |
57 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/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/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/ShareFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.net.Uri;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 |
10 | import com.hhl.devheadline.R;
11 | import com.hhl.devheadline.presenter.NavSharePresenter;
12 | import com.hhl.devheadline.ui.activity.MainActivity;
13 | import com.hhl.devheadline.ui.iview.INavShareView;
14 | import com.hhl.devheadline.ui.view.DHLSwipeRefreshLayout;
15 |
16 | import butterknife.Bind;
17 |
18 | /**
19 | * A fragment with a Google +1 button.
20 | * Activities that contain this fragment must implement the
21 | * {@link ShareFragment.OnFragmentInteractionListener} interface
22 | * to handle interaction events.
23 | * Use the {@link ShareFragment#newInstance} factory method to
24 | * create an instance of this fragment.
25 | */
26 | public class ShareFragment extends BaseFragment implements INavShareView {
27 |
28 | @Bind(R.id.toolbar)
29 | Toolbar mToolbar;
30 |
31 | //TODO 将下拉刷新封装一下
32 | @Bind(R.id.swipe_refresh_layout)
33 | DHLSwipeRefreshLayout mSwipeRefreshLayout;
34 |
35 | @Bind(R.id.recyclerview)
36 | RecyclerView mRecyclerView;
37 |
38 | public static ShareFragment newInstance() {
39 | ShareFragment fragment = new ShareFragment();
40 | Bundle args = new Bundle();
41 | fragment.setArguments(args);
42 | return fragment;
43 | }
44 |
45 | @Override
46 | public void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | if (getArguments() != null) {
49 | }
50 | }
51 |
52 | @Override
53 | protected int getContentView() {
54 | return R.layout.fragment_share;
55 | }
56 |
57 | @Override
58 | protected NavSharePresenter getPresenter() {
59 | return new NavSharePresenter(this);
60 | }
61 |
62 | @Override
63 | protected void init(View view) {
64 | mToolbar.setTitle(R.string.nav_share);
65 | mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
66 | mToolbar.inflateMenu(R.menu.menu_add_share);
67 | mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
68 | @Override
69 | public boolean onMenuItemClick(MenuItem item) {
70 | return false;
71 | }
72 | });
73 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View v) {
76 | Uri uri = new Uri.Builder().scheme(MainActivity.SCHEME_OPEN_MENU).build();
77 | mListener.onFragmentInteraction(uri);
78 | }
79 | });
80 |
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.net.Uri;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.MenuItem;
9 |
10 | import com.hhl.devheadline.R;
11 | import com.hhl.devheadline.presenter.BasePresenter;
12 | import com.hhl.devheadline.ui.fragment.BaseFragment;
13 |
14 | import butterknife.Bind;
15 | import butterknife.ButterKnife;
16 |
17 | /**
18 | * The parent Activity of all activitys
19 | * Created by HanHailong on 16/3/14.
20 | */
21 | public abstract class BaseActivity extends AppCompatActivity implements BaseFragment.OnFragmentInteractionListener {
22 |
23 | @Nullable
24 | @Bind(R.id.toolbar)
25 | protected Toolbar mToolbar;
26 |
27 | protected P mPresenter;
28 |
29 | @Override
30 | protected void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(getContentView());
33 | ButterKnife.bind(this);
34 | initPresenter();
35 | if (isNeedToolbar()) {
36 | initToolbar();
37 | }
38 | }
39 |
40 | @Override
41 | protected void onDestroy() {
42 | super.onDestroy();
43 | mPresenter.detachView();
44 | }
45 |
46 | /**
47 | * init presenter
48 | */
49 | private void initPresenter() {
50 | mPresenter = getPresenter();
51 |
52 | if (mPresenter == null) {
53 | throw new IllegalArgumentException("Presenter must not be null");
54 | }
55 | }
56 |
57 | /**
58 | * init toolbar
59 | */
60 | private void initToolbar() {
61 | if (mToolbar == null) {
62 | throw new IllegalArgumentException("Toolbar must not be null");
63 | }
64 | setSupportActionBar(mToolbar);
65 | }
66 |
67 | /**
68 | * get layout of activity
69 | *
70 | * @return
71 | */
72 | protected abstract int getContentView();
73 |
74 | /**
75 | * get the presenter class
76 | *
77 | * @return
78 | */
79 | protected abstract P getPresenter();
80 |
81 | /**
82 | * is or need toolbar
83 | *
84 | * @return
85 | */
86 | protected boolean isNeedToolbar() {
87 | return true;
88 | }
89 |
90 | @Override
91 | public boolean onOptionsItemSelected(MenuItem item) {
92 | if (item.getItemId() == android.R.id.home) {
93 | //不建议用finish
94 | onBackPressed();
95 | }
96 | return super.onOptionsItemSelected(item);
97 | }
98 |
99 | @Override
100 | public void onFragmentInteraction(Uri uri) {
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_notedetails.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
14 |
15 |
19 |
20 |
26 |
27 |
34 |
35 |
44 |
51 |
61 |
62 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import com.hhl.devheadline.presenter.BasePresenter;
13 |
14 | import butterknife.ButterKnife;
15 |
16 | /**
17 | * Created by HanHailong on 16/3/14.
18 | */
19 | public abstract class BaseFragment
extends Fragment {
20 |
21 | protected OnFragmentInteractionListener mListener;
22 |
23 | protected P mPresenter;
24 |
25 | @Override
26 | public void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | initPresenter();
29 | }
30 |
31 | @Nullable
32 | @Override
33 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
34 | View view = inflater.inflate(getContentView(), container, false);
35 | ButterKnife.bind(this, view);
36 | init(view);
37 | return view;
38 | }
39 |
40 | /**
41 | * init presenter
42 | */
43 | private void initPresenter() {
44 | mPresenter = getPresenter();
45 |
46 | if (mPresenter == null) {
47 | throw new IllegalArgumentException("Presenter must not be null");
48 | }
49 | }
50 |
51 | /**
52 | * get layout of activity
53 | *
54 | * @return
55 | */
56 | protected abstract int getContentView();
57 |
58 | /**
59 | * get the presenter class
60 | *
61 | * @return
62 | */
63 | protected abstract P getPresenter();
64 |
65 | /**
66 | * init view
67 | *
68 | * @param view
69 | */
70 | protected abstract void init(View view);
71 |
72 | @Override
73 | public void onAttach(Context context) {
74 | super.onAttach(context);
75 | if (context instanceof OnFragmentInteractionListener) {
76 | mListener = (OnFragmentInteractionListener) context;
77 | } else {
78 | throw new RuntimeException(context.toString()
79 | + " must implement OnFragmentInteractionListener");
80 | }
81 | }
82 |
83 | @Override
84 | public void onDetach() {
85 | super.onDetach();
86 | mListener = null;
87 | }
88 |
89 | /**
90 | * This interface must be implemented by activities that contain this
91 | * fragment to allow an interaction in this fragment to be communicated
92 | * to the activity and potentially other fragments contained in that
93 | * activity.
94 | *
95 | * See the Android Training lesson Communicating with Other Fragments for more information.
98 | */
99 | public interface OnFragmentInteractionListener {
100 | // TODO: Update argument type and name
101 | void onFragmentInteraction(Uri uri);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/presenter/HomeChoicePresenter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.presenter;
2 |
3 | import com.hhl.devheadline.model.Article;
4 | import com.hhl.devheadline.model.Banner;
5 | import com.hhl.devheadline.model.resp.ArticleResp;
6 | import com.hhl.devheadline.model.resp.BannerResp;
7 | import com.hhl.devheadline.ui.iview.IHomeChoiceView;
8 |
9 | import java.util.List;
10 |
11 | import rx.Subscriber;
12 | import rx.android.schedulers.AndroidSchedulers;
13 | import rx.functions.Func1;
14 |
15 | /**
16 | * Created by HanHailong on 16/3/16.
17 | */
18 | public class HomeChoicePresenter extends BasePresenter {
19 |
20 | public HomeChoicePresenter(IHomeChoiceView view) {
21 | super(view);
22 | }
23 |
24 | public void loadBanners() {
25 | mApiService.loadBannerList()
26 | .observeOn(AndroidSchedulers.mainThread())
27 | .map(new Func1>() {
28 | @Override
29 | public List call(BannerResp bannerResp) {
30 | return bannerResp.getData();
31 | }
32 | })
33 | .subscribe(new Subscriber>() {
34 | @Override
35 | public void onCompleted() {
36 | mView.loadComplete();
37 | }
38 |
39 | @Override
40 | public void onError(Throwable e) {
41 | mView.loadError(e);
42 | }
43 |
44 | @Override
45 | public void onNext(List list) {
46 | mView.fillBannerData(list);
47 | }
48 | });
49 | }
50 |
51 | public void loadArticleDataList() {
52 | mApiService.loadArticleList()
53 | .observeOn(AndroidSchedulers.mainThread())
54 | .filter(new Func1() {
55 | @Override
56 | public Boolean call(ArticleResp articleResp) {
57 | return articleResp != null &&
58 | articleResp.getData() != null &&
59 | articleResp.getData().getArticle() != null;
60 | }
61 | })
62 | .map(new Func1() {
63 | @Override
64 | public ArticleResp.Data call(ArticleResp articleResp) {
65 | return articleResp.getData();
66 | }
67 | })
68 | .map(new Func1>() {
69 | @Override
70 | public List call(ArticleResp.Data data) {
71 | return data.getArticle();
72 | }
73 | })
74 | .subscribe(new Subscriber>() {
75 | @Override
76 | public void onCompleted() {
77 |
78 | }
79 |
80 | @Override
81 | public void onError(Throwable e) {
82 |
83 | }
84 |
85 | @Override
86 | public void onNext(List list) {
87 | mView.fillArticleList(list);
88 | }
89 | });
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/adapter/HomeChoiceAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
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.TextView;
10 |
11 | import com.facebook.drawee.view.SimpleDraweeView;
12 | import com.hhl.devheadline.R;
13 | import com.hhl.devheadline.model.Article;
14 | import com.hhl.devheadline.ui.activity.NoteDetailsActivity;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import butterknife.Bind;
20 | import butterknife.ButterKnife;
21 |
22 | /**
23 | * Created by HanHailong on 16/3/16.
24 | */
25 | public class HomeChoiceAdapter extends RecyclerView.Adapter {
26 |
27 | private final List dataList = new ArrayList<>();
28 | private Context context;
29 |
30 | public HomeChoiceAdapter(Context context) {
31 | this.context = context;
32 | }
33 |
34 | public void addDataList(List list) {
35 | addDataList(list, false);
36 | }
37 |
38 | public void addDataList(List list, boolean append) {
39 | if (list != null) {
40 | if (!append) {
41 | dataList.clear();
42 | }
43 | dataList.addAll(list);
44 | }
45 | notifyDataSetChanged();
46 | }
47 |
48 | @Override
49 | public ChoiceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
50 | return new ChoiceViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_home_choice_item
51 | , parent, false));
52 | }
53 |
54 | @Override
55 | public void onBindViewHolder(final ChoiceViewHolder holder, final int position) {
56 | holder.bindData(dataList.get(position));
57 | holder.itemView.setClickable(true);
58 | holder.itemView.setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View v) {
61 | NoteDetailsActivity.launch(context, dataList.get(position).getOriginal_url());
62 | }
63 | });
64 |
65 | }
66 |
67 | @Override
68 | public int getItemCount() {
69 | return dataList.size();
70 | }
71 |
72 | public static class ChoiceViewHolder extends RecyclerView.ViewHolder {
73 | @Bind(R.id.tv_title)
74 | TextView mTitleTv;
75 | @Bind(R.id.tv_where)
76 | TextView mWhereTv;
77 | @Bind(R.id.tv_comment)
78 | TextView mCommentTv;
79 | @Bind(R.id.tv_like)
80 | TextView mLikeTv;
81 | @Bind(R.id.sdv_avatar)
82 | SimpleDraweeView mIconSdv;
83 |
84 | public ChoiceViewHolder(View itemView) {
85 | super(itemView);
86 | ButterKnife.bind(this, itemView);
87 | }
88 |
89 | public void bindData(Article article) {
90 | if (article == null) return;
91 | try {
92 | mTitleTv.setText(article.getTitle());
93 | mWhereTv.setText("选自 " + article.getSubject().getName());
94 | mIconSdv.setImageURI(Uri.parse(article.getUser().getAvatar()));
95 | mLikeTv.setText(article.getLike_count() + "");
96 | mCommentTv.setText(article.getComment_count() + "");
97 | } catch (Exception e) {
98 | //TODO 日志处理 ,待优化
99 | }
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.net.Uri;
4 | import android.os.Bundle;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 |
12 | import com.hhl.devheadline.R;
13 | import com.hhl.devheadline.presenter.NavHomePresenter;
14 | import com.hhl.devheadline.ui.activity.MainActivity;
15 | import com.hhl.devheadline.ui.adapter.HomeAdapter;
16 | import com.hhl.devheadline.ui.iview.INavHomeView;
17 |
18 | import java.util.List;
19 |
20 | import butterknife.Bind;
21 |
22 | /**
23 | * A simple {@link Fragment} subclass.
24 | * Activities that contain this fragment must implement the
25 | * {@link HomeFragment.OnFragmentInteractionListener} interface
26 | * to handle interaction events.
27 | * Use the {@link HomeFragment#newInstance} factory method to
28 | * create an instance of this fragment.
29 | */
30 | public class HomeFragment extends BaseFragment implements INavHomeView {
31 |
32 | @Bind(R.id.toolbar)
33 | Toolbar mToolbar;
34 | @Bind(R.id.tab_layout)
35 | TabLayout mTabLayout;
36 | @Bind(R.id.viewpager)
37 | ViewPager mViewPager;
38 |
39 | private HomeAdapter mHomeAdapter;
40 |
41 | public static HomeFragment newInstance() {
42 | HomeFragment fragment = new HomeFragment();
43 | Bundle args = new Bundle();
44 | fragment.setArguments(args);
45 | return fragment;
46 | }
47 |
48 | @Override
49 | public void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | if (getArguments() != null) {
52 | }
53 | }
54 |
55 | @Override
56 | protected int getContentView() {
57 | return R.layout.fragment_home;
58 | }
59 |
60 | @Override
61 | protected NavHomePresenter getPresenter() {
62 | return new NavHomePresenter(this);
63 | }
64 |
65 | @Override
66 | protected void init(View view) {
67 | mToolbar.setTitle(R.string.app_name);
68 | mToolbar.inflateMenu(R.menu.menu_home);
69 | mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
70 | @Override
71 | public boolean onMenuItemClick(MenuItem item) {
72 | switch (item.getItemId()) {
73 | case R.id.action_add:
74 | break;
75 | case R.id.action_search:
76 | break;
77 | }
78 | return false;
79 | }
80 | });
81 |
82 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View v) {
85 | Uri uri = new Uri.Builder().scheme(MainActivity.SCHEME_OPEN_MENU).build();
86 | mListener.onFragmentInteraction(uri);
87 | }
88 | });
89 |
90 | mHomeAdapter = new HomeAdapter(getChildFragmentManager());
91 | mViewPager.setAdapter(mHomeAdapter);
92 | //缓存
93 | mViewPager.setOffscreenPageLimit(mPresenter.mTitles.length);
94 |
95 | mTabLayout.setupWithViewPager(mViewPager);
96 |
97 | initData();
98 | }
99 |
100 | private void initData() {
101 | mPresenter.initTabLayout();
102 | }
103 |
104 |
105 | @Override
106 | public void loadTabData(List list, List titles) {
107 | mHomeAdapter.addDataList(list, titles);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/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/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/fragment/HomeChoiceFragment.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.fragment;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Handler;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import com.bigkoo.convenientbanner.ConvenientBanner;
13 | import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
14 | import com.bigkoo.convenientbanner.holder.Holder;
15 | import com.bigkoo.convenientbanner.listener.OnItemClickListener;
16 | import com.facebook.drawee.view.SimpleDraweeView;
17 | import com.hhl.devheadline.R;
18 | import com.hhl.devheadline.model.Article;
19 | import com.hhl.devheadline.model.Banner;
20 | import com.hhl.devheadline.presenter.HomeChoicePresenter;
21 | import com.hhl.devheadline.ui.adapter.HomeChoiceAdapter;
22 | import com.hhl.devheadline.ui.iview.IHomeChoiceView;
23 | import com.hhl.devheadline.ui.view.DHLSwipeRefreshLayout;
24 |
25 | import java.util.List;
26 |
27 | import butterknife.Bind;
28 | import butterknife.ButterKnife;
29 | import cn.iwgang.familiarrecyclerview.FamiliarRecyclerView;
30 |
31 | /**
32 | * Created by HanHailong on 16/3/15.
33 | */
34 | public class HomeChoiceFragment extends BaseFragment implements IHomeChoiceView {
35 |
36 | @Bind(R.id.swipe_refresh_layout)
37 | DHLSwipeRefreshLayout mSwipeRefreshLayout;
38 | @Bind(R.id.recyclerview)
39 | FamiliarRecyclerView mRecyclerView;
40 |
41 | private ConvenientBanner mBannerV;
42 |
43 | private HomeChoiceAdapter mAdapter;
44 |
45 | @Override
46 | protected int getContentView() {
47 | return R.layout.fragment_home_choice;
48 | }
49 |
50 | @Override
51 | protected HomeChoicePresenter getPresenter() {
52 | return new HomeChoicePresenter(this);
53 | }
54 |
55 | @Override
56 | protected void init(View view) {
57 |
58 | mBannerV = (ConvenientBanner) View.inflate(getActivity(), R.layout.view_home_banner, null);
59 | mRecyclerView.addHeaderView(mBannerV);
60 |
61 | mAdapter = new HomeChoiceAdapter(getActivity());
62 | mRecyclerView.setAdapter(mAdapter);
63 | //TODO
64 | mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
65 | @Override
66 | public void onRefresh() {
67 | //TODO
68 | new Handler().postDelayed(new Runnable() {
69 | @Override
70 | public void run() {
71 | mSwipeRefreshLayout.setRefreshing(false);
72 | }
73 | }, 2000);
74 | }
75 | });
76 |
77 | mPresenter.loadBanners();
78 |
79 | mPresenter.loadArticleDataList();
80 | mSwipeRefreshLayout.postDelayed(new Runnable() {
81 | @Override
82 | public void run() {
83 | mSwipeRefreshLayout.setRefreshing(true);
84 | }
85 | }, 100);
86 | }
87 |
88 | @Override
89 | public void fillBannerData(List list) {
90 |
91 | mBannerV.setPages(new CBViewHolderCreator() {
92 | @Override
93 | public BannerViewHolder createHolder() {
94 | return new BannerViewHolder();
95 | }
96 | }, list).setPageIndicator(new int[]{R.drawable.ic_banner_indicator_unselected
97 | , R.drawable.ic_banner_indicator_selected})
98 | .setOnItemClickListener(new OnItemClickListener() {
99 | @Override
100 | public void onItemClick(int position) {
101 | Toast.makeText(getActivity(), "你点击了" + position, Toast.LENGTH_LONG).show();
102 | }
103 | });
104 | }
105 |
106 | private static class BannerViewHolder implements Holder {
107 |
108 | private SimpleDraweeView mImageView;
109 | private TextView mTextView;
110 |
111 | @Override
112 | public View createView(Context context) {
113 | View view = LayoutInflater.from(context).inflate(R.layout.view_banner_item, null);
114 | mImageView = ButterKnife.findById(view, R.id.sdv_image);
115 | mTextView = ButterKnife.findById(view, R.id.tv_title);
116 | return view;
117 | }
118 |
119 | @Override
120 | public void UpdateUI(Context context, int position, Banner data) {
121 | if (data != null) {
122 | mImageView.setImageURI(Uri.parse(data.getImage()));
123 | mTextView.setText(data.getTitle());
124 | }
125 | }
126 | }
127 |
128 | @Override
129 | public void loadError(Throwable e) {
130 | Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
131 | mSwipeRefreshLayout.setRefreshing(false);
132 | }
133 |
134 | @Override
135 | public void loadComplete() {
136 | //TODO
137 | mSwipeRefreshLayout.postDelayed(new Runnable() {
138 | @Override
139 | public void run() {
140 | mSwipeRefreshLayout.setRefreshing(false);
141 | }
142 | }, 1000);
143 | }
144 |
145 | @Override
146 | public void fillArticleList(List list) {
147 | mAdapter.addDataList(list);
148 | }
149 |
150 | @Override
151 | public void onResume() {
152 | super.onResume();
153 | mBannerV.startTurning(3000);
154 | }
155 |
156 | @Override
157 | public void onPause() {
158 | super.onPause();
159 | mBannerV.stopTurning();
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.support.design.widget.NavigationView;
9 | import android.support.v4.app.FragmentManager;
10 | import android.support.v4.view.GravityCompat;
11 | import android.support.v4.widget.DrawerLayout;
12 | import android.view.Menu;
13 | import android.view.MenuItem;
14 |
15 | import com.facebook.drawee.view.SimpleDraweeView;
16 | import com.hhl.devheadline.R;
17 | import com.hhl.devheadline.presenter.MainPresenter;
18 | import com.hhl.devheadline.ui.fragment.HomeFragment;
19 | import com.hhl.devheadline.ui.fragment.ShareFragment;
20 | import com.hhl.devheadline.ui.iview.IMainView;
21 |
22 | import butterknife.Bind;
23 |
24 | public class MainActivity extends BaseActivity
25 | implements NavigationView.OnNavigationItemSelectedListener, IMainView {
26 |
27 | /**
28 | * 打开菜单
29 | */
30 | public static final String SCHEME_OPEN_MENU = "scheme_open_menu";
31 |
32 | @Bind(R.id.drawer_layout)
33 | DrawerLayout mDrawerLayout;
34 |
35 | private HomeFragment mHomeFragment;
36 | private ShareFragment mShareFragment;
37 |
38 | /**
39 | * 启动MainActivity
40 | *
41 | * @param context
42 | */
43 | public static void launch(Context context) {
44 | Intent intent = new Intent(context, MainActivity.class);
45 | context.startActivity(intent);
46 | }
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 |
52 | // DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
53 | // ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
54 | // this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
55 | // drawer.setDrawerListener(toggle);
56 | // toggle.syncState();
57 |
58 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
59 | navigationView.setNavigationItemSelectedListener(this);
60 |
61 | SimpleDraweeView avatarView = (SimpleDraweeView) navigationView.getHeaderView(0).findViewById(R.id.sdv_avatar);
62 | if (avatarView != null) {
63 | avatarView.setImageURI(Uri.parse("https://avatars2.githubusercontent.com/u/4241807?v=3&s=460"));
64 | }
65 |
66 | //fragment Manager
67 | managerFragment(savedInstanceState);
68 | }
69 |
70 | @Override
71 | protected int getContentView() {
72 | return R.layout.activity_main;
73 | }
74 |
75 | @Override
76 | protected MainPresenter getPresenter() {
77 | return new MainPresenter(this);
78 | }
79 |
80 | @Override
81 | protected boolean isNeedToolbar() {
82 | return false;
83 | }
84 |
85 | /**
86 | * 管理Fragment
87 | *
88 | * @param savedInstanceState
89 | */
90 | private void managerFragment(Bundle savedInstanceState) {
91 | FragmentManager fm = getSupportFragmentManager();
92 | if (savedInstanceState == null) {
93 | mHomeFragment = HomeFragment.newInstance();
94 | mShareFragment = ShareFragment.newInstance();
95 | fm.beginTransaction().add(R.id.container, mHomeFragment)
96 | .add(R.id.container, mShareFragment).commit();
97 | }
98 |
99 | fm.beginTransaction().hide(mShareFragment).show(mHomeFragment).commit();
100 | }
101 |
102 | @Override
103 | public void onBackPressed() {
104 | if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
105 | mDrawerLayout.closeDrawer(GravityCompat.START);
106 | } else {
107 | super.onBackPressed();
108 | }
109 | }
110 |
111 | @Override
112 | public boolean onCreateOptionsMenu(Menu menu) {
113 | // Inflate the menu; this adds items to the action bar if it is present.
114 | getMenuInflater().inflate(R.menu.main, menu);
115 | return true;
116 | }
117 |
118 | @Override
119 | public boolean onOptionsItemSelected(MenuItem item) {
120 | // Handle action bar item clicks here. The action bar will
121 | // automatically handle clicks on the Home/Up button, so long
122 | // as you specify a parent activity in AndroidManifest.xml.
123 | int id = item.getItemId();
124 |
125 | //noinspection SimplifiableIfStatement
126 | if (id == R.id.action_settings) {
127 | return true;
128 | }
129 |
130 | return super.onOptionsItemSelected(item);
131 | }
132 |
133 | @SuppressWarnings("StatementWithEmptyBody")
134 | @Override
135 | public boolean onNavigationItemSelected(MenuItem item) {
136 | // Handle navigation view item clicks here.
137 | int id = item.getItemId();
138 |
139 | mDrawerLayout.closeDrawer(GravityCompat.START);
140 |
141 | if (id == R.id.nav_feedback) {
142 | new Handler().postDelayed(new Runnable() {
143 | @Override
144 | public void run() {
145 | FeedbackActivity.launch(MainActivity.this);
146 | }
147 | }, 300);
148 | } else if (id == R.id.nav_setting) {
149 | new Handler().postDelayed(new Runnable() {
150 | @Override
151 | public void run() {
152 | SettingActivity.launch(MainActivity.this);
153 | }
154 | }, 300);
155 | } else {
156 | FragmentManager fm = getSupportFragmentManager();
157 | fm.beginTransaction().hide(mHomeFragment).hide(mShareFragment).commit();
158 |
159 | if (id == R.id.nav_home) {
160 | // Handle the camera action
161 | fm.beginTransaction().show(mHomeFragment).commit();
162 | } else if (id == R.id.nav_share) {
163 | fm.beginTransaction().show(mShareFragment).commit();
164 | } else if (id == R.id.nav_create_theme) {
165 |
166 | } else if (id == R.id.nav_subscrier_theme) {
167 |
168 | } else if (id == R.id.nav_favorite) {
169 |
170 | }
171 | }
172 | return true;
173 | }
174 |
175 | @Override
176 | public void onFragmentInteraction(Uri uri) {
177 | super.onFragmentInteraction(uri);
178 | if (SCHEME_OPEN_MENU.equals(uri.getScheme())) {
179 | mDrawerLayout.openDrawer(GravityCompat.START);
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/model/Article.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.model;
2 |
3 | /**
4 | * Created by HanHailong on 16/3/18.
5 | */
6 | public class Article {
7 |
8 | /**
9 | * is_advertorial : false
10 | * id : 294078
11 | * title : 如果你用 GitHub,可以这样提高效率
12 | * contributor : 流星狂飙
13 | * original_site_name : segmentfault.com
14 | * is_recommend : false
15 | * original_url : http://toutiao.io/r/0ivkig
16 | * image : null
17 | * thumbnail :
18 | * is_featured : true
19 | * comment_count : 2
20 | * like_count : 109
21 | * liked : false
22 | * subject : {"id":22029,"name":"魅族科技开发团队","image":"http://7rf34y.com1.z0.glb.clouddn.com/subject/b79abfd1238f420eadbb38ba69421759/thumb"}
23 | * user : {"id":"145451","name":"流星狂飙","avatar":"http://7rf34y.com1.z0.glb.clouddn.com/user/a6597eea1e2e4573aba796c98e396754/thumb","bio":null,"following":false}
24 | * author_info : {"name":"JerryC","url":""}
25 | * created_at : 1458124470
26 | */
27 |
28 | private boolean is_advertorial;
29 | private int id;
30 | private String title;
31 | private String contributor;
32 | private String original_site_name;
33 | private boolean is_recommend;
34 | private String original_url;
35 | private Object image;
36 | private String thumbnail;
37 | private boolean is_featured;
38 | private int comment_count;
39 | private int like_count;
40 | private boolean liked;
41 | /**
42 | * id : 22029
43 | * name : 魅族科技开发团队
44 | * image : http://7rf34y.com1.z0.glb.clouddn.com/subject/b79abfd1238f420eadbb38ba69421759/thumb
45 | */
46 |
47 | private SubjectBean subject;
48 | /**
49 | * id : 145451
50 | * name : 流星狂飙
51 | * avatar : http://7rf34y.com1.z0.glb.clouddn.com/user/a6597eea1e2e4573aba796c98e396754/thumb
52 | * bio : null
53 | * following : false
54 | */
55 |
56 | private UserBean user;
57 | /**
58 | * name : JerryC
59 | * url :
60 | */
61 |
62 | private AuthorInfoBean author_info;
63 | private int created_at;
64 |
65 | public boolean isIs_advertorial() {
66 | return is_advertorial;
67 | }
68 |
69 | public void setIs_advertorial(boolean is_advertorial) {
70 | this.is_advertorial = is_advertorial;
71 | }
72 |
73 | public int getId() {
74 | return id;
75 | }
76 |
77 | public void setId(int id) {
78 | this.id = id;
79 | }
80 |
81 | public String getTitle() {
82 | return title;
83 | }
84 |
85 | public void setTitle(String title) {
86 | this.title = title;
87 | }
88 |
89 | public String getContributor() {
90 | return contributor;
91 | }
92 |
93 | public void setContributor(String contributor) {
94 | this.contributor = contributor;
95 | }
96 |
97 | public String getOriginal_site_name() {
98 | return original_site_name;
99 | }
100 |
101 | public void setOriginal_site_name(String original_site_name) {
102 | this.original_site_name = original_site_name;
103 | }
104 |
105 | public boolean isIs_recommend() {
106 | return is_recommend;
107 | }
108 |
109 | public void setIs_recommend(boolean is_recommend) {
110 | this.is_recommend = is_recommend;
111 | }
112 |
113 | public String getOriginal_url() {
114 | return original_url;
115 | }
116 |
117 | public void setOriginal_url(String original_url) {
118 | this.original_url = original_url;
119 | }
120 |
121 | public Object getImage() {
122 | return image;
123 | }
124 |
125 | public void setImage(Object image) {
126 | this.image = image;
127 | }
128 |
129 | public String getThumbnail() {
130 | return thumbnail;
131 | }
132 |
133 | public void setThumbnail(String thumbnail) {
134 | this.thumbnail = thumbnail;
135 | }
136 |
137 | public boolean isIs_featured() {
138 | return is_featured;
139 | }
140 |
141 | public void setIs_featured(boolean is_featured) {
142 | this.is_featured = is_featured;
143 | }
144 |
145 | public int getComment_count() {
146 | return comment_count;
147 | }
148 |
149 | public void setComment_count(int comment_count) {
150 | this.comment_count = comment_count;
151 | }
152 |
153 | public int getLike_count() {
154 | return like_count;
155 | }
156 |
157 | public void setLike_count(int like_count) {
158 | this.like_count = like_count;
159 | }
160 |
161 | public boolean isLiked() {
162 | return liked;
163 | }
164 |
165 | public void setLiked(boolean liked) {
166 | this.liked = liked;
167 | }
168 |
169 | public SubjectBean getSubject() {
170 | return subject;
171 | }
172 |
173 | public void setSubject(SubjectBean subject) {
174 | this.subject = subject;
175 | }
176 |
177 | public UserBean getUser() {
178 | return user;
179 | }
180 |
181 | public void setUser(UserBean user) {
182 | this.user = user;
183 | }
184 |
185 | public AuthorInfoBean getAuthor_info() {
186 | return author_info;
187 | }
188 |
189 | public void setAuthor_info(AuthorInfoBean author_info) {
190 | this.author_info = author_info;
191 | }
192 |
193 | public int getCreated_at() {
194 | return created_at;
195 | }
196 |
197 | public void setCreated_at(int created_at) {
198 | this.created_at = created_at;
199 | }
200 |
201 | public static class SubjectBean {
202 | private int id;
203 | private String name;
204 | private String image;
205 |
206 | public int getId() {
207 | return id;
208 | }
209 |
210 | public void setId(int id) {
211 | this.id = id;
212 | }
213 |
214 | public String getName() {
215 | return name;
216 | }
217 |
218 | public void setName(String name) {
219 | this.name = name;
220 | }
221 |
222 | public String getImage() {
223 | return image;
224 | }
225 |
226 | public void setImage(String image) {
227 | this.image = image;
228 | }
229 | }
230 |
231 | public static class UserBean {
232 | private String id;
233 | private String name;
234 | private String avatar;
235 | private Object bio;
236 | private boolean following;
237 |
238 | public String getId() {
239 | return id;
240 | }
241 |
242 | public void setId(String id) {
243 | this.id = id;
244 | }
245 |
246 | public String getName() {
247 | return name;
248 | }
249 |
250 | public void setName(String name) {
251 | this.name = name;
252 | }
253 |
254 | public String getAvatar() {
255 | return avatar;
256 | }
257 |
258 | public void setAvatar(String avatar) {
259 | this.avatar = avatar;
260 | }
261 |
262 | public Object getBio() {
263 | return bio;
264 | }
265 |
266 | public void setBio(Object bio) {
267 | this.bio = bio;
268 | }
269 |
270 | public boolean isFollowing() {
271 | return following;
272 | }
273 |
274 | public void setFollowing(boolean following) {
275 | this.following = following;
276 | }
277 | }
278 |
279 | public static class AuthorInfoBean {
280 | private String name;
281 | private String url;
282 |
283 | public String getName() {
284 | return name;
285 | }
286 |
287 | public void setName(String name) {
288 | this.name = name;
289 | }
290 |
291 | public String getUrl() {
292 | return url;
293 | }
294 |
295 | public void setUrl(String url) {
296 | this.url = url;
297 | }
298 | }
299 | }
300 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hhl/devheadline/ui/activity/NoteDetailsActivity.java:
--------------------------------------------------------------------------------
1 | package com.hhl.devheadline.ui.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.http.SslError;
6 | import android.os.Build;
7 | import android.os.Bundle;
8 | import android.support.annotation.Nullable;
9 | import android.support.v7.widget.Toolbar;
10 | import android.text.SpannableString;
11 | import android.text.Spanned;
12 | import android.text.style.ForegroundColorSpan;
13 | import android.view.Menu;
14 | import android.view.MenuItem;
15 | import android.view.MotionEvent;
16 | import android.view.View;
17 | import android.view.animation.Animation;
18 | import android.view.animation.AnimationUtils;
19 | import android.webkit.JsPromptResult;
20 | import android.webkit.JsResult;
21 | import android.webkit.SslErrorHandler;
22 | import android.webkit.WebChromeClient;
23 | import android.webkit.WebSettings;
24 | import android.webkit.WebView;
25 | import android.webkit.WebViewClient;
26 | import android.widget.ProgressBar;
27 | import android.widget.RelativeLayout;
28 | import android.widget.TextView;
29 |
30 | import com.hhl.devheadline.R;
31 | import com.hhl.devheadline.presenter.NoteDetailsPresenter;
32 | import com.hhl.devheadline.ui.iview.INoteDetailsView;
33 | import com.hhl.devheadline.utils.AppTools;
34 | import com.hhl.devheadline.utils.ToastUtils;
35 |
36 | import butterknife.Bind;
37 | import rx.Observable;
38 | import rx.android.schedulers.AndroidSchedulers;
39 | import rx.functions.Action1;
40 | import rx.functions.Func1;
41 | import rx.schedulers.Schedulers;
42 |
43 | /**
44 | * Created by Administrator on 2016/3/29.
45 | */
46 | public class NoteDetailsActivity extends BaseActivity implements INoteDetailsView {
47 |
48 | private static final String ORIGINAL_URL = "original_url";
49 |
50 | @Bind(R.id.details_bar)
51 | ProgressBar progressBar;
52 | @Bind(R.id.details_webview)
53 | WebView webView;
54 | @Bind(R.id.toolbar)
55 | Toolbar toolbar;
56 | @Bind(R.id.notedetails_llbottom)
57 | RelativeLayout relativeLayout;
58 | @Bind(R.id.text_name)
59 | TextView textView;
60 | String loadingUrl;
61 | String title;
62 | Animation showAnim, dismissAnim;
63 | float downY = 0, offsetY = 0;
64 |
65 | /**
66 | * 启动{@link NoteDetailsActivity}
67 | *
68 | * @param context
69 | */
70 | public static void launch(Context context, String url) {
71 | Intent intent = new Intent(context, NoteDetailsActivity.class);
72 | intent.putExtra(ORIGINAL_URL, url);
73 | context.startActivity(intent);
74 | }
75 |
76 | @Override
77 | protected void onCreate(@Nullable Bundle savedInstanceState) {
78 | super.onCreate(savedInstanceState);
79 | getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
80 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
81 | // setSupportActionBar(toolbar);
82 | initVIew();
83 | }
84 |
85 | private void initVIew() {
86 | Observable.just(getResources().getString(R.string.notedetail_text_name)).map(new Func1() {
87 | @Override
88 | public SpannableString call(String s) {
89 | SpannableString spanabelInfo = new SpannableString(s);
90 | int lenth = s.indexOf(getResources().getString(R.string.notedetail_hal));
91 | spanabelInfo.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorPrimary)),
92 | lenth, lenth + getResources().getString(R.string.notedetail_halgyf).length() + 1,
93 | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
94 | return spanabelInfo;
95 | }
96 | }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).
97 | subscribe(new Action1() {
98 | @Override
99 | public void call(SpannableString spanableInfo) {
100 | textView.setText(spanableInfo);
101 | }
102 | });
103 | showAnim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bottom_show);
104 | dismissAnim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bottom_dismiss);
105 | WebSettings webSettings = webView.getSettings();
106 | //先加载文字后加载图片
107 | if (Build.VERSION.SDK_INT >= 19) {
108 | webSettings.setLoadsImagesAutomatically(true);
109 | } else {
110 | webSettings.setLoadsImagesAutomatically(false);
111 | }
112 | webSettings.setJavaScriptEnabled(true);
113 | webSettings.setDefaultTextEncodingName("UTF-8");
114 | webSettings.setSupportZoom(false);
115 | webSettings.setUseWideViewPort(false);
116 | // webSettings.setBlockNetworkImage(true);
117 | // if (Build.VERSION.SDK_INT < 19) {
118 | // webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
119 | // }
120 | webSettings.setLoadWithOverviewMode(true);
121 | webView.setWebViewClient(new MyWebViewClient());
122 | webView.setWebChromeClient(new MyWebChromeClient());
123 | loadingUrl = getIntent().getStringExtra(ORIGINAL_URL);
124 | webView.loadUrl(loadingUrl);
125 | webView.setOnTouchListener(new View.OnTouchListener() {
126 | @Override
127 | public boolean onTouch(View v, MotionEvent event) {
128 | switch (event.getAction()) {
129 | case MotionEvent.ACTION_DOWN:
130 | downY = (int) event.getY();
131 | break;
132 | case MotionEvent.ACTION_MOVE:
133 | int moveY = (int) event.getY();
134 | offsetY = moveY - downY;
135 | downY = moveY;
136 | break;
137 | case MotionEvent.ACTION_UP:
138 | if (offsetY < 0) {
139 | onScrollToBottom();
140 | } else {
141 | onScrollToTop();
142 | }
143 | break;
144 | }
145 | return false;
146 | }
147 | });
148 |
149 | }
150 |
151 | @Override
152 | protected int getContentView() {
153 | return R.layout.activity_notedetails;
154 | }
155 |
156 | @Override
157 | protected NoteDetailsPresenter getPresenter() {
158 | return new NoteDetailsPresenter(this);
159 | }
160 |
161 | class MyWebChromeClient extends WebChromeClient {
162 |
163 | @Override
164 | public void onProgressChanged(WebView view, int newProgress) {
165 | if (newProgress == 100) {
166 | progressBar.setVisibility(View.GONE);
167 | } else {
168 | if (progressBar.getVisibility() == View.GONE) {
169 | progressBar.setVisibility(View.VISIBLE);
170 | }
171 | if (newProgress > progressBar.getProgress()) {
172 | progressBar.setProgress(newProgress);
173 | }
174 | }
175 | // TODO Auto-generated method stub
176 | super.onProgressChanged(view, newProgress);
177 | }
178 |
179 | @Override
180 | public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
181 | result.confirm();
182 | ToastUtils.toast(message);
183 | return true;
184 | }
185 |
186 | @Override
187 | public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
188 | result.confirm();
189 | return super.onJsConfirm(view, url, message, result);
190 | }
191 |
192 | @Override
193 | public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
194 | result.confirm();
195 | return super.onJsPrompt(view, url, message, message, result);
196 | }
197 |
198 | @Override
199 | public void onReceivedTitle(WebView view, String title) {
200 | super.onReceivedTitle(view, title);
201 | toolbar.setTitle(AppTools.clipLongText(title));
202 | // 保存标题
203 | NoteDetailsActivity.this.title = title;
204 | }
205 | }
206 |
207 | public class MyWebViewClient extends WebViewClient {
208 |
209 | @Override
210 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
211 | return super.shouldOverrideUrlLoading(view, url);
212 | }
213 |
214 | @Override
215 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
216 | super.onReceivedError(view, errorCode, description, failingUrl);
217 | }
218 |
219 | @Override
220 | public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
221 | // TODO Auto-generated method stub
222 | handler.proceed();
223 | super.onReceivedSslError(view, handler, error);
224 | }
225 |
226 | @Override
227 | public void onPageFinished(WebView view, String url) {
228 | //接触数据绑定
229 | view.getSettings().setBlockNetworkImage(false);
230 | //先加载文字在加载图片
231 | if (!webView.getSettings().getLoadsImagesAutomatically()) {
232 | webView.getSettings().setLoadsImagesAutomatically(true);
233 | }
234 | super.onPageFinished(view, url);
235 | }
236 | }
237 |
238 | @Override
239 | public boolean onCreateOptionsMenu(Menu menu) {
240 | getMenuInflater().inflate(R.menu.activity_notedetail_toolsbar, menu);
241 | return true;
242 | }
243 |
244 | @Override
245 | public boolean onOptionsItemSelected(MenuItem item) {
246 | return super.onOptionsItemSelected(item);
247 | }
248 |
249 | public void onScrollToTop() {
250 | if (!relativeLayout.isShown()) {
251 | relativeLayout.clearAnimation();
252 | relativeLayout.startAnimation(showAnim);
253 | relativeLayout.setVisibility(View.VISIBLE);
254 | }
255 | }
256 |
257 | public void onScrollToBottom() {
258 | if (relativeLayout.isShown()) {
259 | relativeLayout.clearAnimation();
260 | relativeLayout.startAnimation(dismissAnim);
261 | relativeLayout.setVisibility(View.GONE);
262 | }
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
18 |
19 |
23 |
24 |
32 |
33 |
41 |
42 |
48 |
49 |
56 |
57 |
58 |
62 |
63 |
71 |
72 |
78 |
79 |
86 |
87 |
93 |
94 |
101 |
102 |
103 |
111 |
112 |
113 |
117 |
118 |
126 |
127 |
133 |
134 |
142 |
143 |
149 |
150 |
157 |
158 |
159 |
165 |
166 |
167 |
171 |
172 |
173 |
181 |
182 |
188 |
189 |
197 |
198 |
199 |
203 |
204 |
214 |
215 |
219 |
220 |
230 |
231 |
235 |
236 |
246 |
247 |
251 |
252 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
--------------------------------------------------------------------------------