├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── 119.gif
├── 120.gif
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── chs
│ │ └── leisure
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── chs
│ │ │ └── leisure
│ │ │ ├── App.java
│ │ │ ├── Constant.java
│ │ │ ├── MainActivity.java
│ │ │ ├── base
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseAdapter.java
│ │ │ ├── BaseFragment.java
│ │ │ ├── BasePresenter.java
│ │ │ ├── BaseView.java
│ │ │ ├── OnItemClickListener.java
│ │ │ └── ViewHolder.java
│ │ │ ├── model
│ │ │ ├── Bean
│ │ │ │ ├── NewsEntity.java
│ │ │ │ └── PictureEntity.java
│ │ │ ├── NewsService.java
│ │ │ ├── PictureService.java
│ │ │ └── impl
│ │ │ │ └── BusinessTask.java
│ │ │ ├── ui
│ │ │ ├── WebDetailActivity.java
│ │ │ ├── about
│ │ │ │ └── FourFragment.java
│ │ │ ├── found
│ │ │ │ └── ThirdFragment.java
│ │ │ ├── news
│ │ │ │ ├── FirstFragment.java
│ │ │ │ ├── NewFragment.java
│ │ │ │ ├── NewsContract.java
│ │ │ │ └── NewsPresenter.java
│ │ │ └── picture
│ │ │ │ ├── PictureContract.java
│ │ │ │ ├── PicturePresenter.java
│ │ │ │ └── SecondFragment.java
│ │ │ ├── utils
│ │ │ ├── ActivityUtils.java
│ │ │ ├── DensityUtil.java
│ │ │ ├── FileUtils.java
│ │ │ ├── GsonUtil.java
│ │ │ ├── HttpUtils.java
│ │ │ ├── LogUtils.java
│ │ │ ├── SystemBarTintManager.java
│ │ │ └── scalars
│ │ │ │ ├── ScalarRequestBodyConverter.java
│ │ │ │ ├── ScalarResponseBodyConverters.java
│ │ │ │ └── ScalarsConverterFactory.java
│ │ │ └── widget
│ │ │ ├── LoadMoreRecyclerView.java
│ │ │ └── RecycleViewDivider.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_web_view.xml
│ │ ├── bottom.xml
│ │ ├── fragment_first.xml
│ │ ├── fragment_news.xml
│ │ ├── fragment_second.xml
│ │ ├── item_fragment_news.xml
│ │ ├── item_pictures.xml
│ │ └── listview_footer.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_overflow.png
│ │ ├── pic_loading.png
│ │ ├── tab_comprehensive_icon.png
│ │ ├── tab_comprehensive_pressed_icon.png
│ │ ├── tab_found_icon.png
│ │ ├── tab_found_pressed_icon.png
│ │ ├── tab_me_icon.png
│ │ ├── tab_me_pressed_icon.png
│ │ ├── tab_move_icon.png
│ │ └── tab_move_pressed_icon.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── arrays.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── chs
│ └── leisure
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ptr-lib
├── .idea
│ ├── .name
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── libraries
│ │ ├── clog_1_0_2.xml
│ │ ├── cube_sdk_1_0_44_39_SNAPSHOT.xml
│ │ └── support_v4_r7.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── workspace.xml
├── AndroidManifest.xml
├── build.gradle
├── build
│ ├── generated
│ │ └── source
│ │ │ ├── buildConfig
│ │ │ ├── androidTest
│ │ │ │ └── debug
│ │ │ │ │ └── in
│ │ │ │ │ └── srain
│ │ │ │ │ └── cube
│ │ │ │ │ └── views
│ │ │ │ │ └── ptr
│ │ │ │ │ └── test
│ │ │ │ │ └── BuildConfig.java
│ │ │ ├── debug
│ │ │ │ └── in
│ │ │ │ │ └── srain
│ │ │ │ │ └── cube
│ │ │ │ │ └── views
│ │ │ │ │ └── ptr
│ │ │ │ │ └── BuildConfig.java
│ │ │ └── release
│ │ │ │ └── in
│ │ │ │ └── srain
│ │ │ │ └── cube
│ │ │ │ └── views
│ │ │ │ └── ptr
│ │ │ │ └── BuildConfig.java
│ │ │ └── r
│ │ │ ├── androidTest
│ │ │ └── debug
│ │ │ │ └── in
│ │ │ │ └── srain
│ │ │ │ └── cube
│ │ │ │ └── views
│ │ │ │ └── ptr
│ │ │ │ ├── R.java
│ │ │ │ └── test
│ │ │ │ └── R.java
│ │ │ ├── debug
│ │ │ └── in
│ │ │ │ └── srain
│ │ │ │ └── cube
│ │ │ │ └── views
│ │ │ │ └── ptr
│ │ │ │ └── R.java
│ │ │ └── release
│ │ │ └── in
│ │ │ └── srain
│ │ │ └── cube
│ │ │ └── views
│ │ │ └── ptr
│ │ │ └── R.java
│ ├── intermediates
│ │ ├── blame
│ │ │ └── res
│ │ │ │ └── androidTest
│ │ │ │ └── debug
│ │ │ │ ├── multi
│ │ │ │ ├── values-zh.json
│ │ │ │ └── values.json
│ │ │ │ └── single
│ │ │ │ ├── drawable-xhdpi-v4.json
│ │ │ │ └── layout.json
│ │ ├── bundles
│ │ │ ├── debug
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── R.txt
│ │ │ │ ├── aapt
│ │ │ │ │ └── AndroidManifest.xml
│ │ │ │ ├── classes.jar
│ │ │ │ └── res
│ │ │ │ │ ├── drawable-xhdpi-v4
│ │ │ │ │ └── ptr_rotate_arrow.png
│ │ │ │ │ ├── layout
│ │ │ │ │ ├── cube_ptr_classic_default_header.xml
│ │ │ │ │ └── cube_ptr_simple_loading.xml
│ │ │ │ │ ├── values-zh
│ │ │ │ │ └── values-zh.xml
│ │ │ │ │ └── values
│ │ │ │ │ └── values.xml
│ │ │ └── release
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── R.txt
│ │ │ │ ├── aapt
│ │ │ │ └── AndroidManifest.xml
│ │ │ │ ├── classes.jar
│ │ │ │ └── res
│ │ │ │ ├── drawable-xhdpi-v4
│ │ │ │ └── ptr_rotate_arrow.png
│ │ │ │ ├── layout
│ │ │ │ ├── cube_ptr_classic_default_header.xml
│ │ │ │ └── cube_ptr_simple_loading.xml
│ │ │ │ ├── values-zh
│ │ │ │ └── values-zh.xml
│ │ │ │ └── values
│ │ │ │ └── values.xml
│ │ ├── classes
│ │ │ ├── debug
│ │ │ │ └── in
│ │ │ │ │ └── srain
│ │ │ │ │ └── cube
│ │ │ │ │ └── views
│ │ │ │ │ └── ptr
│ │ │ │ │ ├── BuildConfig.class
│ │ │ │ │ ├── PtrClassicDefaultHeader$1.class
│ │ │ │ │ ├── PtrClassicDefaultHeader$LastUpdateTimeUpdater.class
│ │ │ │ │ ├── PtrClassicDefaultHeader.class
│ │ │ │ │ ├── PtrClassicFrameLayout.class
│ │ │ │ │ ├── PtrDefaultHandler.class
│ │ │ │ │ ├── PtrFrameLayout$1.class
│ │ │ │ │ ├── PtrFrameLayout$2.class
│ │ │ │ │ ├── PtrFrameLayout$LayoutParams.class
│ │ │ │ │ ├── PtrFrameLayout$ScrollChecker.class
│ │ │ │ │ ├── PtrFrameLayout.class
│ │ │ │ │ ├── PtrHandler.class
│ │ │ │ │ ├── PtrUIHandler.class
│ │ │ │ │ ├── PtrUIHandlerHolder.class
│ │ │ │ │ ├── PtrUIHandlerHook.class
│ │ │ │ │ ├── R$attr.class
│ │ │ │ │ ├── R$drawable.class
│ │ │ │ │ ├── R$id.class
│ │ │ │ │ ├── R$layout.class
│ │ │ │ │ ├── R$string.class
│ │ │ │ │ ├── R$styleable.class
│ │ │ │ │ ├── R.class
│ │ │ │ │ ├── header
│ │ │ │ │ ├── MaterialHeader$1.class
│ │ │ │ │ ├── MaterialHeader$2.class
│ │ │ │ │ ├── MaterialHeader$3.class
│ │ │ │ │ ├── MaterialHeader.class
│ │ │ │ │ ├── MaterialProgressDrawable$1.class
│ │ │ │ │ ├── MaterialProgressDrawable$2.class
│ │ │ │ │ ├── MaterialProgressDrawable$3.class
│ │ │ │ │ ├── MaterialProgressDrawable$4.class
│ │ │ │ │ ├── MaterialProgressDrawable$5.class
│ │ │ │ │ ├── MaterialProgressDrawable$EndCurveInterpolator.class
│ │ │ │ │ ├── MaterialProgressDrawable$OvalShadow.class
│ │ │ │ │ ├── MaterialProgressDrawable$Ring.class
│ │ │ │ │ ├── MaterialProgressDrawable$StartCurveInterpolator.class
│ │ │ │ │ ├── MaterialProgressDrawable.class
│ │ │ │ │ ├── StoreHouseBarItem.class
│ │ │ │ │ ├── StoreHouseHeader$1.class
│ │ │ │ │ ├── StoreHouseHeader$AniController.class
│ │ │ │ │ ├── StoreHouseHeader.class
│ │ │ │ │ └── StoreHousePath.class
│ │ │ │ │ ├── indicator
│ │ │ │ │ ├── PtrIndicator.class
│ │ │ │ │ └── PtrTensionIndicator.class
│ │ │ │ │ └── util
│ │ │ │ │ ├── PtrCLog.class
│ │ │ │ │ └── PtrLocalDisplay.class
│ │ │ └── release
│ │ │ │ └── in
│ │ │ │ └── srain
│ │ │ │ └── cube
│ │ │ │ └── views
│ │ │ │ └── ptr
│ │ │ │ ├── BuildConfig.class
│ │ │ │ ├── PtrClassicDefaultHeader$1.class
│ │ │ │ ├── PtrClassicDefaultHeader$LastUpdateTimeUpdater.class
│ │ │ │ ├── PtrClassicDefaultHeader.class
│ │ │ │ ├── PtrClassicFrameLayout.class
│ │ │ │ ├── PtrDefaultHandler.class
│ │ │ │ ├── PtrFrameLayout$1.class
│ │ │ │ ├── PtrFrameLayout$2.class
│ │ │ │ ├── PtrFrameLayout$LayoutParams.class
│ │ │ │ ├── PtrFrameLayout$ScrollChecker.class
│ │ │ │ ├── PtrFrameLayout.class
│ │ │ │ ├── PtrHandler.class
│ │ │ │ ├── PtrUIHandler.class
│ │ │ │ ├── PtrUIHandlerHolder.class
│ │ │ │ ├── PtrUIHandlerHook.class
│ │ │ │ ├── R$attr.class
│ │ │ │ ├── R$drawable.class
│ │ │ │ ├── R$id.class
│ │ │ │ ├── R$layout.class
│ │ │ │ ├── R$string.class
│ │ │ │ ├── R$styleable.class
│ │ │ │ ├── R.class
│ │ │ │ ├── header
│ │ │ │ ├── MaterialHeader$1.class
│ │ │ │ ├── MaterialHeader$2.class
│ │ │ │ ├── MaterialHeader$3.class
│ │ │ │ ├── MaterialHeader.class
│ │ │ │ ├── MaterialProgressDrawable$1.class
│ │ │ │ ├── MaterialProgressDrawable$2.class
│ │ │ │ ├── MaterialProgressDrawable$3.class
│ │ │ │ ├── MaterialProgressDrawable$4.class
│ │ │ │ ├── MaterialProgressDrawable$5.class
│ │ │ │ ├── MaterialProgressDrawable$EndCurveInterpolator.class
│ │ │ │ ├── MaterialProgressDrawable$OvalShadow.class
│ │ │ │ ├── MaterialProgressDrawable$Ring.class
│ │ │ │ ├── MaterialProgressDrawable$StartCurveInterpolator.class
│ │ │ │ ├── MaterialProgressDrawable.class
│ │ │ │ ├── StoreHouseBarItem.class
│ │ │ │ ├── StoreHouseHeader$1.class
│ │ │ │ ├── StoreHouseHeader$AniController.class
│ │ │ │ ├── StoreHouseHeader.class
│ │ │ │ └── StoreHousePath.class
│ │ │ │ ├── indicator
│ │ │ │ ├── PtrIndicator.class
│ │ │ │ └── PtrTensionIndicator.class
│ │ │ │ └── util
│ │ │ │ ├── PtrCLog.class
│ │ │ │ └── PtrLocalDisplay.class
│ │ ├── incremental-safeguard
│ │ │ ├── debug
│ │ │ │ └── tag.txt
│ │ │ └── release
│ │ │ │ └── tag.txt
│ │ ├── incremental
│ │ │ ├── compileDebugAidl
│ │ │ │ └── dependency.store
│ │ │ ├── compileDebugAndroidTestAidl
│ │ │ │ └── dependency.store
│ │ │ ├── compileReleaseAidl
│ │ │ │ └── dependency.store
│ │ │ ├── mergeDebugAndroidTestAssets
│ │ │ │ └── merger.xml
│ │ │ ├── mergeDebugAndroidTestResources
│ │ │ │ └── merger.xml
│ │ │ ├── mergeDebugAndroidTestShaders
│ │ │ │ └── merger.xml
│ │ │ ├── mergeDebugAssets
│ │ │ │ └── merger.xml
│ │ │ ├── mergeDebugJniLibFolders
│ │ │ │ └── merger.xml
│ │ │ ├── mergeDebugShaders
│ │ │ │ └── merger.xml
│ │ │ ├── mergeReleaseAssets
│ │ │ │ └── merger.xml
│ │ │ ├── mergeReleaseJniLibFolders
│ │ │ │ └── merger.xml
│ │ │ ├── mergeReleaseShaders
│ │ │ │ └── merger.xml
│ │ │ ├── packageDebugResources
│ │ │ │ └── merger.xml
│ │ │ └── packageReleaseResources
│ │ │ │ └── merger.xml
│ │ ├── manifest
│ │ │ └── androidTest
│ │ │ │ └── debug
│ │ │ │ └── AndroidManifest.xml
│ │ ├── res
│ │ │ ├── merged
│ │ │ │ └── androidTest
│ │ │ │ │ └── debug
│ │ │ │ │ ├── drawable-xhdpi-v4
│ │ │ │ │ └── ptr_rotate_arrow.png
│ │ │ │ │ ├── layout
│ │ │ │ │ ├── cube_ptr_classic_default_header.xml
│ │ │ │ │ └── cube_ptr_simple_loading.xml
│ │ │ │ │ ├── values-zh
│ │ │ │ │ └── values-zh.xml
│ │ │ │ │ └── values
│ │ │ │ │ └── values.xml
│ │ │ └── resources-debug-androidTest.ap_
│ │ └── symbols
│ │ │ └── androidTest
│ │ │ └── debug
│ │ │ └── R.txt
│ └── outputs
│ │ └── aar
│ │ ├── ptr-lib-debug.aar
│ │ └── ptr-lib-release.aar
├── checkstyle.xml
├── gradle-mvn-push.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
│ ├── clog-1.0.2-sources.jar
│ └── clog-1.0.2.jar
├── local.properties
├── pom.xml
├── res
│ ├── drawable-xhdpi
│ │ └── ptr_rotate_arrow.png
│ ├── layout
│ │ ├── cube_ptr_classic_default_header.xml
│ │ └── cube_ptr_simple_loading.xml
│ ├── values-zh
│ │ └── cube_ptr_string.xml
│ └── values
│ │ ├── cube_ptr_attrs.xml
│ │ └── cube_ptr_string.xml
└── src
│ └── in
│ └── srain
│ └── cube
│ └── views
│ └── ptr
│ ├── PtrClassicDefaultHeader.java
│ ├── PtrClassicFrameLayout.java
│ ├── PtrDefaultHandler.java
│ ├── PtrFrameLayout.java
│ ├── PtrHandler.java
│ ├── PtrUIHandler.java
│ ├── PtrUIHandlerHolder.java
│ ├── PtrUIHandlerHook.java
│ ├── header
│ ├── MaterialHeader.java
│ ├── MaterialProgressDrawable.java
│ ├── StoreHouseBarItem.java
│ ├── StoreHouseHeader.java
│ └── StoreHousePath.java
│ ├── indicator
│ ├── PtrIndicator.java
│ └── PtrTensionIndicator.java
│ └── util
│ ├── PtrCLog.java
│ └── PtrLocalDisplay.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Leisure
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/119.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chsmy/Leisure/7da9d135b70eaa5e4794a8ee3ef8df6da4285b77/119.gif
--------------------------------------------------------------------------------
/120.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chsmy/Leisure/7da9d135b70eaa5e4794a8ee3ef8df6da4285b77/120.gif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Leisure
2 | 闲暇就是没事的时候看的 ^^
3 | 闲暇客户端RxJava+Retrofit+Butterknife+MVP
4 |
5 | 一个练习的项目持续更新中
6 | 用到的知识点:
7 | [RxJava](https://github.com/ReactiveX/RxJava)
8 | [Retrofit](https://github.com/square/retrofit)
9 | [ButterKnife](https://github.com/JakeWharton/butterknife)
10 | [MVP参考了google官方案例](https://github.com/googlesamples/android-architecture)
11 | 使用[Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh)
12 | 封装了下RecycleView使其具有下拉刷新和滑倒底部加载功能
13 | [Glide](https://github.com/bumptech/glide)进行图片缓存
14 |
15 | 效果图:
16 | 
17 | 
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.chs.leisure"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.3.0'
26 | compile 'io.reactivex:rxjava:1.1.1'
27 | compile 'io.reactivex:rxandroid:1.1.0'
28 | compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
29 | compile 'com.google.code.gson:gson:2.6.2'
30 | compile 'com.squareup.okhttp3:okhttp:3.2.0'
31 | compile 'com.squareup.okio:okio:1.6.0'
32 | compile 'com.squareup.retrofit2:converter-gson:2.0.0'
33 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
34 | compile 'com.android.support:design:23.3.0'
35 | compile 'com.android.support:recyclerview-v7:23.3.0'
36 | compile 'com.jakewharton:butterknife:7.0.1'
37 | compile 'com.android.support:cardview-v7:23.3.0'
38 | compile 'com.github.bumptech.glide:glide:3.7.0'
39 | compile project(':ptr-lib')
40 | }
41 |
--------------------------------------------------------------------------------
/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 D:\AndroidTools\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/androidTest/java/com/chs/leisure/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure;
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/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/App.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure;
2 |
3 | import android.app.Application;
4 |
5 |
6 | /**
7 | * 作者:chs on 2016/4/25 16:15
8 | * 邮箱:657083984@qq.com
9 | */
10 | public class App extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/Constant.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure;
2 |
3 | /**
4 | * 作者:chs on 2016/4/26 10:43
5 | * 邮箱:657083984@qq.com
6 | */
7 | public class Constant {
8 | public static String BasePictureUrl = "http://www.tngou.net/tnfs/api/";
9 | public static String BaseNewsUrl = "http://apis.baidu.com/txapi/";
10 | public static String PIC_HEAD = "http://tnfs.tngou.net/image";//图片链接的前面部分
11 | public static String PIC_WEB = "http://www.tngou.net/tnfs/show/";//图片链接的WEB网址
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.base;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | import com.chs.leisure.R;
12 | import com.chs.leisure.utils.SystemBarTintManager;
13 |
14 | import butterknife.ButterKnife;
15 |
16 | /**
17 | * 作者:chs on 2016/4/25 16:32
18 | * 邮箱:657083984@qq.com
19 | */
20 | public class BaseActivity extends AppCompatActivity {
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | initStatusBar();
25 | }
26 |
27 | @Override
28 | protected void onDestroy() {
29 | super.onDestroy();
30 | ButterKnife.unbind(this);
31 | }
32 |
33 | private void initStatusBar() {
34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
35 | setTranslucentStatus(true);
36 | }
37 |
38 | SystemBarTintManager tintManager = new SystemBarTintManager(this);
39 | tintManager.setStatusBarTintEnabled(true);
40 | tintManager.setNavigationBarTintEnabled(true);
41 | tintManager.setStatusBarTintColor(getResources().getColor(R.color.colorPrimaryDark));
42 | }
43 |
44 | @TargetApi(19)
45 | private void setTranslucentStatus(boolean on) {
46 | Window win = getWindow();
47 | WindowManager.LayoutParams winParams = win.getAttributes();
48 | final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
49 | if (on) {
50 | winParams.flags |= bits;
51 | } else {
52 | winParams.flags &= ~bits;
53 | }
54 | win.setAttributes(winParams);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 |
7 | import butterknife.ButterKnife;
8 |
9 | /**
10 | * 作者:chs on 2016/4/25 16:32
11 | * 邮箱:657083984@qq.com
12 | */
13 | public abstract class BaseFragment extends Fragment {
14 | @Override
15 | public void onCreate(@Nullable Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | }
18 | /** Fragment当前状态是否可见 */
19 | protected boolean isVisible;
20 |
21 |
22 | @Override
23 | public void setUserVisibleHint(boolean isVisibleToUser) {
24 | super.setUserVisibleHint(isVisibleToUser);
25 |
26 | if(getUserVisibleHint()) {
27 | isVisible = true;
28 | onVisible();
29 | } else {
30 | isVisible = false;
31 | onInvisible();
32 | }
33 | }
34 | /**
35 | * 可见
36 | */
37 | protected void onVisible() {
38 | lazyLoad();
39 | }
40 |
41 | /**
42 | * 不可见
43 | */
44 | protected void onInvisible() {
45 |
46 |
47 | }
48 |
49 | /**
50 | * 延迟加载
51 | * 子类必须重写此方法
52 | */
53 | protected abstract void lazyLoad();
54 | @Override
55 | public void onDestroy() {
56 | super.onDestroy();
57 | ButterKnife.unbind(this);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/base/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.base;
2 |
3 | /**
4 | * 作者:chs on 2016/4/26 09:49
5 | * 邮箱:657083984@qq.com
6 | */
7 | public interface BasePresenter {
8 | void start(int page);
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/base/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.base;
2 |
3 | /**
4 | * 作者:chs on 2016/4/26 09:48
5 | * 邮箱:657083984@qq.com
6 | */
7 | public interface BaseView {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/base/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.base;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 |
6 | public interface OnItemClickListener
7 | {
8 | void onItemClick(ViewGroup parent, View view, T t, int position);
9 | boolean onItemLongClick(ViewGroup parent, View view, T t, int position);
10 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/model/Bean/NewsEntity.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.model.Bean;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * 作者:chs on 2016/4/28 10:33
7 | * 邮箱:657083984@qq.com
8 | */
9 | public class NewsEntity {
10 | /**
11 | * code : 200
12 | * msg : success
13 | * newslist : [{"ctime":"2016-04-28 10:40","title":"意大利中国女留学生欲轻生 美国警长跨国相救(图)","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/6/62/627EEFFC52F2A42C06A30B1EE6DC8B69.jpg.119x83.jpg","url":"http://news.163.com/16/0428/10/BLO065H800014JB6.html#f=slist"},{"ctime":"2016-04-28 10:40","title":"小学生被校车轧倒身亡 警方:肇事司机已刑拘","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/B/B6/B65B600F3A30D2D681F5051C4E6328A7.jpg.119x83.jpg","url":"http://news.163.com/16/0428/10/BLO067V000011229.html#f=slist"},{"ctime":"2016-04-28 10:42","title":"芜湖麦当劳砍人案追踪:军事迷砍伤军事迷","description":"网易社会","picUrl":"http://s.cimg.163.com/cnews/2016/4/28/201604281038236a66a_550.jpg.119x83.jpg","url":"http://news.163.com/16/0428/10/BLO0BA0000011229.html#f=slist"},{"ctime":"2016-04-28 10:43","title":"大学生公益调查:近六成人称若参加公益后没人知道就不","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/8/8E/8ED23EF109BAFE26CDD714D7299B9325.jpg.119x83.jpg","url":"http://news.163.com/16/0428/10/BLO0C0HM00014AED.html#f=slist"},{"ctime":"2016-04-28 09:08","title":"延安路高架早高峰飘浓烟 原是一旁工地焚烧垃圾(组图)","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/2/2C/2C6DAF27881ECF6B021EA5F5EE040482.jpg.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNQUM8J00014AEE.html#f=slist"},{"ctime":"2016-04-28 09:11","title":"湖师大、湖大女厕接连发现有人泼粪水 警方调查","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/9/97/9725B4D399668D2C73BF46A7AC8382A9.jpg.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNR3EQ100014AEE.html#f=slist"},{"ctime":"2016-04-28 09:16","title":"女公务员实名举报村主任:骗我生孩子罚款加骚扰","description":"网易社会","picUrl":"http://s.cimg.163.com/cnews/2016/4/28/2016042809131562383_550.jpg.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNRC5ST00011229.html#f=slist"},{"ctime":"2016-04-28 09:33","title":"杭州协警礼为奇被授予一等治安荣誉奖章(图)","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/2/29/297E75D7C2D7BE744F2292D66250AD95.png.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNSBH340001124J.html#f=slist"},{"ctime":"2016-04-28 09:33","title":"3岁女童称脚底遭老师牙签扎 幼儿园:蚊子咬的","description":"网易社会","picUrl":"http://s.cimg.163.com/cnews/2016/4/28/201604280931173ce1a_550.jpg.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNSCOF800011229.html#f=slist"},{"ctime":"2016-04-28 09:44","title":"广东警方缴获碰瓷团队专用高级轿车28台(图)","description":"网易社会","picUrl":"http://s.cimg.163.com/catchpic/4/49/49FB978602BE4D0080BF7811136D88E6.jpg.119x83.jpg","url":"http://news.163.com/16/0428/09/BLNSVG910001124J.html#f=slist"}]
14 | */
15 |
16 | private int code;
17 | private String msg;
18 | /**
19 | * ctime : 2016-04-28 10:40
20 | * title : 意大利中国女留学生欲轻生 美国警长跨国相救(图)
21 | * description : 网易社会
22 | * picUrl : http://s.cimg.163.com/catchpic/6/62/627EEFFC52F2A42C06A30B1EE6DC8B69.jpg.119x83.jpg
23 | * url : http://news.163.com/16/0428/10/BLO065H800014JB6.html#f=slist
24 | */
25 |
26 | private List newslist;
27 |
28 | public int getCode() {
29 | return code;
30 | }
31 |
32 | public void setCode(int code) {
33 | this.code = code;
34 | }
35 |
36 | public String getMsg() {
37 | return msg;
38 | }
39 |
40 | public void setMsg(String msg) {
41 | this.msg = msg;
42 | }
43 |
44 | public List getNewslist() {
45 | return newslist;
46 | }
47 |
48 | public void setNewslist(List newslist) {
49 | this.newslist = newslist;
50 | }
51 |
52 | public static class NewslistEntity {
53 | private String ctime;
54 | private String title;
55 | private String description;
56 | private String picUrl;
57 | private String url;
58 |
59 | public String getCtime() {
60 | return ctime;
61 | }
62 |
63 | public void setCtime(String ctime) {
64 | this.ctime = ctime;
65 | }
66 |
67 | public String getTitle() {
68 | return title;
69 | }
70 |
71 | public void setTitle(String title) {
72 | this.title = title;
73 | }
74 |
75 | public String getDescription() {
76 | return description;
77 | }
78 |
79 | public void setDescription(String description) {
80 | this.description = description;
81 | }
82 |
83 | public String getPicUrl() {
84 | return picUrl;
85 | }
86 |
87 | public void setPicUrl(String picUrl) {
88 | this.picUrl = picUrl;
89 | }
90 |
91 | public String getUrl() {
92 | return url;
93 | }
94 |
95 | public void setUrl(String url) {
96 | this.url = url;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/model/NewsService.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.model;
2 |
3 | import retrofit2.http.GET;
4 | import retrofit2.http.Query;
5 | import rx.Observable;
6 |
7 | /**
8 | * 作者:chs on 2016/4/28 10:35
9 | * 邮箱:657083984@qq.com
10 | */
11 | public interface NewsService {
12 | @GET("social/social")
13 | Observable getSocial(@Query("page") int page, @Query("num") int rows);
14 | @GET("tiyu/tiyu")
15 | Observable getSport(@Query("page") int page, @Query("num") int rows);
16 | @GET("keji/keji")
17 | Observable getTechnology(@Query("page") int page, @Query("num") int rows);
18 | @GET("world/world")
19 | Observable getWorld(@Query("page") int page, @Query("num") int rows);
20 | @GET("huabian/newtop")
21 | Observable getRecreation(@Query("page") int page, @Query("num") int rows);
22 | @GET("qiwen/qiwen")
23 | Observable getRemarkable(@Query("page") int page, @Query("num") int rows);
24 | @GET("health/health")
25 | Observable getHealth(@Query("page") int page, @Query("num") int rows);
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/model/PictureService.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.model;
2 |
3 | import com.chs.leisure.model.Bean.PictureEntity;
4 |
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Query;
7 | import rx.Observable;
8 |
9 | /**
10 | * 作者:chs on 2016/4/26 10:21
11 | * 邮箱:657083984@qq.com
12 | */
13 | public interface PictureService {
14 | @GET("list")
15 | Observable getPictures(@Query("page") int page,@Query("rows") int rows);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/model/impl/BusinessTask.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.model.impl;
2 |
3 | import com.chs.leisure.model.Bean.PictureEntity;
4 | import com.chs.leisure.model.NewsService;
5 | import com.chs.leisure.model.PictureService;
6 | import com.chs.leisure.utils.HttpUtils;
7 |
8 | import rx.Observable;
9 | import rx.Scheduler;
10 | import rx.Subscriber;
11 | import rx.android.schedulers.AndroidSchedulers;
12 | import rx.schedulers.Schedulers;
13 |
14 | /**
15 | * 作者:chs on 2016/4/26 10:39
16 | * 邮箱:657083984@qq.com
17 | */
18 | public class BusinessTask {
19 |
20 | public void getPictureList(Subscriber subscriber, int currentPage) {
21 | HttpUtils.getInstance().initRetrofit().create(PictureService.class).getPictures(currentPage, 10)
22 | .subscribeOn(Schedulers.io())
23 | .unsubscribeOn(Schedulers.io())
24 | .observeOn(AndroidSchedulers.mainThread())
25 | .subscribe(subscriber);
26 | }
27 |
28 | public void geNewsList(Subscriber subscriber, int currentPage, int type) {
29 | NewsService newsService = HttpUtils.getInstance().initRetrofitWithHeader().create(NewsService.class);
30 | Observable observable = null;
31 | switch (type) {
32 | case 0:
33 | observable = newsService.getSocial(currentPage, 10);
34 | break;
35 | case 1:
36 | observable = newsService.getSport(currentPage, 10);
37 | break;
38 | case 2:
39 | observable = newsService.getTechnology(currentPage, 10);
40 | break;
41 | case 3:
42 | observable = newsService.getWorld(currentPage, 10);
43 | break;
44 | case 4:
45 | observable = newsService.getRecreation(currentPage, 10);
46 | break;
47 | case 5:
48 | observable = newsService.getRemarkable(currentPage, 10);
49 | break;
50 | case 6:
51 | observable = newsService.getHealth(currentPage, 10);
52 | break;
53 | }
54 | if (observable != null) {
55 | observable
56 | .subscribeOn(Schedulers.io())
57 | .unsubscribeOn(Schedulers.io())
58 | .observeOn(AndroidSchedulers.mainThread())
59 | .subscribe(subscriber);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/WebDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.webkit.WebChromeClient;
7 | import android.webkit.WebSettings;
8 | import android.webkit.WebView;
9 | import android.webkit.WebViewClient;
10 | import android.widget.FrameLayout;
11 | import android.widget.ProgressBar;
12 |
13 | import com.chs.leisure.Constant;
14 | import com.chs.leisure.R;
15 | import com.chs.leisure.base.BaseActivity;
16 |
17 | import butterknife.Bind;
18 | import butterknife.ButterKnife;
19 |
20 | /**
21 | * 作者:chs on 2016/4/26 17:47
22 | * 邮箱:657083984@qq.com
23 | */
24 | public class WebDetailActivity extends Activity {
25 | @Bind(R.id.web_view)
26 | WebView webView;
27 | @Bind(R.id.pb_bar)
28 | ProgressBar progressBar;
29 | @Bind(R.id.rl_content)
30 | FrameLayout rl_content;
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_web_view);
35 | ButterKnife.bind(this);
36 | initView();
37 | }
38 |
39 | private void initView() {
40 | String url = getIntent().getStringExtra("url");
41 | WebSettings settings = webView.getSettings();
42 | settings.setJavaScriptEnabled(true);
43 | settings.setLoadWithOverviewMode(true);
44 | settings.setAppCacheEnabled(true);
45 | settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
46 | settings.setSupportZoom(true);
47 | webView.loadUrl(url);
48 | // webView.setWebChromeClient(new ChromeClient());
49 | webView.setWebViewClient(new PicClient());
50 | }
51 |
52 |
53 | @Override
54 | protected void onDestroy() {
55 | super.onDestroy();
56 | if (webView != null) {
57 | rl_content.removeView(webView);
58 | webView.removeAllViews();
59 | webView.destroy();
60 | webView = null;
61 | }
62 | }
63 | // private class ChromeClient extends WebChromeClient {
64 | // @Override
65 | // public void onProgressChanged(WebView view, int newProgress) {
66 | // super.onProgressChanged(view, newProgress);
67 | // iView.showProgressBar(newProgress);
68 | // }
69 | //
70 | // @Override
71 | // public void onReceivedTitle(WebView view, String title) {
72 | // super.onReceivedTitle(view, title);
73 | // iView.setWebTitle(title);
74 | // }
75 | // }
76 |
77 | private class PicClient extends WebViewClient {
78 | @Override
79 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
80 | if (url != null) view.loadUrl(url);
81 | return true;
82 | }
83 |
84 | @Override
85 | public void onPageFinished(WebView view, String url) {
86 | super.onPageFinished(view, url);
87 | if(progressBar!=null){
88 | progressBar.setVisibility(View.GONE);
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/about/FourFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui.about;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import com.chs.leisure.base.BaseFragment;
13 |
14 | /**
15 | * 作者:chs on 2016/4/25 17:26
16 | * 邮箱:657083984@qq.com
17 | */
18 | public class FourFragment extends BaseFragment {
19 | @Nullable
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
22 | TextView textView = new TextView(getActivity());
23 | textView.setText("FourFragment");
24 | textView.setTextSize(30);
25 | textView.setGravity(Gravity.CENTER);
26 | return textView;
27 | }
28 |
29 | @Override
30 | protected void lazyLoad() {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/found/ThirdFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui.found;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import com.chs.leisure.base.BaseFragment;
13 |
14 | /**
15 | * 作者:chs on 2016/4/25 17:26
16 | * 邮箱:657083984@qq.com
17 | */
18 | public class ThirdFragment extends BaseFragment {
19 | @Nullable
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
22 | TextView textView = new TextView(getActivity());
23 | textView.setText("ThirdFragment");
24 | textView.setTextSize(30);
25 | textView.setGravity(Gravity.CENTER);
26 | return textView;
27 | }
28 |
29 | @Override
30 | protected void lazyLoad() {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/news/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui.news;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.app.FragmentManager;
8 | import android.support.v4.app.FragmentStatePagerAdapter;
9 | import android.support.v4.view.ViewPager;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.chs.leisure.R;
15 | import com.chs.leisure.base.BaseFragment;
16 | import com.chs.leisure.model.Bean.NewsEntity;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import butterknife.Bind;
22 | import butterknife.ButterKnife;
23 |
24 | /**
25 | * 作者:chs on 2016/4/25 17:26
26 | * 邮箱:657083984@qq.com
27 | */
28 | public class FirstFragment extends BaseFragment implements NewsContract.View {
29 | @Bind(R.id.tab_selector)
30 | TabLayout mTabSelector;
31 | @Bind(R.id.vp_news)
32 | ViewPager mViewPager;
33 | private List mFragmentList;
34 | private String[] mTitles = new String[]{"社会","体育","科技","世界","娱乐","奇闻","健康"};
35 | private NewsPagerAdapter mAdapter;
36 | @Nullable
37 | @Override
38 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
39 | View view = inflater.inflate(R.layout.fragment_first, null);
40 | ButterKnife.bind(this,view);
41 | initData();
42 | initView();
43 | return view;
44 | }
45 |
46 | private void initData() {
47 | mFragmentList = new ArrayList<>();
48 | mFragmentList.clear();
49 | for(int i = 0;i {
13 | void showInfo(NewsEntity entity);
14 | }
15 | interface Presenter extends BasePresenter {
16 | void start(int page,int type);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/picture/PictureContract.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui.picture;
2 |
3 | import com.chs.leisure.base.BasePresenter;
4 | import com.chs.leisure.base.BaseView;
5 | import com.chs.leisure.model.Bean.PictureEntity;
6 |
7 | /**
8 | * 作者:chs on 2016/4/26 09:57
9 | * 邮箱:657083984@qq.com
10 | */
11 | public interface PictureContract {
12 | interface View extends BaseView{
13 | void showInfo(PictureEntity entity);
14 | }
15 | interface Presenter extends BasePresenter{
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/ui/picture/PicturePresenter.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.ui.picture;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.chs.leisure.model.Bean.PictureEntity;
6 | import com.chs.leisure.model.impl.BusinessTask;
7 | import com.chs.leisure.utils.GsonUtil;
8 | import com.chs.leisure.utils.LogUtils;
9 |
10 | import rx.Subscriber;
11 |
12 | /**
13 | * 作者:chs on 2016/4/26 10:12
14 | * 邮箱:657083984@qq.com
15 | */
16 | public class PicturePresenter implements PictureContract.Presenter {
17 | private BusinessTask mPictureTask;
18 | private PictureContract.View mPictureView;
19 |
20 | public PicturePresenter( PictureContract.View pictureView) {
21 | this.mPictureView = pictureView;
22 | mPictureTask = new BusinessTask();
23 | }
24 |
25 | @Override
26 | public void start(int page) {
27 | getPicList(page);
28 | }
29 |
30 | public void getPicList(int page){
31 | mPictureTask.getPictureList(new Subscriber() {
32 | @Override
33 | public void onCompleted() {
34 | LogUtils.e("PicturePresenter","onCompleted");
35 | }
36 |
37 | @Override
38 | public void onError(Throwable e) {
39 | LogUtils.e("PicturePresenter","onError");
40 | }
41 |
42 | @Override
43 | public void onNext(String result) {
44 | if(!TextUtils.isEmpty(result)){
45 | mPictureView.showInfo(GsonUtil.changeGsonToBean(result,PictureEntity.class));
46 | }
47 | }
48 | },page);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/utils/ActivityUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.chs.leisure.utils;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.v4.app.Fragment;
21 | import android.support.v4.app.FragmentManager;
22 | import android.support.v4.app.FragmentTransaction;
23 |
24 | /**
25 | * This provides methods to help Activities load their UI.
26 | */
27 | public class ActivityUtils {
28 |
29 | /**
30 | * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
31 | * performed by the {@code fragmentManager}.
32 | *
33 | */
34 | public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
35 | @NonNull Fragment fragment, int frameId) {
36 | checkNotNull(fragmentManager);
37 | checkNotNull(fragment);
38 | FragmentTransaction transaction = fragmentManager.beginTransaction();
39 | transaction.add(frameId, fragment);
40 | transaction.commit();
41 | }
42 | public static T checkNotNull(T reference) {
43 | if (reference == null) {
44 | throw new NullPointerException();
45 | }
46 | return reference;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/utils/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.utils;
2 |
3 | import android.content.Context;
4 |
5 | public class DensityUtil {
6 | /**
7 | *
8 | */
9 | public static int dip2px(Context context, float dpValue) {
10 | final float scale = context.getResources().getDisplayMetrics().density;
11 | return (int) (dpValue * scale + 0.5f);
12 | }
13 |
14 | /**
15 | *
16 | */
17 | public static int px2dip(Context context, float pxValue) {
18 | final float scale = context.getResources().getDisplayMetrics().density;
19 | return (int) (pxValue / scale + 0.5f);
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/leisure/utils/GsonUtil.java:
--------------------------------------------------------------------------------
1 | package com.chs.leisure.utils;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import com.google.gson.Gson;
8 | import com.google.gson.JsonArray;
9 | import com.google.gson.JsonElement;
10 | import com.google.gson.JsonParser;
11 | import com.google.gson.reflect.TypeToken;
12 |
13 | public class GsonUtil {
14 | public static String createGsonString(Object object) {
15 | Gson gson = new Gson();
16 | String gsonString = gson.toJson(object);
17 | return gsonString;
18 | }
19 |
20 | public static T changeGsonToBean(String gsonString, Class cls) {
21 | Gson gson = new Gson();
22 | T t = gson.fromJson(gsonString, cls);
23 | return t;
24 | }
25 |
26 | public static List changeGsonToList(String gsonString, Class cls) {
27 | Gson gson = new Gson();
28 | List list = gson.fromJson(gsonString, new TypeToken>() {}.getType());
29 | return list;
30 | }
31 | public static List fromJsonArray(String json, Class clazz) throws Exception {
32 | List lst = new ArrayList();
33 |
34 | JsonArray array = new JsonParser().parse(json).getAsJsonArray();
35 | for(final JsonElement elem : array){
36 | lst.add(new Gson().fromJson(elem, clazz));
37 | }
38 |
39 | return lst;
40 | }
41 | public static List