├── .gitignore
├── .idea
├── .name
├── codeStyleSettings.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── jsoup-1.9.1.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── flyou
│ │ └── girls
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── com
│ │ │ └── flyou
│ │ │ └── girls
│ │ │ ├── Constant.java
│ │ │ ├── adapter
│ │ │ ├── SpacesItemDecoration.java
│ │ │ ├── ViewHolder.java
│ │ │ └── recyclerview
│ │ │ │ ├── CommonAdapter.java
│ │ │ │ ├── DividerItemDecoration.java
│ │ │ │ ├── EmptyRecyclerView.java
│ │ │ │ ├── MultiItemCommonAdapter.java
│ │ │ │ ├── MultiItemTypeSupport.java
│ │ │ │ ├── OnItemClickListener.java
│ │ │ │ └── support
│ │ │ │ ├── SectionAdapter.java
│ │ │ │ └── SectionSupport.java
│ │ │ └── ui
│ │ │ ├── ImageDetialActivity.java
│ │ │ ├── ImageViewPagerActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── mainImageList
│ │ │ ├── domain
│ │ │ │ └── ImageListDomain.java
│ │ │ ├── model
│ │ │ │ ├── ImageListModel.java
│ │ │ │ └── ImageListModelImpl.java
│ │ │ ├── persenter
│ │ │ │ ├── ImageListPersenter.java
│ │ │ │ └── ImageListPersenterImpl.java
│ │ │ ├── view
│ │ │ │ └── ImageListView.java
│ │ │ └── widget
│ │ │ │ └── fragment
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── MRXTFragment.java
│ │ │ │ ├── NewFragment.java
│ │ │ │ ├── SWMTFragment.java
│ │ │ │ ├── ShaoNvFragment.java
│ │ │ │ ├── WALLPAPERFragment.java
│ │ │ │ ├── WMXZFragment.java
│ │ │ │ └── XinGanFragment.java
│ │ │ └── typeImageList
│ │ │ ├── domain
│ │ │ └── TypeImageDomain.java
│ │ │ ├── model
│ │ │ ├── TypeImageListModel.java
│ │ │ └── TypeImageListModelImpl.java
│ │ │ ├── persenter
│ │ │ ├── TypeImageListPersenter.java
│ │ │ └── TypeImageListPersenterImpl.java
│ │ │ ├── view
│ │ │ └── TypeImageListView.java
│ │ │ └── widget
│ │ │ └── TypeImageActivity.java
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── ic_date.png
│ │ ├── ic_home.png
│ │ ├── ic_mine.png
│ │ ├── ic_notifications.png
│ │ ├── ic_photo.png
│ │ ├── pic_loading.png
│ │ └── pic_loading_round.png
│ │ ├── drawable-mdpi
│ │ ├── ic_date.png
│ │ ├── ic_home.png
│ │ ├── ic_mine.png
│ │ ├── ic_notifications.png
│ │ └── ic_photo.png
│ │ ├── drawable-v21
│ │ ├── ic_menu_camera.xml
│ │ ├── ic_menu_gallery.xml
│ │ ├── ic_menu_manage.xml
│ │ ├── ic_menu_send.xml
│ │ ├── ic_menu_share.xml
│ │ └── ic_menu_slideshow.xml
│ │ ├── drawable-xhdpi
│ │ ├── ic_date.png
│ │ ├── ic_home.png
│ │ ├── ic_mine.png
│ │ ├── ic_notifications.png
│ │ └── ic_photo.png
│ │ ├── drawable-xxhdpi
│ │ ├── ic_about.png
│ │ ├── ic_date.png
│ │ ├── ic_home.png
│ │ ├── ic_least.png
│ │ ├── ic_mine.png
│ │ ├── ic_mrxt.png
│ │ ├── ic_notifications.png
│ │ ├── ic_personal.png
│ │ ├── ic_photo.png
│ │ ├── ic_sex.png
│ │ ├── ic_share.png
│ │ ├── ic_swyh.png
│ │ ├── ic_wallper.png
│ │ ├── ic_wmxz.png
│ │ └── icon.png
│ │ ├── drawable
│ │ └── side_nav_bar.xml
│ │ ├── layout
│ │ ├── activity_image_detial.xml
│ │ ├── activity_image_view_pager.xml
│ │ ├── activity_main.xml
│ │ ├── activity_type_image.xml
│ │ ├── app_bar_main.xml
│ │ ├── content_main.xml
│ │ ├── fragment_main.xml
│ │ ├── nav_header_main.xml
│ │ ├── view_item_fragment_main.xml
│ │ └── view_item_type_image.xml
│ │ ├── menu
│ │ ├── activity_main_drawer.xml
│ │ └── main.xml
│ │ ├── 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
│ │ └── ic_luc.png
│ │ ├── values-v21
│ │ ├── dimens.xml
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── drawables.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── flyou
│ └── girls
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by flyou
2 | ### Android template
3 |
4 | # ios DS_Store
5 | .DS_Store
6 |
7 | # Built application files
8 | *.apk
9 | *.ap_
10 |
11 | # Files for the Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 |
22 | # idea
23 | /.idea/workspace.xml
24 | /.idea/libraries
25 |
26 | # Gradle files
27 | .gradle/
28 | /build
29 |
30 | # Local configuration file (sdk path, etc)
31 | local.properties
32 |
33 | # Proguard folder generated by Eclipse
34 | proguard/
35 |
36 | # Log Files
37 | *.log
38 |
39 | # Android Studio Navigation editor temp files
40 | .navigation/
41 |
42 | # Android Studio captures folder
43 | captures/
44 |
45 | # Intellij
46 | *.iml
47 |
48 | # Keystore files
49 | *.jks
50 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Girls
--------------------------------------------------------------------------------
/.idea/codeStyleSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
227 |
228 |
229 |
--------------------------------------------------------------------------------
/.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 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Girls
2 |
3 |
4 |
5 | - **我**最近比较闲,无意中发现了一个神秘的网站(不要想太多,仅仅是个图片网站而已),看了看还不错,就多看了两眼(岂止两眼啊)。
6 |
7 | - **爱** :当然上面图片的质量挺高的,于是自己先是用python写了爬虫,把整站的图片爬到了七牛上,是不是看到这里大家就已经迫不及待了,表急啊。但是出现了一个问题就是这个网站更新挺快的,一来我不想在服务器搞服务搞这些图片,二来啊这么多好东好帮手;
8 | - **学** :注意!注意!注意!
9 | - **习** :前方高能,未满十八周岁的开发者请迅速收藏本网页,回家再慢慢看
10 |
11 | -------------------
12 |
13 |
14 | ##特性
15 |
16 | ####- XJAVA+MVP
17 | ####- material design
18 | ####- Jsoup数据解析
19 | ####- glide图片加载
20 | 
21 | 
22 | 
23 | 
24 | 
25 | ####最新apk下载地址,猛戳下面
26 | ####[DownLoad](http://fir.im/Girls)"DownLoad")
27 |
28 |
29 | 我才不会告诉你们,在源文件里面有网站地址呢
30 |
31 |
32 |
33 |
34 |
35 |
36 | ##About me
37 | - weibo:[@flyou](http://weibo.com/fangjaylong)
38 | - Email:
39 |
40 | ---------
41 |
42 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
3 |
--------------------------------------------------------------------------------
/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.flyou.girls"
9 | minSdkVersion 15
10 | targetSdkVersion 22
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 'io.reactivex:rxjava:1.1.0'
26 | compile 'io.reactivex:rxandroid:1.1.0'
27 | compile 'com.android.support:appcompat-v7:23.3.0'
28 | compile 'com.android.support:design:23.3.0'
29 | compile files('libs/jsoup-1.9.1.jar')
30 | compile 'com.android.support:cardview-v7:23.3.0'
31 | compile 'com.android.support:recyclerview-v7:23.3.0'
32 | compile 'jp.wasabeef:recyclerview-animators:2.1.0'
33 | compile 'com.github.bumptech.glide:glide:3.7.0'
34 | compile 'com.github.chrisbanes:PhotoView:1.2.6'
35 | //Material Dialog
36 | compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') {
37 | transitive = true
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/app/libs/jsoup-1.9.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/libs/jsoup-1.9.1.jar
--------------------------------------------------------------------------------
/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:\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/androidTest/java/com/flyou/girls/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls;
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 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/Constant.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls;
2 |
3 | /**
4 | * ============================================================
5 | * 项目名称:Girls
6 | * 包名称:com.flyou.girls
7 | * 文件名:Constant
8 | * 类描述:
9 | * 创建人:flyou
10 | * 邮箱:fangjaylong@gmail.com
11 | * 创建时间:2016/4/19 15:57
12 | * 修改备注:
13 | * 版本:@version V1.0
14 | * ============================================================
15 | **/
16 | public class Constant {
17 | public static final String BASE_URL="http://m.xxxiao.com";
18 | public static final String NEW="/page/";
19 | public static final String XINGGAN="/cat/xinggan/page/";
20 | public static final String SHAONV="/cat/shaonv/page/";
21 | public static final String MRXT="/cat/mrxt/page/";
22 | public static final String SWMT="/cat/swmt/page/";
23 | public static final String WMXZ="/cat/wmxz/page/";
24 | public static final String WALLPAPER="/cat/wallpaper/page";
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/SpacesItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | /**
8 | * ============================================================
9 | * 项目名称:Girls
10 | * 包名称:com.flyou.girls.adapter
11 | * 文件名:SpacesItemDecoration
12 | * 类描述:
13 | * 创建人:flyou
14 | * 邮箱:fangjaylong@gmail.com
15 | * 创建时间:2016/4/20 17:05
16 | * 修改备注:
17 | * 版本:@version V1.0
18 | * ============================================================
19 | **/
20 | public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
21 |
22 | private int space;
23 |
24 | public SpacesItemDecoration(int space) {
25 | this.space=space;
26 | }
27 |
28 | @Override
29 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
30 | outRect.left=space;
31 | outRect.right=space;
32 | outRect.bottom=space;
33 | if(parent.getChildAdapterPosition(view)==0){
34 | outRect.top=space;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/ViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Paint;
7 | import android.graphics.Typeface;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.text.util.Linkify;
12 | import android.util.SparseArray;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.view.animation.AlphaAnimation;
17 | import android.widget.Checkable;
18 | import android.widget.ImageView;
19 | import android.widget.ProgressBar;
20 | import android.widget.RatingBar;
21 | import android.widget.TextView;
22 |
23 | import com.bumptech.glide.Glide;
24 | import com.flyou.girls.R;
25 |
26 | public class ViewHolder extends RecyclerView.ViewHolder {
27 | private SparseArray mViews;
28 | private int mPosition;
29 | private View mConvertView;
30 | private Context mContext;
31 | private int mLayoutId;
32 |
33 | public ViewHolder(Context context, View itemView, ViewGroup parent, int position) {
34 | super(itemView);
35 | mContext = context;
36 | mConvertView = itemView;
37 | mPosition = position;
38 | mViews = new SparseArray();
39 | mConvertView.setTag(this);
40 |
41 | }
42 |
43 |
44 | public static ViewHolder get(Context context, View convertView,
45 | ViewGroup parent, int layoutId, int position) {
46 | if (convertView == null) {
47 | View itemView = LayoutInflater.from(context).inflate(layoutId, parent,
48 | false);
49 | ViewHolder holder = new ViewHolder(context, itemView, parent, position);
50 | holder.mLayoutId = layoutId;
51 | return holder;
52 | } else {
53 | ViewHolder holder = (ViewHolder) convertView.getTag();
54 | holder.mPosition = position;
55 | return holder;
56 | }
57 | }
58 |
59 |
60 | /**
61 | * 通过viewId获取控件
62 | *
63 | * @param viewId
64 | * @return
65 | */
66 | public T getView(int viewId) {
67 | View view = mViews.get(viewId);
68 | if (view == null) {
69 | view = mConvertView.findViewById(viewId);
70 | mViews.put(viewId, view);
71 | }
72 | return (T) view;
73 | }
74 |
75 | public View getConvertView() {
76 | return mConvertView;
77 | }
78 |
79 | /**
80 | * 设置TextView的值
81 | *
82 | * @param viewId
83 | * @param text
84 | * @return
85 | */
86 | public ViewHolder setText(int viewId, String text) {
87 | TextView tv = getView(viewId);
88 | tv.setText(text);
89 | return this;
90 | }
91 |
92 | public ViewHolder setImageResource(int viewId, int resId) {
93 | ImageView view = getView(viewId);
94 | view.setImageResource(resId);
95 | return this;
96 | }
97 |
98 | public ViewHolder setImageWithUrl(int viewId, String url) {
99 | ImageView view = getView(viewId);
100 | Glide.with(mContext)
101 | .load(url)
102 | .centerCrop()
103 | .crossFade()
104 | .placeholder(R.drawable.pic_loading)
105 | .error(R.drawable.pic_loading)
106 | .into(view);
107 | return this;
108 | }
109 |
110 | public ViewHolder setImageWithUrlAndSize(int viewId, String url, int width, int height) {
111 | ImageView view = getView(viewId);
112 | Glide.with(mContext)
113 | .load(url)
114 | .centerCrop()
115 | .crossFade()
116 | .placeholder(R.drawable.pic_loading)
117 |
118 | .into(view);
119 | return this;
120 | }
121 |
122 | public ViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
123 | ImageView view = getView(viewId);
124 | view.setImageBitmap(bitmap);
125 | return this;
126 | }
127 |
128 | public ViewHolder setImageDrawable(int viewId, Drawable drawable) {
129 | ImageView view = getView(viewId);
130 | view.setImageDrawable(drawable);
131 | return this;
132 | }
133 |
134 | public ViewHolder setBackgroundColor(int viewId, int color) {
135 | View view = getView(viewId);
136 | view.setBackgroundColor(color);
137 | return this;
138 | }
139 |
140 | public ViewHolder setBackgroundRes(int viewId, int backgroundRes) {
141 | View view = getView(viewId);
142 | view.setBackgroundResource(backgroundRes);
143 | return this;
144 | }
145 |
146 | public ViewHolder setTextColor(int viewId, int textColor) {
147 | TextView view = getView(viewId);
148 | view.setTextColor(textColor);
149 | return this;
150 | }
151 |
152 | public ViewHolder setTextColorRes(int viewId, int textColorRes) {
153 | TextView view = getView(viewId);
154 | view.setTextColor(mContext.getResources().getColor(textColorRes));
155 | return this;
156 | }
157 |
158 | @SuppressLint("NewApi")
159 | public ViewHolder setAlpha(int viewId, float value) {
160 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
161 | getView(viewId).setAlpha(value);
162 | } else {
163 | // Pre-honeycomb hack to set Alpha value
164 | AlphaAnimation alpha = new AlphaAnimation(value, value);
165 | alpha.setDuration(0);
166 | alpha.setFillAfter(true);
167 | getView(viewId).startAnimation(alpha);
168 | }
169 | return this;
170 | }
171 |
172 | public ViewHolder setVisible(int viewId, boolean visible) {
173 | View view = getView(viewId);
174 | view.setVisibility(visible ? View.VISIBLE : View.GONE);
175 | return this;
176 | }
177 |
178 | public ViewHolder linkify(int viewId) {
179 | TextView view = getView(viewId);
180 | Linkify.addLinks(view, Linkify.ALL);
181 | return this;
182 | }
183 |
184 | public ViewHolder setTypeface(Typeface typeface, int... viewIds) {
185 | for (int viewId : viewIds) {
186 | TextView view = getView(viewId);
187 | view.setTypeface(typeface);
188 | view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
189 | }
190 | return this;
191 | }
192 |
193 | public ViewHolder setProgress(int viewId, int progress) {
194 | ProgressBar view = getView(viewId);
195 | view.setProgress(progress);
196 | return this;
197 | }
198 |
199 | public ViewHolder setProgress(int viewId, int progress, int max) {
200 | ProgressBar view = getView(viewId);
201 | view.setMax(max);
202 | view.setProgress(progress);
203 | return this;
204 | }
205 |
206 | public ViewHolder setMax(int viewId, int max) {
207 | ProgressBar view = getView(viewId);
208 | view.setMax(max);
209 | return this;
210 | }
211 |
212 | public ViewHolder setRating(int viewId, float rating) {
213 | RatingBar view = getView(viewId);
214 | view.setRating(rating);
215 | return this;
216 | }
217 |
218 | public ViewHolder setRating(int viewId, float rating, int max) {
219 | RatingBar view = getView(viewId);
220 | view.setMax(max);
221 | view.setRating(rating);
222 | return this;
223 | }
224 |
225 | public ViewHolder setTag(int viewId, Object tag) {
226 | View view = getView(viewId);
227 | view.setTag(tag);
228 | return this;
229 | }
230 |
231 | public ViewHolder setTag(int viewId, int key, Object tag) {
232 | View view = getView(viewId);
233 | view.setTag(key, tag);
234 | return this;
235 | }
236 |
237 | public ViewHolder setChecked(int viewId, boolean checked) {
238 | Checkable view = (Checkable) getView(viewId);
239 | view.setChecked(checked);
240 | return this;
241 | }
242 |
243 | /**
244 | * 关于事件的
245 | */
246 | public ViewHolder setOnClickListener(int viewId,
247 | View.OnClickListener listener) {
248 | View view = getView(viewId);
249 | view.setOnClickListener(listener);
250 | return this;
251 | }
252 |
253 | public ViewHolder setOnTouchListener(int viewId,
254 | View.OnTouchListener listener) {
255 | View view = getView(viewId);
256 | view.setOnTouchListener(listener);
257 | return this;
258 | }
259 |
260 | public ViewHolder setOnLongClickListener(int viewId,
261 | View.OnLongClickListener listener) {
262 | View view = getView(viewId);
263 | view.setOnLongClickListener(listener);
264 | return this;
265 | }
266 |
267 | public void updatePosition(int position) {
268 | mPosition = position;
269 | }
270 |
271 | public int getCurPosition(){ return mPosition; }
272 |
273 | public int getLayoutId() {
274 | return mLayoutId;
275 | }
276 | }
277 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/CommonAdapter.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.flyou.girls.adapter.ViewHolder;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * Created by zhy on 16/4/9.
15 | */
16 | public abstract class CommonAdapter extends RecyclerView.Adapter
17 | {
18 | protected Context mContext;
19 | protected int mLayoutId;
20 | protected List mDatas;
21 | protected LayoutInflater mInflater;
22 |
23 | private OnItemClickListener mOnItemClickListener;
24 |
25 | public void setOnItemClickListener(OnItemClickListener onItemClickListener)
26 | {
27 | this.mOnItemClickListener = onItemClickListener;
28 | }
29 |
30 | public CommonAdapter(Context context, int layoutId, List datas)
31 | {
32 | mContext = context;
33 | mInflater = LayoutInflater.from(context);
34 | mLayoutId = layoutId;
35 | mDatas = datas;
36 | }
37 |
38 | @Override
39 | public ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType)
40 | {
41 | ViewHolder viewHolder = ViewHolder.get(mContext, null, parent, mLayoutId, -1);
42 | setListener(parent, viewHolder, viewType);
43 | return viewHolder;
44 | }
45 |
46 | protected int getPosition(RecyclerView.ViewHolder viewHolder)
47 | {
48 | return viewHolder.getAdapterPosition();
49 | }
50 |
51 | protected boolean isEnabled(int viewType)
52 | {
53 | return true;
54 | }
55 |
56 |
57 | protected void setListener(final ViewGroup parent, final ViewHolder viewHolder, int viewType)
58 | {
59 | if (!isEnabled(viewType)) return;
60 | viewHolder.getConvertView().setOnClickListener(new View.OnClickListener()
61 | {
62 | @Override
63 | public void onClick(View v)
64 | {
65 | if (mOnItemClickListener != null)
66 | {
67 | int position = getPosition(viewHolder);
68 | mOnItemClickListener.onItemClick(parent, v, mDatas.get(position), position);
69 | }
70 | }
71 | });
72 |
73 |
74 | viewHolder.getConvertView().setOnLongClickListener(new View.OnLongClickListener()
75 | {
76 | @Override
77 | public boolean onLongClick(View v)
78 | {
79 | if (mOnItemClickListener != null)
80 | {
81 | int position = getPosition(viewHolder);
82 | return mOnItemClickListener.onItemLongClick(parent, v, mDatas.get(position), position);
83 | }
84 | return false;
85 | }
86 | });
87 | }
88 |
89 | @Override
90 | public void onBindViewHolder(ViewHolder holder, int position)
91 | {
92 | holder.updatePosition(position);
93 | convert(holder, mDatas.get(position));
94 | }
95 |
96 | public abstract void convert(ViewHolder holder, T t);
97 |
98 | @Override
99 | public int getItemCount()
100 | {
101 | return mDatas.size();
102 | }
103 |
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/DividerItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;/*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * limitations under the License.
6 | */
7 |
8 | import android.content.Context;
9 | import android.content.res.TypedArray;
10 | import android.graphics.Canvas;
11 | import android.graphics.Rect;
12 | import android.graphics.drawable.Drawable;
13 | import android.support.v7.widget.LinearLayoutManager;
14 | import android.support.v7.widget.RecyclerView;
15 | import android.view.View;
16 |
17 |
18 | /**
19 | * This class is from the v7 samples of the Android SDK. It's not by me!
20 | *
21 | * See the license above for details.
22 | */
23 | public class DividerItemDecoration extends RecyclerView.ItemDecoration {
24 |
25 | private static final int[] ATTRS = new int[]{
26 | android.R.attr.listDivider
27 | };
28 |
29 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
30 |
31 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
32 |
33 | private Drawable mDivider;
34 |
35 | private int mOrientation;
36 |
37 | public DividerItemDecoration(Context context, int orientation) {
38 | final TypedArray a = context.obtainStyledAttributes(ATTRS);
39 | mDivider = a.getDrawable(0);
40 | a.recycle();
41 | setOrientation(orientation);
42 | }
43 |
44 | public void setOrientation(int orientation) {
45 | if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
46 | throw new IllegalArgumentException("invalid orientation");
47 | }
48 | mOrientation = orientation;
49 | }
50 |
51 | @Override
52 | public void onDraw(Canvas c, RecyclerView parent) {
53 |
54 | if (mOrientation == VERTICAL_LIST) {
55 | drawVertical(c, parent);
56 | } else {
57 | drawHorizontal(c, parent);
58 | }
59 |
60 | }
61 |
62 |
63 | public void drawVertical(Canvas c, RecyclerView parent) {
64 | final int left = parent.getPaddingLeft();
65 | final int right = parent.getWidth() - parent.getPaddingRight();
66 |
67 | final int childCount = parent.getChildCount();
68 | for (int i = 0; i < childCount; i++) {
69 | final View child = parent.getChildAt(i);
70 | RecyclerView v = new RecyclerView(parent.getContext());
71 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
72 | .getLayoutParams();
73 | final int top = child.getBottom() + params.bottomMargin;
74 | final int bottom = top + mDivider.getIntrinsicHeight();
75 | mDivider.setBounds(left, top, right, bottom);
76 | mDivider.draw(c);
77 | }
78 | }
79 |
80 | public void drawHorizontal(Canvas c, RecyclerView parent) {
81 | final int top = parent.getPaddingTop();
82 | final int bottom = parent.getHeight() - parent.getPaddingBottom();
83 |
84 | final int childCount = parent.getChildCount();
85 | for (int i = 0; i < childCount; i++) {
86 | final View child = parent.getChildAt(i);
87 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
88 | .getLayoutParams();
89 | final int left = child.getRight() + params.rightMargin;
90 | final int right = left + mDivider.getIntrinsicHeight();
91 | mDivider.setBounds(left, top, right, bottom);
92 | mDivider.draw(c);
93 | }
94 | }
95 |
96 | @Override
97 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
98 | if (mOrientation == VERTICAL_LIST) {
99 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
100 | } else {
101 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/EmptyRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | /**
9 | * https://gist.github.com/adelnizamutdinov/31c8f054d1af4588dc5c
10 | */
11 | public class EmptyRecyclerView extends RecyclerView
12 | {
13 | View emptyView;
14 |
15 | public EmptyRecyclerView(Context context)
16 | {
17 | super(context);
18 | }
19 |
20 | public EmptyRecyclerView(Context context, AttributeSet attrs)
21 | {
22 | super(context, attrs);
23 | }
24 |
25 | public EmptyRecyclerView(Context context, AttributeSet attrs, int defStyle)
26 | {
27 | super(context, attrs, defStyle);
28 | }
29 |
30 | void checkIfEmpty()
31 | {
32 | if (emptyView != null)
33 | {
34 | emptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE);
35 | }
36 | }
37 |
38 | final AdapterDataObserver observer = new AdapterDataObserver()
39 | {
40 | @Override
41 | public void onChanged()
42 | {
43 | super.onChanged();
44 | checkIfEmpty();
45 | }
46 | };
47 |
48 | @Override
49 | public void swapAdapter(Adapter adapter, boolean removeAndRecycleExistingViews)
50 | {
51 | final Adapter oldAdapter = getAdapter();
52 | if (oldAdapter != null)
53 | {
54 | oldAdapter.unregisterAdapterDataObserver(observer);
55 | }
56 |
57 | if (adapter != null)
58 | {
59 | adapter.registerAdapterDataObserver(observer);
60 | }
61 | super.swapAdapter(adapter, removeAndRecycleExistingViews);
62 | checkIfEmpty();
63 | }
64 |
65 | @Override
66 | public void setAdapter(Adapter adapter)
67 | {
68 | final Adapter oldAdapter = getAdapter();
69 | if (oldAdapter != null)
70 | {
71 | oldAdapter.unregisterAdapterDataObserver(observer);
72 | }
73 | super.setAdapter(adapter);
74 | if (adapter != null)
75 | {
76 | adapter.registerAdapterDataObserver(observer);
77 | }
78 | }
79 |
80 | public void setEmptyView(View emptyView)
81 | {
82 | this.emptyView = emptyView;
83 | checkIfEmpty();
84 | }
85 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/MultiItemCommonAdapter.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.view.ViewGroup;
5 |
6 | import com.flyou.girls.adapter.ViewHolder;
7 |
8 | import java.util.List;
9 |
10 | public abstract class MultiItemCommonAdapter extends CommonAdapter
11 | {
12 |
13 | protected MultiItemTypeSupport mMultiItemTypeSupport;
14 |
15 | public MultiItemCommonAdapter(Context context, List datas,
16 | MultiItemTypeSupport multiItemTypeSupport)
17 | {
18 | super(context, -1, datas);
19 | mMultiItemTypeSupport = multiItemTypeSupport;
20 |
21 | if (mMultiItemTypeSupport == null)
22 | throw new IllegalArgumentException("the mMultiItemTypeSupport can not be null.");
23 | }
24 |
25 | @Override
26 | public int getItemViewType(int position)
27 | {
28 | if (mMultiItemTypeSupport != null)
29 | return mMultiItemTypeSupport.getItemViewType(position, mDatas.get(position));
30 | return super.getItemViewType(position);
31 | }
32 |
33 | @Override
34 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
35 | {
36 | if (mMultiItemTypeSupport == null) return super.onCreateViewHolder(parent, viewType);
37 |
38 | int layoutId = mMultiItemTypeSupport.getLayoutId(viewType);
39 | ViewHolder holder = ViewHolder.get(mContext, null, parent, layoutId, -1);
40 | setListener(parent, holder, viewType);
41 | return holder;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/MultiItemTypeSupport.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;
2 |
3 | public interface MultiItemTypeSupport
4 | {
5 | int getLayoutId(int itemType);
6 |
7 | int getItemViewType(int position, T t);
8 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview;
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/flyou/girls/adapter/recyclerview/support/SectionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview.support;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import com.flyou.girls.adapter.ViewHolder;
7 | import com.flyou.girls.adapter.recyclerview.MultiItemCommonAdapter;
8 | import com.flyou.girls.adapter.recyclerview.MultiItemTypeSupport;
9 |
10 | import java.util.LinkedHashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 | import java.util.Set;
14 |
15 | /**
16 | * Created by zhy on 16/4/9.
17 | */
18 | public abstract class SectionAdapter extends MultiItemCommonAdapter
19 | {
20 | private SectionSupport mSectionSupport;
21 | private static final int TYPE_SECTION = 0;
22 | private LinkedHashMap mSections;
23 |
24 | private MultiItemTypeSupport headerItemTypeSupport;
25 |
26 | @Override
27 | public int getItemViewType(int position)
28 | {
29 | return mMultiItemTypeSupport.getItemViewType(position, null);
30 | }
31 |
32 | final RecyclerView.AdapterDataObserver observer = new RecyclerView.AdapterDataObserver()
33 | {
34 | @Override
35 | public void onChanged()
36 | {
37 | super.onChanged();
38 | findSections();
39 | }
40 | };
41 |
42 | public SectionAdapter(Context context, int layoutId, List datas, SectionSupport sectionSupport)
43 | {
44 | this(context, layoutId, null, datas, sectionSupport);
45 | }
46 |
47 | public SectionAdapter(Context context, MultiItemTypeSupport multiItemTypeSupport, List datas, SectionSupport sectionSupport)
48 | {
49 | this(context, -1, multiItemTypeSupport, datas, sectionSupport);
50 | }
51 |
52 | public SectionAdapter(Context context, int layoutId, MultiItemTypeSupport multiItemTypeSupport, List datas, SectionSupport sectionSupport)
53 | {
54 | super(context, datas, null);
55 | mLayoutId = layoutId;
56 | initMulitiItemTypeSupport(layoutId, multiItemTypeSupport);
57 | mMultiItemTypeSupport = headerItemTypeSupport;
58 | mSectionSupport = sectionSupport;
59 | mSections = new LinkedHashMap<>();
60 | findSections();
61 | registerAdapterDataObserver(observer);
62 | }
63 |
64 | private void initMulitiItemTypeSupport(int layoutId, final MultiItemTypeSupport multiItemTypeSupport)
65 | {
66 | if (layoutId != -1)
67 | {
68 | headerItemTypeSupport = new MultiItemTypeSupport()
69 | {
70 | @Override
71 | public int getLayoutId(int itemType)
72 | {
73 | if (itemType == TYPE_SECTION)
74 | return mSectionSupport.sectionHeaderLayoutId();
75 | else
76 | return mLayoutId;
77 | }
78 |
79 | @Override
80 | public int getItemViewType(int position, T o)
81 | {
82 | int positionVal = getIndexForPosition(position);
83 | return mSections.values().contains(position) ?
84 | TYPE_SECTION :
85 | 1;
86 | }
87 | };
88 | } else if (multiItemTypeSupport != null)
89 | {
90 | headerItemTypeSupport = new MultiItemTypeSupport()
91 | {
92 | @Override
93 | public int getLayoutId(int itemType)
94 | {
95 | if (itemType == TYPE_SECTION)
96 | return mSectionSupport.sectionHeaderLayoutId();
97 | else
98 | return multiItemTypeSupport.getLayoutId(itemType);
99 | }
100 |
101 | @Override
102 | public int getItemViewType(int position, T o)
103 | {
104 | int positionVal = getIndexForPosition(position);
105 | return mSections.values().contains(position) ?
106 | TYPE_SECTION :
107 | multiItemTypeSupport.getItemViewType(positionVal, o);
108 | }
109 | };
110 | } else
111 | {
112 | throw new RuntimeException("layoutId or MultiItemTypeSupport must set one.");
113 | }
114 |
115 | }
116 |
117 | @Override
118 | protected boolean isEnabled(int viewType)
119 | {
120 | if (viewType == TYPE_SECTION)
121 | return false;
122 | return super.isEnabled(viewType);
123 | }
124 |
125 | @Override
126 | public void onDetachedFromRecyclerView(RecyclerView recyclerView)
127 | {
128 | super.onDetachedFromRecyclerView(recyclerView);
129 | unregisterAdapterDataObserver(observer);
130 | }
131 |
132 | public void findSections()
133 | {
134 | int n = mDatas.size();
135 | int nSections = 0;
136 | mSections.clear();
137 |
138 | for (int i = 0; i < n; i++)
139 | {
140 | String sectionName = mSectionSupport.getTitle(mDatas.get(i));
141 |
142 | if (!mSections.containsKey(sectionName))
143 | {
144 | mSections.put(sectionName, i + nSections);
145 | nSections++;
146 | }
147 | }
148 |
149 | }
150 |
151 |
152 | @Override
153 | public int getItemCount()
154 | {
155 | return super.getItemCount() + mSections.size();
156 | }
157 |
158 | public int getIndexForPosition(int position)
159 | {
160 | int nSections = 0;
161 |
162 | Set> entrySet = mSections.entrySet();
163 | for (Map.Entry entry : entrySet)
164 | {
165 | if (entry.getValue() < position)
166 | {
167 | nSections++;
168 | }
169 | }
170 | return position - nSections;
171 | }
172 |
173 | @Override
174 | protected int getPosition(RecyclerView.ViewHolder viewHolder)
175 | {
176 | return getIndexForPosition(viewHolder.getAdapterPosition());
177 | }
178 |
179 | @Override
180 | public void onBindViewHolder(ViewHolder holder, int position)
181 | {
182 | position = getIndexForPosition(position);
183 | if (holder.getItemViewType() == TYPE_SECTION)
184 | {
185 | holder.setText(mSectionSupport.sectionTitleTextViewId(), mSectionSupport.getTitle(mDatas.get(position)));
186 | return;
187 | }
188 | super.onBindViewHolder(holder, position);
189 | }
190 |
191 |
192 | }
193 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/adapter/recyclerview/support/SectionSupport.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.adapter.recyclerview.support;
2 |
3 | /**
4 | * Created by zhy on 16/4/9.
5 | */
6 | public interface SectionSupport
7 | {
8 | public int sectionHeaderLayoutId();
9 |
10 | public int sectionTitleTextViewId();
11 |
12 | public String getTitle(T t);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/ImageDetialActivity.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui;
2 |
3 | import android.os.Bundle;
4 | import android.os.Environment;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.view.Window;
8 | import android.view.WindowManager;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
15 | import com.bumptech.glide.request.RequestListener;
16 | import com.bumptech.glide.request.target.Target;
17 | import com.flyou.girls.R;
18 |
19 | import java.io.File;
20 | import java.io.FileOutputStream;
21 | import java.io.InputStream;
22 | import java.net.HttpURLConnection;
23 | import java.net.URL;
24 | import java.util.jar.Manifest;
25 |
26 | import rx.Observable;
27 | import rx.Subscriber;
28 | import rx.android.schedulers.AndroidSchedulers;
29 | import rx.schedulers.Schedulers;
30 | import uk.co.senab.photoview.PhotoViewAttacher;
31 |
32 | public class ImageDetialActivity extends AppCompatActivity implements View.OnClickListener {
33 | private TextView mDownLoad;
34 | private ImageView mImageView;
35 | private PhotoViewAttacher mAttacher;
36 | private TextView mLoading;
37 | private String mImageurl;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
43 |
44 | this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
45 |
46 | setContentView(R.layout.activity_image_detial);
47 | initView();
48 | initDate();
49 |
50 | }
51 |
52 | private void initDate() {
53 | mImageurl = getIntent().getStringExtra("imageurl");
54 | Glide.with(ImageDetialActivity.this)
55 | .load(mImageurl)
56 | // .centerCrop()
57 | .crossFade()
58 | .listener(new RequestListener() {
59 | @Override
60 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
61 | return false;
62 | }
63 |
64 | @Override
65 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
66 | mLoading.setVisibility(View.GONE);
67 | mDownLoad.setVisibility(View.VISIBLE);
68 | return false;
69 | }
70 | })
71 | .into(mImageView);
72 | mAttacher = new PhotoViewAttacher(mImageView);
73 |
74 | mAttacher.update();
75 |
76 |
77 | }
78 |
79 | private void initView() {
80 | mDownLoad = (TextView) findViewById(R.id.download);
81 | mLoading = (TextView) findViewById(R.id.laoding);
82 | mImageView = (ImageView) findViewById(R.id.imageView);
83 | mDownLoad.setOnClickListener(this);
84 |
85 | }
86 |
87 | @Override
88 | public void onClick(View v) {
89 | switch (v.getId()) {
90 | case R.id.download:
91 | Observable observable = Observable.create(new Observable.OnSubscribe() {
92 | @Override
93 | public void call(Subscriber super String> subscriber) {
94 | String fileName = System.currentTimeMillis() + ".jpg";
95 | File file = new File(Environment.getExternalStorageDirectory() + File.separator+"Girls", fileName);
96 |
97 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
98 |
99 | try {
100 | if (!file.exists()){
101 | file.mkdirs();
102 | }
103 | // 从网络上获取图片
104 | URL url = new URL(mImageurl);
105 | HttpURLConnection conn = null;
106 |
107 | conn = (HttpURLConnection) url.openConnection();
108 | conn.setConnectTimeout(5000);
109 | conn.setRequestMethod("GET");
110 | conn.setDoInput(true);
111 | if (conn.getResponseCode() == 200) {
112 |
113 | InputStream is = conn.getInputStream();
114 | FileOutputStream fos = new FileOutputStream(file);
115 | byte[] buffer = new byte[1024];
116 | int len = 0;
117 | while ((len = is.read(buffer)) != -1) {
118 | fos.write(buffer, 0, len);
119 | }
120 | is.close();
121 | fos.close();
122 |
123 | }
124 | } catch (Exception e) {
125 | e.printStackTrace();
126 | }
127 | subscriber.onNext(file.getAbsolutePath());
128 | } else {
129 | Toast.makeText(ImageDetialActivity.this, "没有发现sd卡,无法下载", Toast.LENGTH_SHORT).show();
130 | }
131 |
132 | }
133 | });
134 | Subscriber subscriber = new Subscriber() {
135 | @Override
136 | public void onCompleted() {
137 |
138 | }
139 |
140 | @Override
141 | public void onError(Throwable e) {
142 | Toast.makeText(ImageDetialActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
143 | }
144 |
145 | @Override
146 | public void onNext(String s) {
147 | Toast.makeText(ImageDetialActivity.this, "图片下载成功:" + s, Toast.LENGTH_SHORT).show();
148 | }
149 | };
150 | observable.subscribeOn(Schedulers.io())
151 | .observeOn(AndroidSchedulers.mainThread())
152 | .subscribe(subscriber);
153 | break;
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/ImageViewPagerActivity.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui;
2 |
3 | import android.graphics.Color;
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.os.Environment;
7 | import android.support.v4.view.PagerAdapter;
8 | import android.support.v4.view.ViewPager;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 | import android.widget.ImageView;
16 | import android.widget.TextView;
17 | import android.widget.Toast;
18 |
19 | import com.bumptech.glide.Glide;
20 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
21 | import com.bumptech.glide.request.RequestListener;
22 | import com.bumptech.glide.request.target.Target;
23 | import com.flyou.girls.R;
24 | import com.flyou.girls.ui.typeImageList.domain.TypeImageDomain;
25 |
26 | import java.io.File;
27 | import java.io.FileOutputStream;
28 | import java.io.InputStream;
29 | import java.net.HttpURLConnection;
30 | import java.net.URL;
31 | import java.util.ArrayList;
32 |
33 | import rx.Observable;
34 | import rx.Subscriber;
35 | import rx.android.schedulers.AndroidSchedulers;
36 | import rx.schedulers.Schedulers;
37 | import uk.co.senab.photoview.PhotoViewAttacher;
38 |
39 | public class ImageViewPagerActivity extends AppCompatActivity {
40 |
41 | private ViewPager mViewPager;
42 | private TextView mNumTV;
43 |
44 | private ArrayList mImageList;
45 | private int mPosition;
46 |
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
52 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//实现半透明状态栏
53 | Window window = getWindow();
54 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
55 | | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
56 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
57 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
58 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
59 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
60 | window.setStatusBarColor(Color.TRANSPARENT);
61 | window.setNavigationBarColor(Color.TRANSPARENT);
62 | }
63 | setContentView(R.layout.activity_image_view_pager);
64 | mImageList = getIntent().getParcelableArrayListExtra("imagelist");
65 | mPosition = getIntent().getIntExtra("position", 0);
66 | if (mImageList == null || mImageList.isEmpty()) {
67 | finish();
68 | return;
69 | }
70 | initView();
71 | initListener();
72 | }
73 |
74 | private void initView() {
75 | mNumTV = (TextView) findViewById(R.id.numTV);
76 | mViewPager = (ViewPager) findViewById(R.id.viewPager);
77 | mNumTV.setText(mPosition + 1 + "/" + mImageList.size());
78 | mViewPager.setAdapter(new ImagePagerAdapter());
79 | mViewPager.setCurrentItem(mPosition);
80 | }
81 |
82 | private void initListener() {
83 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
84 |
85 | @Override
86 | public void onPageSelected(int position) {
87 | mNumTV.setText((position + 1) + "/"
88 | + mImageList.size());
89 | }
90 |
91 | @Override
92 | public void onPageScrolled(int arg0, float arg1, int arg2) {
93 |
94 | }
95 |
96 | @Override
97 | public void onPageScrollStateChanged(int arg0) {
98 |
99 | }
100 | });
101 |
102 | }
103 |
104 | class ImagePagerAdapter extends PagerAdapter {
105 |
106 |
107 | @Override
108 | public int getCount() {
109 | return mImageList.size();
110 | }
111 |
112 | @Override
113 | public View instantiateItem(ViewGroup container, final int position) {
114 | View parent = LayoutInflater.from(container.getContext()).inflate(R.layout.activity_image_detial, container, false);
115 | container.addView(parent);
116 | View downLoad = parent.findViewById(R.id.download);
117 | View loading = parent.findViewById(R.id.laoding);
118 | downLoad.setOnClickListener(new View.OnClickListener() {
119 | @Override
120 | public void onClick(View v) {
121 | downloadImage(mImageList.get(position).getFullSizeUrl());
122 | }
123 | });
124 | downLoad.setTag(mImageList.get(position).getFullSizeUrl());
125 | ImageView imageView = (ImageView) parent.findViewById(R.id.imageView);
126 | displayImage(mImageList.get(position).getFullSizeUrl(),imageView,loading,downLoad);
127 | return parent;
128 | }
129 |
130 | @Override
131 | public void destroyItem(ViewGroup container, int position, Object object) {
132 | container.removeView((View) object);
133 | }
134 |
135 | @Override
136 | public boolean isViewFromObject(View view, Object object) {
137 | return view == object;
138 | }
139 |
140 | void displayImage(final String url,final ImageView imageView,final View loading,final View download) {
141 | Glide.with(ImageViewPagerActivity.this)
142 | .load(url)
143 | // .centerCrop()
144 | .crossFade()
145 | .listener(new RequestListener() {
146 | @Override
147 | public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
148 | return false;
149 | }
150 |
151 | @Override
152 | public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
153 | loading.setVisibility(View.GONE);
154 | download.setVisibility(View.VISIBLE);
155 | PhotoViewAttacher attacher = new PhotoViewAttacher(imageView);
156 | // mAttacher.update();
157 | return false;
158 | }
159 | })
160 | .into(imageView);
161 | }
162 |
163 | void downloadImage(final String imageUrl) {
164 | Observable observable = Observable.create(new Observable.OnSubscribe() {
165 | @Override
166 | public void call(Subscriber super String> subscriber) {
167 | String fileName = System.currentTimeMillis() + ".jpg";
168 | File folader = new File(Environment.getExternalStorageDirectory() + File.separator + "Girls");
169 | File file = new File(Environment.getExternalStorageDirectory() + File.separator + "Girls", fileName);
170 |
171 | if (Environment.getExternalStorageState().equals(
172 |
173 | Environment.MEDIA_MOUNTED)) {
174 |
175 | try {
176 | if (!folader.exists()) {
177 | folader.mkdirs();
178 | }
179 | // 从网络上获取图片
180 | URL url = new URL(imageUrl);
181 | HttpURLConnection conn = null;
182 |
183 | conn = (HttpURLConnection) url.openConnection();
184 | conn.setConnectTimeout(5000);
185 | conn.setRequestMethod("GET");
186 | conn.setDoInput(true);
187 | if (conn.getResponseCode() == 200) {
188 |
189 | InputStream is = conn.getInputStream();
190 | FileOutputStream fos = new FileOutputStream(file);
191 | byte[] buffer = new byte[1024];
192 | int len = 0;
193 | while ((len = is.read(buffer)) != -1) {
194 | fos.write(buffer, 0, len);
195 | }
196 | is.close();
197 | fos.close();
198 |
199 | }
200 | } catch (Exception e) {
201 | e.printStackTrace();
202 | }
203 | subscriber.onNext(file.getAbsolutePath());
204 | } else {
205 | Toast.makeText(ImageViewPagerActivity.this, "没有发现sd卡,无法下载", Toast.LENGTH_SHORT).show();
206 | }
207 |
208 | }
209 | });
210 | Subscriber subscriber = new Subscriber() {
211 | @Override
212 | public void onCompleted() {
213 |
214 | }
215 |
216 | @Override
217 | public void onError(Throwable e) {
218 | Toast.makeText(ImageViewPagerActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
219 | }
220 |
221 | @Override
222 | public void onNext(String s) {
223 | Toast.makeText(ImageViewPagerActivity.this, "图片下载成功:" + s, Toast.LENGTH_SHORT).show();
224 | }
225 | };
226 | observable.subscribeOn(Schedulers.io())
227 | .observeOn(AndroidSchedulers.mainThread())
228 | .subscribe(subscriber);
229 | }
230 | }
231 |
232 | }
233 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.NavigationView;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.GravityCompat;
7 | import android.support.v4.widget.DrawerLayout;
8 | import android.support.v7.app.ActionBarDrawerToggle;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 |
14 | import com.afollestad.materialdialogs.MaterialDialog;
15 | import com.flyou.girls.R;
16 | import com.flyou.girls.ui.mainImageList.widget.fragment.MRXTFragment;
17 | import com.flyou.girls.ui.mainImageList.widget.fragment.NewFragment;
18 | import com.flyou.girls.ui.mainImageList.widget.fragment.SWMTFragment;
19 | import com.flyou.girls.ui.mainImageList.widget.fragment.ShaoNvFragment;
20 | import com.flyou.girls.ui.mainImageList.widget.fragment.WALLPAPERFragment;
21 | import com.flyou.girls.ui.mainImageList.widget.fragment.WMXZFragment;
22 | import com.flyou.girls.ui.mainImageList.widget.fragment.XinGanFragment;
23 |
24 | public class MainActivity extends AppCompatActivity
25 | implements NavigationView.OnNavigationItemSelectedListener {
26 | private Fragment mCurrentFragment;
27 | private Toolbar mToolbar;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
34 | setSupportActionBar(mToolbar);
35 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
36 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
37 | this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
38 | drawer.setDrawerListener(toggle);
39 | toggle.syncState();
40 |
41 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
42 | navigationView.setNavigationItemSelectedListener(this);
43 | navigationView.setCheckedItem(R.id.nav_new);
44 | changeFragment(new NewFragment());
45 | }
46 |
47 | @Override
48 | public void onBackPressed() {
49 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
50 | if (drawer.isDrawerOpen(GravityCompat.START)) {
51 | drawer.closeDrawer(GravityCompat.START);
52 | } else {
53 | super.onBackPressed();
54 | }
55 | }
56 |
57 | @Override
58 | public boolean onCreateOptionsMenu(Menu menu) {
59 | // Inflate the menu; this adds items to the action bar if it is present.
60 | getMenuInflater().inflate(R.menu.main, menu);
61 | return true;
62 | }
63 |
64 | @Override
65 | public boolean onOptionsItemSelected(MenuItem item) {
66 | // Handle action bar item clicks here. The action bar will
67 | // automatically handle clicks on the Home/Up button, so long
68 | // as you specify a parent activity in AndroidManifest.xml.
69 | int id = item.getItemId();
70 |
71 | //noinspection SimplifiableIfStatement
72 | if (id == R.id.action_settings) {
73 | return true;
74 | }
75 |
76 | return super.onOptionsItemSelected(item);
77 | }
78 |
79 | @SuppressWarnings("StatementWithEmptyBody")
80 | @Override
81 | public boolean onNavigationItemSelected(MenuItem item) {
82 | // Handle navigation view item clicks here.
83 | int id = item.getItemId();
84 | switch (id) {
85 | case R.id.nav_new:
86 | changeFragment(new NewFragment());
87 |
88 | break;
89 | case R.id.nav_xingan:
90 | changeFragment(new XinGanFragment());
91 | break;
92 | case R.id.nav_shaonv:
93 | changeFragment(new ShaoNvFragment());
94 | break;
95 | case R.id.nav_mr:
96 | changeFragment(new MRXTFragment());
97 | break;
98 | case R.id.nav_sw:
99 | changeFragment(new SWMTFragment());
100 | break;
101 | case R.id.nav_xz:
102 | changeFragment(new WMXZFragment());
103 | break;
104 | case R.id.nav_wallpaper:
105 | changeFragment(new WALLPAPERFragment());
106 | break;
107 | case R.id.nav_share:
108 | new MaterialDialog.Builder(MainActivity.this)
109 | .title("关于应用")
110 | .icon(getResources().getDrawable(R.drawable.ic_about))
111 | .positiveText("确定")
112 | .content(R.string.about_app)
113 | .show();
114 | break;
115 | case R.id.nav_personal:
116 | new MaterialDialog.Builder(MainActivity.this)
117 | .title("关于作者")
118 | .icon(getResources().getDrawable(R.drawable.ic_personal))
119 | .positiveText("确定")
120 | .content(R.string.about_account)
121 | .show();
122 |
123 | break;
124 | }
125 | mToolbar.setTitle(item.getTitle());
126 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
127 | drawer.closeDrawer(GravityCompat.START);
128 | return true;
129 | }
130 |
131 |
132 | // change fragment
133 | private void changeFragment(Fragment fragment) {
134 | if (mCurrentFragment == null || !fragment.getClass().getName().equals(mCurrentFragment.getClass().getName())) {
135 | getSupportFragmentManager().beginTransaction().replace(R.id.fragent_content, fragment).commit();
136 | mCurrentFragment = fragment;
137 | }
138 |
139 |
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/domain/ImageListDomain.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.domain;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * ============================================================
8 | * 项目名称:Girls
9 | * 包名称:com.flyou.girls.ui.ImageList.domain
10 | * 文件名:ImageListDomain
11 | * 类描述:
12 | * 创建人:flyou
13 | * 邮箱:fangjaylong@gmail.com
14 | * 创建时间:2016/4/19 15:47
15 | * 修改备注:
16 | * 版本:@version V1.0
17 | * ============================================================
18 | **/
19 | public class ImageListDomain implements Parcelable {
20 | private String linkUrl;
21 | private String imageUrl;
22 | private String imgaeTitle;
23 |
24 |
25 |
26 | public String getLinkUrl() {
27 | return linkUrl;
28 | }
29 |
30 | public void setLinkUrl(String linkUrl) {
31 | this.linkUrl = linkUrl;
32 | }
33 |
34 | public String getImageUrl() {
35 | return imageUrl;
36 | }
37 |
38 | public void setImageUrl(String imageUrl) {
39 | this.imageUrl = imageUrl;
40 | }
41 |
42 | public String getImgaeTitle() {
43 | return imgaeTitle;
44 | }
45 |
46 | public void setImgaeTitle(String imgaeTitle) {
47 | this.imgaeTitle = imgaeTitle;
48 | }
49 |
50 | public ImageListDomain(String linkUrl, String imageUrl, String imgaeTitle) {
51 | this.linkUrl = linkUrl;
52 | this.imageUrl = imageUrl;
53 | this.imgaeTitle = imgaeTitle;
54 | }
55 |
56 | @Override
57 | public int describeContents() {
58 | return 0;
59 | }
60 |
61 | @Override
62 | public void writeToParcel(Parcel dest, int flags) {
63 | dest.writeString(this.linkUrl);
64 | dest.writeString(this.imageUrl);
65 | dest.writeString(this.imgaeTitle);
66 | }
67 |
68 | protected ImageListDomain(Parcel in) {
69 | this.linkUrl = in.readString();
70 | this.imageUrl = in.readString();
71 | this.imgaeTitle = in.readString();
72 | }
73 |
74 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
75 | @Override
76 | public ImageListDomain createFromParcel(Parcel source) {
77 | return new ImageListDomain(source);
78 | }
79 |
80 | @Override
81 | public ImageListDomain[] newArray(int size) {
82 | return new ImageListDomain[size];
83 | }
84 | };
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/model/ImageListModel.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.model;
2 |
3 | /**
4 | * ============================================================
5 | * 项目名称:Girls
6 | * 包名称:com.flyou.girls.ui.ImageList.domain
7 | * 文件名:ImageListModel
8 | * 类描述:
9 | * 创建人:flyou
10 | * 邮箱:fangjaylong@gmail.com
11 | * 创建时间:2016/4/19 15:39
12 | * 修改备注:
13 | * 版本:@version V1.0
14 | * ============================================================
15 | **/
16 | public interface ImageListModel {
17 | void GetImageList(String type,int page,ImageListModelImpl.GetImageListenter listener);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/model/ImageListModelImpl.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.model;
2 |
3 | import com.flyou.girls.Constant;
4 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
5 |
6 | import org.jsoup.Jsoup;
7 | import org.jsoup.nodes.Document;
8 | import org.jsoup.nodes.Element;
9 | import org.jsoup.select.Elements;
10 |
11 | import java.io.IOException;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import rx.Observable;
16 | import rx.Subscriber;
17 | import rx.android.schedulers.AndroidSchedulers;
18 | import rx.schedulers.Schedulers;
19 |
20 | /**
21 | * ============================================================
22 | * 项目名称:Girls
23 | * 包名称:com.flyou.girls.ui.ImageList.domain
24 | * 文件名:ImageListModelImpl
25 | * 类描述:
26 | * 创建人:flyou
27 | * 邮箱:fangjaylong@gmail.com
28 | * 创建时间:2016/4/19 15:45
29 | * 修改备注:
30 | * 版本:@version V1.0
31 | * ============================================================
32 | **/
33 | public class ImageListModelImpl implements ImageListModel {
34 |
35 |
36 | @Override
37 | public void GetImageList(final String type, final int page, final GetImageListenter listener) {
38 |
39 |
40 | Observable> observable = Observable.create(new Observable.OnSubscribe>() {
41 | @Override
42 | public void call(Subscriber super List> subscriber) {
43 | List imageListDomainList = new ArrayList();
44 | try {
45 | Document document = Jsoup.connect(Constant.BASE_URL + type+page).get();
46 | Element imageListelement = document.getElementById("blog-grid");
47 |
48 | Elements imageListElements = imageListelement.getElementsByAttributeValueContaining("class","col-lg-4 col-md-4 three-columns post-box");
49 | for (Element imageListElement : imageListElements) {
50 | Element link = imageListElement.select("a[href]").first();
51 | Element image = imageListElement.select("img").first();
52 | String linkUrl = link.attr("abs:href");
53 | String imageUrl = image.attr("abs:src");
54 | String imageTitle = image.attr("alt").trim();
55 | imageListDomainList.add(new ImageListDomain(linkUrl, imageUrl, imageTitle));
56 |
57 | }
58 | subscriber.onNext(imageListDomainList);
59 |
60 | } catch (IOException e) {
61 | subscriber.onError(e);
62 |
63 | }
64 |
65 | }
66 | });
67 |
68 | Subscriber> subscriber = new Subscriber>() {
69 | @Override
70 | public void onCompleted() {
71 | }
72 |
73 | @Override
74 | public void onError(Throwable e) {
75 | listener.OnError((Exception) e);
76 | }
77 |
78 | @Override
79 | public void onNext(List imageListDomains) {
80 | listener.onSuccess(imageListDomains);
81 | }
82 | };
83 |
84 | observable
85 | .subscribeOn(Schedulers.io())
86 | .observeOn(AndroidSchedulers.mainThread())
87 | .subscribe(subscriber);
88 |
89 |
90 | }
91 |
92 | public interface GetImageListenter {
93 | void onSuccess(List imageList);
94 |
95 | void OnError(Exception e);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/persenter/ImageListPersenter.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.persenter;
2 |
3 | /**
4 | * ============================================================
5 | * 项目名称:Girls
6 | * 包名称:com.flyou.girls.ui.ImageList.persenter
7 | * 文件名:ImageListPersenter
8 | * 类描述:
9 | * 创建人:flyou
10 | * 邮箱:fangjaylong@gmail.com
11 | * 创建时间:2016/4/19 16:46
12 | * 修改备注:
13 | * 版本:@version V1.0
14 | * ============================================================
15 | **/
16 | public interface ImageListPersenter {
17 | void startGetImageList(String type,int page);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/persenter/ImageListPersenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.persenter;
2 |
3 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
4 | import com.flyou.girls.ui.mainImageList.model.ImageListModel;
5 | import com.flyou.girls.ui.mainImageList.model.ImageListModelImpl;
6 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * ============================================================
12 | * 项目名称:Girls
13 | * 包名称:com.flyou.girls.ui.ImageList.persenter
14 | * 文件名:ImageListPersenterImpl
15 | * 类描述:
16 | * 创建人:flyou
17 | * 邮箱:fangjaylong@gmail.com
18 | * 创建时间:2016/4/19 16:48
19 | * 修改备注:
20 | * 版本:@version V1.0
21 | * ============================================================
22 | **/
23 | public class ImageListPersenterImpl implements ImageListModelImpl.GetImageListenter,ImageListPersenter{
24 | private ImageListView imageListView;
25 | private ImageListModel imageListModel;
26 |
27 | public ImageListPersenterImpl(ImageListView imageListView) {
28 | this.imageListView = imageListView;
29 | this.imageListModel=new ImageListModelImpl();
30 | }
31 |
32 |
33 | @Override
34 | public void onSuccess(List imageList) {
35 | imageListView.receiveImageList(imageList);
36 | imageListView.hideLoading();
37 | }
38 |
39 | @Override
40 | public void OnError(Exception e) {
41 | imageListView.showLoadFaild(e);
42 | imageListView.hideLoading();
43 | }
44 |
45 | @Override
46 | public void startGetImageList(String type,int page) {
47 | imageListView.showLaoding();
48 | imageListModel.GetImageList(type,page,this);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/view/ImageListView.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.view;
2 |
3 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * ============================================================
9 | * 项目名称:Girls
10 | * 包名称:com.flyou.girls.ui.ImageList.view
11 | * 文件名:ImageListView
12 | * 类描述:
13 | * 创建人:flyou
14 | * 邮箱:fangjaylong@gmail.com
15 | * 创建时间:2016/4/19 16:42
16 | * 修改备注:
17 | * 版本:@version V1.0
18 | * ============================================================
19 | **/
20 | public interface ImageListView {
21 | void showLaoding();
22 |
23 | void hideLoading();
24 |
25 | void showLoadFaild( Exception e);
26 |
27 | void receiveImageList(List imageListDomains);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | /**
11 | * ============================================================
12 | * 项目名称:HenuCenterPro
13 | * 包名称:com.flyou.flying.ui.frgment
14 | * 文件名:BaseFragment
15 | * 类描述:
16 | * 创建人:flyou
17 | * 邮箱:fangjaylong@gmail.com
18 | * 创建时间:2015/9/23 10:36
19 | * 修改备注:
20 | * 版本:@version V1.0
21 | * ============================================================
22 | */
23 | public abstract class BaseFragment extends Fragment {
24 | public Activity context;
25 | public View rootView;
26 |
27 | @Override
28 | public void onCreate(Bundle savedInstanceState) {
29 |
30 | super.onCreate(savedInstanceState);
31 |
32 | }
33 |
34 |
35 | @Override
36 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
37 | if (rootView == null) {
38 | rootView = inflater.inflate(getLayoutResource(), container, false);
39 |
40 | }
41 |
42 | return rootView;
43 | }
44 |
45 | @Override
46 | public void onActivityCreated(Bundle savedInstanceState) {
47 |
48 | initView();
49 | initData();
50 | super.onActivityCreated(savedInstanceState);
51 | }
52 |
53 | protected abstract int getLayoutResource();
54 |
55 | protected abstract void initData();
56 |
57 | protected abstract void initView();
58 |
59 | @Override
60 | public void onAttach(Activity activity) {
61 | this.context = activity;
62 | super.onAttach(activity);
63 | }
64 |
65 | @Override
66 | public void onDestroy() {
67 |
68 | super.onDestroy();
69 | }
70 |
71 | public void onResume() {
72 | super.onResume();
73 |
74 | }
75 | public void onPause() {
76 | super.onPause();
77 |
78 | }
79 |
80 | // /*
81 | // * 对象转 json
82 | // * obj 对象
83 | // * */
84 | // public String toJson(Object obj) {
85 | //
86 | // Gson gson = new Gson();
87 | // return gson.toJson(obj);
88 | // }
89 | //
90 | // /*
91 | // * json转对象
92 | // * classOfT 对象类型
93 | // * */
94 | // public T toObj(String json, Type typeOfT) {
95 | // Gson gson = new Gson();
96 | // T t = gson.fromJson(json, typeOfT);
97 | // return t;
98 | // }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/MRXTFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class MRXTFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 | }
117 |
118 | @Override
119 | public void receiveImageList(List imageListDomains) {
120 | if (null == imageListDomains || imageListDomains.size() == 0) {
121 |
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/NewFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class NewFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 |
137 | Intent intent=new Intent(context,TypeImageActivity.class);
138 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
139 | intent.putExtra("title",imageListDomain.getImgaeTitle());
140 | ActivityOptionsCompat options =
141 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
142 | ActivityCompat .startActivity(context, intent, options.toBundle());
143 | }
144 | });
145 | }
146 | };
147 | mLayoutManager = new LinearLayoutManager(context);
148 | mRecyclerView.setLayoutManager(mLayoutManager);
149 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
150 |
151 | mRecyclerView.setAdapter(mAdapter);
152 | mRecyclerView.addOnScrollListener(mOnScrollListener);
153 | } else {
154 | int lastPosition = mImageListDomains.size() - 1;
155 | mImageListDomains.addAll(imageListDomains);
156 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
157 | }
158 |
159 |
160 | }
161 |
162 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
163 |
164 | private int lastVisibleItem;
165 |
166 | @Override
167 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
168 | super.onScrolled(recyclerView, dx, dy);
169 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
170 | }
171 |
172 | @Override
173 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
174 | super.onScrollStateChanged(recyclerView, newState);
175 | if (newState == RecyclerView.SCROLL_STATE_IDLE
176 | && lastVisibleItem + 1 == mAdapter.getItemCount()
177 | ) {
178 | mCurrentPage++;
179 | mPersenter.startGetImageList(mType, mCurrentPage);
180 | }
181 | }
182 | };
183 |
184 | @Override
185 | public void onRefresh() {
186 | mCurrentPage=1;
187 | mPersenter.startGetImageList(mType, mCurrentPage);
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/SWMTFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class SWMTFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/ShaoNvFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class ShaoNvFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/WALLPAPERFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class WALLPAPERFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/WMXZFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class WMXZFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/mainImageList/widget/fragment/XinGanFragment.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.mainImageList.widget.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.ActivityCompat;
5 | import android.support.v4.app.ActivityOptionsCompat;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Toast;
11 |
12 | import com.flyou.girls.Constant;
13 | import com.flyou.girls.R;
14 | import com.flyou.girls.adapter.ViewHolder;
15 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
16 | import com.flyou.girls.ui.mainImageList.domain.ImageListDomain;
17 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenter;
18 | import com.flyou.girls.ui.mainImageList.persenter.ImageListPersenterImpl;
19 | import com.flyou.girls.ui.mainImageList.view.ImageListView;
20 | import com.flyou.girls.ui.typeImageList.widget.TypeImageActivity;
21 |
22 | import java.util.List;
23 |
24 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
25 |
26 | /**
27 | * ============================================================
28 | * 项目名称:Girls
29 | * 包名称:com.flyou.girls.ui.ImageList.widget.fragment
30 | * 文件名:NewFragment
31 | * 类描述:
32 | * 创建人:flyou
33 | * 邮箱:fangjaylong@gmail.com
34 | * 创建时间:2016/4/20 9:11
35 | * 修改备注:
36 | * 版本:@version V1.0
37 | * ============================================================
38 | **/
39 | public class XinGanFragment extends BaseFragment implements ImageListView, SwipeRefreshLayout.OnRefreshListener {
40 | private ImageListPersenter mPersenter;
41 | private String mType;
42 | private int mCurrentPage = 1;
43 | private SwipeRefreshLayout mSwipeRefreshLayout;
44 | private RecyclerView mRecyclerView;
45 | private LinearLayoutManager mLayoutManager;
46 | private CommonAdapter mAdapter;
47 | private List mImageListDomains;
48 |
49 | @Override
50 | protected int getLayoutResource() {
51 | return R.layout.fragment_main;
52 | }
53 |
54 | @Override
55 | protected void initData() {
56 | mPersenter = new ImageListPersenterImpl(this);
57 | switch (getClass().getSimpleName()) {
58 | case "NewFragment":
59 | mType = Constant.NEW;
60 | break;
61 | case "XinGanFragment":
62 | mType = Constant.XINGGAN;
63 | break;
64 | case "ShaoNvFragment":
65 | mType = Constant.SHAONV;
66 | break;
67 | case "MRXTFragment":
68 | mType = Constant.MRXT;
69 | break;
70 | case "SWMTFragment":
71 | mType = Constant.SWMT;
72 | break;
73 | case "WMXZFragment":
74 | mType = Constant.WMXZ;
75 | break;
76 | case "WALLPAPERFragment":
77 | mType = Constant.WALLPAPER;
78 | break;
79 | default:
80 | mType = Constant.NEW;
81 | break;
82 |
83 |
84 | }
85 | mPersenter.startGetImageList(mType, mCurrentPage);
86 | }
87 |
88 | @Override
89 | protected void initView() {
90 | mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
91 | mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);
92 |
93 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
94 | mSwipeRefreshLayout.setOnRefreshListener(this);
95 | }
96 |
97 | @Override
98 | public void showLaoding() {
99 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
100 | mSwipeRefreshLayout.setRefreshing(true);
101 | }
102 |
103 | @Override
104 | public void hideLoading() {
105 | mSwipeRefreshLayout.setRefreshing(false);
106 | }
107 |
108 | @Override
109 | public void showLoadFaild(Exception e) {
110 | if (mCurrentPage!=1){
111 | Toast.makeText(context, "你太贪心了,已经没有更多图片了", Toast.LENGTH_SHORT).show();
112 | }
113 | else {
114 | Toast.makeText(context, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
115 | }
116 |
117 | }
118 |
119 | @Override
120 | public void receiveImageList(List imageListDomains) {
121 | if (null == imageListDomains || imageListDomains.size() == 0) {
122 | Toast.makeText(context, "没有发现更多数据", Toast.LENGTH_SHORT).show();
123 | return;
124 | }
125 |
126 | if (mCurrentPage == 1) {
127 | mImageListDomains=imageListDomains;
128 | mAdapter = new CommonAdapter(context, R.layout.view_item_fragment_main, mImageListDomains) {
129 | @Override
130 | public void convert(ViewHolder holder, final ImageListDomain imageListDomain) {
131 | holder.setText(R.id.tv_title, imageListDomain.getImgaeTitle());
132 | holder.setImageWithUrl(R.id.iv_cover, imageListDomain.getImageUrl());
133 | holder.setOnClickListener(R.id.iv_cover, new View.OnClickListener() {
134 | @Override
135 | public void onClick(View v) {
136 | Intent intent=new Intent(context,TypeImageActivity.class);
137 | intent.putExtra("linkUrl",imageListDomain.getLinkUrl());
138 | intent.putExtra("title",imageListDomain.getImgaeTitle());
139 | ActivityOptionsCompat options =
140 | ActivityOptionsCompat.makeSceneTransitionAnimation(context);
141 | ActivityCompat.startActivity(context, intent, options.toBundle());
142 | }
143 | });
144 | }
145 | };
146 | mLayoutManager = new LinearLayoutManager(context);
147 | mRecyclerView.setLayoutManager(mLayoutManager);
148 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
149 |
150 | mRecyclerView.setAdapter(mAdapter);
151 | mRecyclerView.addOnScrollListener(mOnScrollListener);
152 | } else {
153 | int lastPosition = mImageListDomains.size() - 1;
154 | mImageListDomains.addAll(imageListDomains);
155 | mAdapter.notifyItemRangeInserted(lastPosition, imageListDomains.size());
156 | }
157 |
158 |
159 | }
160 |
161 | private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
162 |
163 | private int lastVisibleItem;
164 |
165 | @Override
166 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
167 | super.onScrolled(recyclerView, dx, dy);
168 | lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
169 | }
170 |
171 | @Override
172 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
173 | super.onScrollStateChanged(recyclerView, newState);
174 | if (newState == RecyclerView.SCROLL_STATE_IDLE
175 | && lastVisibleItem + 1 == mAdapter.getItemCount()
176 | ) {
177 | mCurrentPage++;
178 | mPersenter.startGetImageList(mType, mCurrentPage);
179 | }
180 | }
181 | };
182 |
183 | @Override
184 | public void onRefresh() {
185 | mCurrentPage=1;
186 | mPersenter.startGetImageList(mType, mCurrentPage);
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/domain/TypeImageDomain.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.domain;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * ============================================================
8 | * 项目名称:Girls
9 | * 包名称:com.flyou.girls.ui.typeImageList.domain
10 | * 文件名:TypeImageDomain
11 | * 类描述:
12 | * 创建人:flyou
13 | * 邮箱:fangjaylong@gmail.com
14 | * 创建时间:2016/4/20 14:36
15 | * 修改备注:
16 | * 版本:@version V1.0
17 | * ============================================================
18 | **/
19 | public class TypeImageDomain implements Parcelable {
20 | private int width;
21 | private int height;
22 | private String url;
23 | private String fullSizeUrl;
24 |
25 | public TypeImageDomain(int width, int height, String url, String fullSizeUrl) {
26 | this.width = width;
27 | this.height = height;
28 | this.url = url;
29 | this.fullSizeUrl = fullSizeUrl;
30 | }
31 |
32 | public int getWidth() {
33 | return width;
34 | }
35 |
36 | public void setWidth(int width) {
37 | this.width = width;
38 | }
39 |
40 | public int getHeight() {
41 | return height;
42 | }
43 |
44 | public void setHeight(int height) {
45 | this.height = height;
46 | }
47 |
48 | public String getUrl() {
49 | return url;
50 | }
51 |
52 | public void setUrl(String url) {
53 | this.url = url;
54 | }
55 |
56 | public String getFullSizeUrl() {
57 | return fullSizeUrl;
58 | }
59 |
60 | public void setFullSizeUrl(String fullSizeUrl) {
61 | this.fullSizeUrl = fullSizeUrl;
62 | }
63 |
64 | @Override
65 | public int describeContents() {
66 | return 0;
67 | }
68 |
69 | @Override
70 | public void writeToParcel(Parcel dest, int flags) {
71 | dest.writeInt(this.width);
72 | dest.writeInt(this.height);
73 | dest.writeString(this.url);
74 | dest.writeString(this.fullSizeUrl);
75 | }
76 |
77 | protected TypeImageDomain(Parcel in) {
78 | this.width = in.readInt();
79 | this.height = in.readInt();
80 | this.url = in.readString();
81 | this.fullSizeUrl = in.readString();
82 | }
83 |
84 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
85 | @Override
86 | public TypeImageDomain createFromParcel(Parcel source) {
87 | return new TypeImageDomain(source);
88 | }
89 |
90 | @Override
91 | public TypeImageDomain[] newArray(int size) {
92 | return new TypeImageDomain[size];
93 | }
94 | };
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/model/TypeImageListModel.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.model;
2 |
3 | /**
4 | * ============================================================
5 | * 项目名称:Girls
6 | * 包名称:com.flyou.girls.ui.typeImageList.model
7 | * 文件名:TypeImageListModel
8 | * 类描述:
9 | * 创建人:flyou
10 | * 邮箱:fangjaylong@gmail.com
11 | * 创建时间:2016/4/20 14:42
12 | * 修改备注:
13 | * 版本:@version V1.0
14 | * ============================================================
15 | **/
16 | public interface TypeImageListModel {
17 | void getTypeImageList(String url,TypeImageListModelImpl.OnGetTypeImageListener litener);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/model/TypeImageListModelImpl.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.model;
2 |
3 | import com.flyou.girls.ui.typeImageList.domain.TypeImageDomain;
4 |
5 | import org.jsoup.Jsoup;
6 | import org.jsoup.nodes.Document;
7 | import org.jsoup.nodes.Element;
8 | import org.jsoup.select.Elements;
9 |
10 | import java.io.IOException;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import rx.Observable;
15 | import rx.Subscriber;
16 | import rx.android.schedulers.AndroidSchedulers;
17 | import rx.schedulers.Schedulers;
18 |
19 | /**
20 | * ============================================================
21 | * 项目名称:Girls
22 | * 包名称:com.flyou.girls.ui.typeImageList.model
23 | * 文件名:TypeImageListModelImpl
24 | * 类描述:
25 | * 创建人:flyou
26 | * 邮箱:fangjaylong@gmail.com
27 | * 创建时间:2016/4/20 14:43
28 | * 修改备注:
29 | * 版本:@version V1.0
30 | * ============================================================
31 | **/
32 | public class TypeImageListModelImpl implements TypeImageListModel {
33 | @Override
34 | public void getTypeImageList(final String url, final TypeImageListModelImpl.OnGetTypeImageListener litener) {
35 |
36 |
37 | Observable> observable = Observable.create(new Observable.OnSubscribe>() {
38 | @Override
39 | public void call(Subscriber super List> subscriber) {
40 | List typeImageDomains = new ArrayList();
41 | try {
42 | Document document = Jsoup.connect(url).get();
43 | Element element = document.getElementById("gallery-1");
44 | Elements elementsA = element.getElementsByTag("a");
45 |
46 | for (Element a : elementsA) {
47 | String linkUrl = a.attr("abs:href");
48 |
49 | Elements img = a.getElementsByTag("img");
50 | String src = img.attr("src");
51 | String width = img.attr("width");
52 | String height = img.attr("height");
53 | typeImageDomains.add(new TypeImageDomain(Integer.valueOf(width), Integer.valueOf(height), src,linkUrl));
54 | }
55 | } catch (IOException e) {
56 | subscriber.onError(e);
57 | }
58 | System.out.print(typeImageDomains.get(0).getHeight());
59 | subscriber.onNext(typeImageDomains);
60 | }
61 | });
62 |
63 |
64 | Subscriber> subscriber = new Subscriber>() {
65 | @Override
66 | public void onCompleted() {
67 |
68 | }
69 |
70 | @Override
71 | public void onError(Throwable e) {
72 | litener.OnError((Exception) e);
73 | }
74 |
75 | @Override
76 | public void onNext(List typeImageDomains) {
77 | litener.onSuccess(typeImageDomains);
78 |
79 | }
80 | };
81 |
82 |
83 | observable
84 | .subscribeOn(Schedulers.io())
85 | .observeOn(AndroidSchedulers.mainThread())
86 | .subscribe(subscriber);
87 | }
88 |
89 | public interface OnGetTypeImageListener {
90 | void onSuccess(List imageDomainList);
91 |
92 | void OnError(Exception e);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/persenter/TypeImageListPersenter.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.persenter;
2 |
3 | /**
4 | * ============================================================
5 | * 项目名称:Girls
6 | * 包名称:com.flyou.girls.ui.typeImageList.persenter
7 | * 文件名:TypeImageListPersenter
8 | * 类描述:
9 | * 创建人:flyou
10 | * 邮箱:fangjaylong@gmail.com
11 | * 创建时间:2016/4/20 14:47
12 | * 修改备注:
13 | * 版本:@version V1.0
14 | * ============================================================
15 | **/
16 | public interface TypeImageListPersenter {
17 | void startGetImageList(String url);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/persenter/TypeImageListPersenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.persenter;
2 |
3 | import com.flyou.girls.ui.typeImageList.domain.TypeImageDomain;
4 | import com.flyou.girls.ui.typeImageList.model.TypeImageListModel;
5 | import com.flyou.girls.ui.typeImageList.model.TypeImageListModelImpl;
6 | import com.flyou.girls.ui.typeImageList.view.TypeImageListView;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * ============================================================
12 | * 项目名称:Girls
13 | * 包名称:com.flyou.girls.ui.typeImageList.persenter
14 | * 文件名:TypeImageListPersenterImpl
15 | * 类描述:
16 | * 创建人:flyou
17 | * 邮箱:fangjaylong@gmail.com
18 | * 创建时间:2016/4/20 14:48
19 | * 修改备注:
20 | * 版本:@version V1.0
21 | * ============================================================
22 | **/
23 | public class TypeImageListPersenterImpl implements TypeImageListModelImpl.OnGetTypeImageListener,TypeImageListPersenter {
24 | private TypeImageListView mTypeImageListView;
25 | private TypeImageListModel mTypeImageListModel;
26 |
27 | public TypeImageListPersenterImpl(TypeImageListView typeImageListView) {
28 | mTypeImageListView = typeImageListView;
29 | mTypeImageListModel=new TypeImageListModelImpl();
30 | }
31 |
32 | @Override
33 | public void onSuccess(List typeImageDomains) {
34 | mTypeImageListView.hideLoading();
35 | mTypeImageListView.receiveImageList(typeImageDomains);
36 | }
37 |
38 | @Override
39 | public void OnError(Exception e) {
40 | mTypeImageListView.hideLoading();
41 | }
42 |
43 |
44 |
45 | @Override
46 | public void startGetImageList(String url) {
47 | mTypeImageListModel.getTypeImageList(url,this);
48 | mTypeImageListView.showLaoding();
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/view/TypeImageListView.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.view;
2 |
3 | import com.flyou.girls.ui.typeImageList.domain.TypeImageDomain;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * ============================================================
9 | * 项目名称:Girls
10 | * 包名称:com.flyou.girls.ui.typeImageList.view
11 | * 文件名:TypeImageListView
12 | * 类描述:
13 | * 创建人:flyou
14 | * 邮箱:fangjaylong@gmail.com
15 | * 创建时间:2016/4/20 14:46
16 | * 修改备注:
17 | * 版本:@version V1.0
18 | * ============================================================
19 | **/
20 | public interface TypeImageListView {
21 | void showLaoding();
22 |
23 | void hideLoading();
24 |
25 | void showLoadFaild( Exception e);
26 |
27 | void receiveImageList(List typeImageDomains);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/flyou/girls/ui/typeImageList/widget/TypeImageActivity.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls.ui.typeImageList.widget;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ActivityCompat;
6 | import android.support.v4.app.ActivityOptionsCompat;
7 | import android.support.v4.widget.SwipeRefreshLayout;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.support.v7.widget.Toolbar;
12 | import android.view.View;
13 | import android.widget.Toast;
14 |
15 | import com.flyou.girls.R;
16 | import com.flyou.girls.adapter.SpacesItemDecoration;
17 | import com.flyou.girls.adapter.ViewHolder;
18 | import com.flyou.girls.adapter.recyclerview.CommonAdapter;
19 | import com.flyou.girls.ui.ImageViewPagerActivity;
20 | import com.flyou.girls.ui.typeImageList.domain.TypeImageDomain;
21 | import com.flyou.girls.ui.typeImageList.persenter.TypeImageListPersenter;
22 | import com.flyou.girls.ui.typeImageList.persenter.TypeImageListPersenterImpl;
23 | import com.flyou.girls.ui.typeImageList.view.TypeImageListView;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
29 |
30 | public class TypeImageActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener, TypeImageListView {
31 | private SwipeRefreshLayout mSwipeRefreshLayout;
32 | private RecyclerView mRecyclerView;
33 | private TypeImageListPersenter mPersenter;
34 | private LinearLayoutManager mLayoutManager;
35 | private CommonAdapter mAdapter;
36 | private String mLinkUrl;
37 | private String mTitle;
38 | private Toolbar mToolbar;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 |
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_type_image);
45 | initView();
46 | initDate();
47 | setListener();
48 |
49 | }
50 |
51 | private void initView() {
52 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
53 |
54 |
55 | mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.sw_layout);
56 | mRecyclerView = (RecyclerView) findViewById(R.id.receiverview);
57 | mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
58 | mSwipeRefreshLayout.setOnRefreshListener(this);
59 |
60 | }
61 |
62 | private void initDate() {
63 | mLinkUrl = getIntent().getStringExtra("linkUrl");
64 | if (mLinkUrl.isEmpty()) {
65 | Toast.makeText(this, "加载图片列表失败", Toast.LENGTH_SHORT).show();
66 | return;
67 | }
68 |
69 | mTitle = getIntent().getStringExtra("title");
70 | //设置ToolBar tit了 必须放在 getSupportActionBar().setDisplayHomeAsUpEnabled(true);之前 不然没有效果
71 | if (!mTitle.isEmpty()) {
72 |
73 | mToolbar.setTitle(mTitle);
74 | }
75 |
76 |
77 | setSupportActionBar(mToolbar);
78 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
79 |
80 | mPersenter = new TypeImageListPersenterImpl(this);
81 | mPersenter.startGetImageList(mLinkUrl);
82 | }
83 |
84 | private void setListener() {
85 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View v) {
88 | onBackPressed();
89 | }
90 | });
91 | }
92 |
93 | @Override
94 | public void onRefresh() {
95 |
96 | mPersenter.startGetImageList(mLinkUrl);
97 | }
98 |
99 | @Override
100 | public void showLaoding() {
101 | mSwipeRefreshLayout.measure(View.MEASURED_SIZE_MASK, View.MEASURED_HEIGHT_STATE_SHIFT);
102 | mSwipeRefreshLayout.setRefreshing(true);
103 | }
104 |
105 | @Override
106 | public void hideLoading() {
107 | mSwipeRefreshLayout.setRefreshing(false);
108 | }
109 |
110 | @Override
111 | public void showLoadFaild(Exception e) {
112 | Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
113 | }
114 |
115 | @Override
116 | public void receiveImageList(final List typeImageDomains) {
117 | if (mAdapter == null) {
118 | mAdapter = new CommonAdapter(TypeImageActivity.this, R.layout.view_item_type_image, typeImageDomains) {
119 | @Override
120 | public void convert(final ViewHolder holder, final TypeImageDomain typeImageDomain) {
121 | holder.setImageWithUrlAndSize(R.id.imageView, typeImageDomain.getUrl(), typeImageDomain.getWidth(), typeImageDomain.getHeight());
122 | holder.setOnClickListener(R.id.imageView, new View.OnClickListener() {
123 | @Override
124 | public void onClick(View v) {
125 | Intent intent = new Intent(TypeImageActivity.this, ImageViewPagerActivity.class);
126 | intent.putParcelableArrayListExtra("imagelist", (ArrayList) typeImageDomains);
127 | intent.putExtra("position", holder.getCurPosition());
128 | ActivityOptionsCompat options =
129 | ActivityOptionsCompat.makeSceneTransitionAnimation(TypeImageActivity.this);
130 | ActivityCompat.startActivity(TypeImageActivity.this, intent, options.toBundle());
131 | }
132 | });
133 | }
134 | };
135 | mLayoutManager = new LinearLayoutManager(TypeImageActivity.this);
136 | mRecyclerView.setLayoutManager(mLayoutManager);
137 | mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
138 | //设置item之间的间隔
139 | SpacesItemDecoration decoration = new SpacesItemDecoration(5);
140 | mRecyclerView.addItemDecoration(decoration);
141 | mRecyclerView.setAdapter(mAdapter);
142 |
143 | } else {
144 | mAdapter.notifyDataSetChanged();
145 |
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/ic_date.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/ic_home.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_mine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/ic_mine.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/ic_notifications.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/ic_photo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/pic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/pic_loading.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/pic_loading_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-hdpi/pic_loading_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-mdpi/ic_date.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-mdpi/ic_home.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_mine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-mdpi/ic_mine.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-mdpi/ic_notifications.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-mdpi/ic_photo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xhdpi/ic_date.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xhdpi/ic_home.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_mine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xhdpi/ic_mine.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xhdpi/ic_notifications.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xhdpi/ic_photo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_about.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_date.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_home.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_least.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_least.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_mine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_mine.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_mrxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_mrxt.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_notifications.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_personal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_personal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_photo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_sex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_sex.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_swyh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_swyh.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_wallper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_wallper.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_wmxz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/ic_wmxz.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_detial.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
17 |
25 |
26 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_view_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_type_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
26 |
27 |
28 |
29 |
35 |
36 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
20 |
21 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_item_fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
14 |
18 |
19 |
27 |
28 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_item_type_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_luc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/app/src/main/res/mipmap-xxxhdpi/ic_luc.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 16dp
7 | 16dp
8 | 5dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 5dp
4 | 160dp
5 |
6 |
7 | 0dp
8 | 16dp
9 | 16dp
10 | 0dp
11 | 0dp
12 | 0dp
13 |
14 |
--------------------------------------------------------------------------------
/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 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Girls
3 |
4 | Open navigation drawer
5 | Close navigation drawer
6 |
7 | Settings
8 | \n微博:凤飞雪未扬\n\nGithub:flyou\n\n博客:flyou
9 | 声明:本应用所有数据均来自互联网,且本app仅作学习用途。\n\n相关技术:RXJAVA、MVP、glide、jsoup
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/test/java/com/flyou/girls/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.flyou.girls;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.1.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven { url "https://jitpack.io" }
19 |
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyou/Girls/c71a38f83cb4d1f0db916859134455a5c3b92408/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------