乌云君 - 知乎专栏<\/a><\/p>联系邮箱: help@wooyun.org<\/p>","state":"published","sourceUrl":"","commentPermission":"anyone","canComment":true,"snapshotUrl":"","slug":20581814,"publishedTime":"2016-02-18T15:18:42+08:00","url":"/p/20581814","title":"汽车号牌已变成新的信息泄露入口?!","summary":"一提到车牌,就忍不住放这个梗。。。去年乌云君曝光了一些车主信息被非法交易买卖的事情,这些数据会从汽车销售商、总部客户系统中被泄露,然后用来做一些广告推销或违章诈骗等危害用户权益的行为,比如这样(apk文件为android手机木马程序)或这样车辆信息\u2026","column":{"slug":"wooyun","name":"乌云君"},"meta":{"previous":null,"next":null},"reviewingCommentsCount":0,"commentsCount":0,"likesCount":0}}
36 | * reviewingCommentsCount : 0
37 | * commentsCount : 26
38 | * likesCount : 245
39 | */
40 |
41 | private String titleImage;
42 | /**
43 | * comments : /api/posts/20460225/comments
44 | */
45 |
46 | private LinksBean links;
47 | private String content;
48 | private int slug;
49 | private String publishedTime;
50 | private String title;
51 | private String summary;
52 | private int commentsCount;
53 | private int likesCount;
54 | private List> reviewers;
55 | private List> topics;
56 |
57 | public String getTitleImage() {
58 | return titleImage;
59 | }
60 |
61 | public void setTitleImage(String titleImage) {
62 | this.titleImage = titleImage;
63 | }
64 |
65 | public LinksBean getLinks() {
66 | return links;
67 | }
68 |
69 | public void setLinks(LinksBean links) {
70 | this.links = links;
71 | }
72 |
73 | public String getContent() {
74 | return content;
75 | }
76 |
77 | public void setContent(String content) {
78 | this.content = content;
79 | }
80 |
81 | public int getSlug() {
82 | return slug;
83 | }
84 |
85 | public void setSlug(int slug) {
86 | this.slug = slug;
87 | }
88 |
89 | public String getPublishedTime() {
90 | return publishedTime;
91 | }
92 |
93 | public void setPublishedTime(String publishedTime) {
94 | this.publishedTime = publishedTime;
95 | }
96 |
97 | public String getTitle() {
98 | return title;
99 | }
100 |
101 | public void setTitle(String title) {
102 | this.title = title;
103 | }
104 |
105 | public String getSummary() {
106 | return summary;
107 | }
108 |
109 | public void setSummary(String summary) {
110 | this.summary = summary;
111 | }
112 |
113 | public int getCommentsCount() {
114 | return commentsCount;
115 | }
116 |
117 | public void setCommentsCount(int commentsCount) {
118 | this.commentsCount = commentsCount;
119 | }
120 |
121 | public int getLikesCount() {
122 | return likesCount;
123 | }
124 |
125 | public void setLikesCount(int likesCount) {
126 | this.likesCount = likesCount;
127 | }
128 |
129 | public List> getReviewers() {
130 | return reviewers;
131 | }
132 |
133 | public void setReviewers(List> reviewers) {
134 | this.reviewers = reviewers;
135 | }
136 |
137 | public List> getTopics() {
138 | return topics;
139 | }
140 |
141 | public void setTopics(List> topics) {
142 | this.topics = topics;
143 | }
144 |
145 | public static class LinksBean {
146 | private String comments;
147 |
148 | public String getComments() {
149 | return comments;
150 | }
151 |
152 | public void setComments(String comments) {
153 | this.comments = comments;
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/model/Girl.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by allen on 2016/6/17.
9 | */
10 | public class Girl {
11 | public boolean error;
12 | // @SerializedName 定义序列化之后的名称
13 | public @SerializedName("results")
14 | List girlResults;
15 |
16 | public static class GirlResult{
17 | public String desc;
18 | public String url;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/model/Item.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.model;
2 |
3 | /**
4 | * Created by allen on 2016/6/17.
5 | *
6 | * Cache Item for girl pic
7 | */
8 | public class Item {
9 | public String description;
10 | public String imageUrl;
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/model/ZhuanLan.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by allen on 2016/6/14.
7 | */
8 | public class ZhuanLan {
9 |
10 | private int followersCount;
11 | private String description;
12 | private CreatorBean creator;
13 | private String href;
14 | private boolean acceptSubmission;
15 | private String slug;
16 | private String name;
17 | private String url;
18 | private AvatarBean avatar;
19 | private String commentPermission;
20 | private boolean following;
21 | private int postsCount;
22 | private boolean canPost;
23 | private boolean activateAuthorRequested;
24 |
25 | private List topics;
26 |
27 | public int getFollowersCount() {
28 | return followersCount;
29 | }
30 |
31 | public void setFollowersCount(int followersCount) {
32 | this.followersCount = followersCount;
33 | }
34 |
35 | public String getDescription() {
36 | return description;
37 | }
38 |
39 | public void setDescription(String description) {
40 | this.description = description;
41 | }
42 |
43 | public CreatorBean getCreator() {
44 | return creator;
45 | }
46 |
47 | public void setCreator(CreatorBean creator) {
48 | this.creator = creator;
49 | }
50 |
51 | public String getHref() {
52 | return href;
53 | }
54 |
55 | public void setHref(String href) {
56 | this.href = href;
57 | }
58 |
59 | public boolean isAcceptSubmission() {
60 | return acceptSubmission;
61 | }
62 |
63 | public void setAcceptSubmission(boolean acceptSubmission) {
64 | this.acceptSubmission = acceptSubmission;
65 | }
66 |
67 | public String getSlug() {
68 | return slug;
69 | }
70 |
71 | public void setSlug(String slug) {
72 | this.slug = slug;
73 | }
74 |
75 | public String getName() {
76 | return name;
77 | }
78 |
79 | public void setName(String name) {
80 | this.name = name;
81 | }
82 |
83 | public String getUrl() {
84 | return url;
85 | }
86 |
87 | public void setUrl(String url) {
88 | this.url = url;
89 | }
90 |
91 | public AvatarBean getAvatar() {
92 | return avatar;
93 | }
94 |
95 | public void setAvatar(AvatarBean avatar) {
96 | this.avatar = avatar;
97 | }
98 |
99 | public String getCommentPermission() {
100 | return commentPermission;
101 | }
102 |
103 | public void setCommentPermission(String commentPermission) {
104 | this.commentPermission = commentPermission;
105 | }
106 |
107 | public boolean isFollowing() {
108 | return following;
109 | }
110 |
111 | public void setFollowing(boolean following) {
112 | this.following = following;
113 | }
114 |
115 | public int getPostsCount() {
116 | return postsCount;
117 | }
118 |
119 | public void setPostsCount(int postsCount) {
120 | this.postsCount = postsCount;
121 | }
122 |
123 | public boolean isCanPost() {
124 | return canPost;
125 | }
126 |
127 | public void setCanPost(boolean canPost) {
128 | this.canPost = canPost;
129 | }
130 |
131 | public boolean isActivateAuthorRequested() {
132 | return activateAuthorRequested;
133 | }
134 |
135 | public void setActivateAuthorRequested(boolean activateAuthorRequested) {
136 | this.activateAuthorRequested = activateAuthorRequested;
137 | }
138 |
139 | public List getTopics() {
140 | return topics;
141 | }
142 |
143 | public void setTopics(List topics) {
144 | this.topics = topics;
145 | }
146 |
147 | public static class CreatorBean {
148 | private String bio;
149 | private String hash;
150 | private String description;
151 | private String profileUrl;
152 | /**
153 | * id : 6c83b4b34
154 | * template : http://pic1.zhimg.com/{id}_{size}.jpg
155 | */
156 |
157 | private AvatarBean avatar;
158 | private String slug;
159 | private String name;
160 |
161 | public String getBio() {
162 | return bio;
163 | }
164 |
165 | public void setBio(String bio) {
166 | this.bio = bio;
167 | }
168 |
169 | public String getHash() {
170 | return hash;
171 | }
172 |
173 | public void setHash(String hash) {
174 | this.hash = hash;
175 | }
176 |
177 | public String getDescription() {
178 | return description;
179 | }
180 |
181 | public void setDescription(String description) {
182 | this.description = description;
183 | }
184 |
185 | public String getProfileUrl() {
186 | return profileUrl;
187 | }
188 |
189 | public void setProfileUrl(String profileUrl) {
190 | this.profileUrl = profileUrl;
191 | }
192 |
193 | public AvatarBean getAvatar() {
194 | return avatar;
195 | }
196 |
197 | public void setAvatar(AvatarBean avatar) {
198 | this.avatar = avatar;
199 | }
200 |
201 | public String getSlug() {
202 | return slug;
203 | }
204 |
205 | public void setSlug(String slug) {
206 | this.slug = slug;
207 | }
208 |
209 | public String getName() {
210 | return name;
211 | }
212 |
213 | public void setName(String name) {
214 | this.name = name;
215 | }
216 |
217 | public static class AvatarBean {
218 | private String id;
219 | private String template;
220 |
221 | public String getId() {
222 | return id;
223 | }
224 |
225 | public void setId(String id) {
226 | this.id = id;
227 | }
228 |
229 | public String getTemplate() {
230 | return template;
231 | }
232 |
233 | public void setTemplate(String template) {
234 | this.template = template;
235 | }
236 | }
237 | }
238 |
239 | public static class AvatarBean {
240 | private String id;
241 | private String template;
242 |
243 | public String getId() {
244 | return id;
245 | }
246 |
247 | public void setId(String id) {
248 | this.id = id;
249 | }
250 |
251 | public String getTemplate() {
252 | return template;
253 | }
254 |
255 | public void setTemplate(String template) {
256 | this.template = template;
257 | }
258 | }
259 |
260 | public static class TopicsBean {
261 | private String url;
262 | private String id;
263 | private String name;
264 |
265 | public String getUrl() {
266 | return url;
267 | }
268 |
269 | public void setUrl(String url) {
270 | this.url = url;
271 | }
272 |
273 | public String getId() {
274 | return id;
275 | }
276 |
277 | public void setId(String id) {
278 | this.id = id;
279 | }
280 |
281 | public String getName() {
282 | return name;
283 | }
284 |
285 | public void setName(String name) {
286 | this.name = name;
287 | }
288 | }
289 | }
290 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/net/Network.java:
--------------------------------------------------------------------------------
1 | // (c)2016 Flipboard Inc, All Rights Reserved.
2 |
3 | package com.wu.allen.zhuanlan.net;
4 |
5 |
6 | import com.wu.allen.zhuanlan.net.api.ArticleDetailApi;
7 | import com.wu.allen.zhuanlan.net.api.GankApi;
8 | import com.wu.allen.zhuanlan.net.api.ZhLanArticleApi;
9 | import com.wu.allen.zhuanlan.net.api.ZhuanLanApi;
10 |
11 | import java.util.concurrent.TimeUnit;
12 |
13 | import okhttp3.OkHttpClient;
14 | import okhttp3.logging.HttpLoggingInterceptor;
15 | import retrofit2.CallAdapter;
16 | import retrofit2.Converter;
17 | import retrofit2.Retrofit;
18 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
19 | import retrofit2.converter.gson.GsonConverterFactory;
20 |
21 | public class Network {
22 | private static GankApi gankApi;
23 | private static ZhuanLanApi zhuanLanApi;
24 | private static ZhLanArticleApi zhLanArticleApi;
25 | private static ArticleDetailApi articleDetailApi;
26 | private static final String GANHUO_API = "http://gank.io/api/";
27 | private static final String ZhuanLanList_API = "https://zhuanlan.zhihu.com/api/columns/";
28 | private static final String ArticleList_API = "https://zhuanlan.zhihu.com/api/columns/";
29 | private static final String ARTICLEDETAIL_API = "https://zhuanlan.zhihu.com/api/posts/";
30 | private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
31 | private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJavaCallAdapterFactory.create();
32 | private static OkHttpClient client;
33 |
34 | public static OkHttpClient initOkHttp(){
35 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
36 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
37 | client = new OkHttpClient.Builder()
38 | .addInterceptor(interceptor)
39 | .retryOnConnectionFailure(true)
40 | .connectTimeout(15, TimeUnit.SECONDS)
41 | .build();
42 | return client;
43 | }
44 | // Gank meizi api
45 | public static GankApi getGankApi() {
46 | if (gankApi == null) {
47 | Retrofit retrofit = new Retrofit.Builder()
48 | .client(initOkHttp())
49 | .baseUrl(GANHUO_API)
50 | .addConverterFactory(gsonConverterFactory)
51 | .addCallAdapterFactory(rxJavaCallAdapterFactory)
52 | .build();
53 | gankApi = retrofit.create(GankApi.class);
54 | }
55 | return gankApi;
56 | }
57 | // Zhihu zhuanlan api
58 | public static ZhuanLanApi getZhuanLanApi() {
59 | if (zhuanLanApi == null) {
60 | Retrofit retrofit = new Retrofit.Builder()
61 | .client(initOkHttp())
62 | .baseUrl(ZhuanLanList_API)
63 | .addConverterFactory(gsonConverterFactory)
64 | .addCallAdapterFactory(rxJavaCallAdapterFactory)
65 | .build();
66 | zhuanLanApi = retrofit.create(ZhuanLanApi.class);
67 | }
68 | return zhuanLanApi;
69 | }
70 | // Zhihu zhuanlanarticle api
71 | public static ZhLanArticleApi getZhLanArticleApi() {
72 | if (zhLanArticleApi == null) {
73 | Retrofit retrofit = new Retrofit.Builder()
74 | .client(initOkHttp())
75 | .baseUrl(ArticleList_API)
76 | .addConverterFactory(gsonConverterFactory)
77 | .addCallAdapterFactory(rxJavaCallAdapterFactory)
78 | .build();
79 | zhLanArticleApi= retrofit.create(ZhLanArticleApi.class);
80 | }
81 | return zhLanArticleApi;
82 | }
83 | // Zhihu articleDetail api
84 | public static ArticleDetailApi getArticleDetailApi() {
85 | if (articleDetailApi == null) {
86 | Retrofit retrofit = new Retrofit.Builder()
87 | .client(initOkHttp())
88 | .baseUrl(ARTICLEDETAIL_API)
89 | .addConverterFactory(gsonConverterFactory)
90 | .addCallAdapterFactory(rxJavaCallAdapterFactory)
91 | .build();
92 | articleDetailApi = retrofit.create(ArticleDetailApi.class);
93 | }
94 | return articleDetailApi;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/net/api/ArticleDetailApi.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.net.api;
2 |
3 | import com.wu.allen.zhuanlan.model.ArticleDetail;
4 | import retrofit2.http.GET;
5 | import retrofit2.http.Path;
6 | import rx.Observable;
7 |
8 | /**
9 | * Created by allen on 2016/6/19.
10 | */
11 | public interface ArticleDetailApi {
12 | @GET("{articleSlug}")
13 | Observable getArticleDetail(
14 | @Path("articleSlug") int articleSlug
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/net/api/GankApi.java:
--------------------------------------------------------------------------------
1 | // (c)2016 Flipboard Inc, All Rights Reserved.
2 |
3 | package com.wu.allen.zhuanlan.net.api;
4 |
5 |
6 | import com.wu.allen.zhuanlan.model.Girl;
7 |
8 | import retrofit2.http.GET;
9 | import retrofit2.http.Path;
10 | import rx.Observable;
11 |
12 | public interface GankApi {
13 | @GET("data/福利/{number}/{page}")
14 | Observable getBeauties(@Path("number") int number, @Path("page") int page);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/net/api/ZhLanArticleApi.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.net.api;
2 |
3 | import com.wu.allen.zhuanlan.model.Article;
4 |
5 | import java.util.List;
6 |
7 | import retrofit2.http.GET;
8 | import retrofit2.http.Path;
9 | import retrofit2.http.Query;
10 | import rx.Observable;
11 |
12 | /**
13 | * Created by allen on 2016/6/18.
14 | */
15 | public interface ZhLanArticleApi {
16 | @GET("{slug}/posts")
17 | Observable> getArticle(
18 | @Path("slug") String slug,
19 | @Query("limit") int limit,
20 | @Query("offest") int offest
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/net/api/ZhuanLanApi.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.net.api;
2 |
3 | import com.wu.allen.zhuanlan.model.ZhuanLan;
4 |
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Path;
7 | import rx.Observable;
8 |
9 | /**
10 | * Created by allen on 2016/6/18.
11 | */
12 | public interface ZhuanLanApi {
13 | @GET("{zhuanlanname}")
14 | Observable getZhuanLan(
15 | @Path("zhuanlanname") String zhuanlanname
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/Dp2PxUtil.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.DisplayMetrics;
6 |
7 | /**
8 | * Created by allen on 2016/6/14.
9 | */
10 | public class Dp2PxUtil {
11 | /**
12 | * This method converts dp unit to equivalent pixels, depending on device density.
13 | *
14 | * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels
15 | * @param context Context to get resources and device specific display metrics
16 | * @return A float value to represent px equivalent to dp depending on device density
17 | */
18 | public static float convertDpToPixel(float dp, Context context){
19 | Resources resources = context.getResources();
20 | DisplayMetrics metrics = resources.getDisplayMetrics();
21 | float px = dp * (metrics.densityDpi / 160f);
22 | return px;
23 | }
24 |
25 | /**
26 | * This method converts device specific pixels to density independent pixels.
27 | *
28 | * @param px A value in px (pixels) unit. Which we need to convert into db
29 | * @param context Context to get resources and device specific display metrics
30 | * @return A float value to represent dp equivalent to px value
31 | */
32 | public static float convertPixelsToDp(float px, Context context){
33 | Resources resources = context.getResources();
34 | DisplayMetrics metrics = resources.getDisplayMetrics();
35 | float dp = px / (metrics.densityDpi / 160f);
36 | return dp;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/ImgSaveUtil.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.graphics.Bitmap;
6 | import android.net.Uri;
7 | import android.os.Environment;
8 | import android.support.design.widget.Snackbar;
9 | import android.util.Log;
10 | import android.widget.ImageView;
11 |
12 | import java.io.File;
13 | import java.io.FileNotFoundException;
14 | import java.io.FileOutputStream;
15 | import java.io.IOException;
16 |
17 | /**
18 | * Created by allen on 2016/6/19.
19 | *
20 | * Here reference is https://github.com/gaolonglong/GankGirl/blob/master/app/src/main/java/com/app/gaolonglong/gankgirl/util/ImageUtil.java
21 | */
22 | public class ImgSaveUtil {
23 |
24 | public static Uri saveImage(Context context, String url, Bitmap bitmap, ImageView imageView, String tag){
25 | //妹纸保存路径
26 | String imgDir = Environment.getExternalStorageDirectory().getPath() + "/GankGirl";
27 | //图片名称处理
28 | String[] fileNameArr = url.substring(url.lastIndexOf("/") + 1).split("\\.");
29 | String fileName = fileNameArr[0] + ".png";
30 | //创建文件路径
31 | File fileDir = new File(imgDir);
32 | if (!fileDir.exists()){
33 | fileDir.mkdir();
34 | }
35 | //创建文件
36 | File imageFile = new File(fileDir,fileName);
37 | try {
38 | FileOutputStream fos = new FileOutputStream(imageFile);
39 | boolean compress = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
40 | Snackbar.make(imageView,"妹纸已经躺在你的图库里啦.. ( >ω<)",Snackbar.LENGTH_SHORT).show();
41 |
42 | fos.flush();
43 | fos.close();
44 | } catch (FileNotFoundException e) {
45 | e.printStackTrace();
46 | } catch (IOException e) {
47 | e.printStackTrace();
48 | }
49 |
50 | Uri uri = Uri.fromFile(imageFile);
51 | //发送广播,通知图库更新
52 | context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,uri));
53 | return uri;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/ImgShareUtil.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 |
7 | /**
8 | * Created by allen on 2016/6/21.
9 | */
10 | public class ImgShareUtil {
11 |
12 | public static void shareImage(Context context, Uri uri){
13 | Intent intent = new Intent(Intent.ACTION_SEND);
14 | intent.setType("image/jpeg");//图片
15 | intent.putExtra(Intent.EXTRA_STREAM, uri);
16 | context.startActivity(Intent.createChooser(intent,"分享妹纸"));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/NetWorkUtil.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * Created by allen on 2016/6/19.
9 | */
10 | public class NetWorkUtil {
11 | // NetWork is ok?
12 | public static boolean isNetworkConnected(Context context) {
13 | if (context != null) {
14 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context
15 | .getSystemService(Context.CONNECTIVITY_SERVICE);
16 | NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
17 | if (mNetworkInfo != null) {
18 | return mNetworkInfo.isAvailable();
19 | }
20 | }
21 | return false;
22 | }
23 | // WIFI is ok?
24 | public static boolean isWifiConnected(Context context) {
25 | if (context != null) {
26 | ConnectivityManager mConnectivityManager = (ConnectivityManager) context
27 | .getSystemService(Context.CONNECTIVITY_SERVICE);
28 | NetworkInfo mWiFiNetworkInfo = mConnectivityManager
29 | .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
30 | if (mWiFiNetworkInfo != null) {
31 | return mWiFiNetworkInfo.isAvailable();
32 | }
33 | }
34 | return false;
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by allen on 2016/6/14.
8 | */
9 |
10 |
11 | public class ToastUtil {
12 |
13 | // shortTime
14 | public static void showShort(Context context, String info) {
15 | Toast.makeText(context, info, Toast.LENGTH_SHORT).show();
16 | }
17 |
18 | // LongTime
19 | public static void showLong(Context context, String info) {
20 | Toast.makeText(context, info, Toast.LENGTH_LONG).show();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/util/TopicData.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.util;
2 |
3 | /**
4 | * Created by allen on 2016/6/18.
5 | */
6 | // Beacause of ZHihu API,some constant write here
7 | public class TopicData {
8 |
9 | public static String default_ids[] = {"beasleynation","Battlestar","bigertech","48zhen",
10 | "nordenbox","android-weekly","kaede","klexraxmusic","grapeot","dingj"};
11 |
12 | public static String psychology_ids[] = {"gooseeker","happy","psychology","jiandanxinli",
13 | "lengai","career","aiqing","knowyourself"};
14 |
15 | public static String life_talks_ids[] = {"zhangjiawei","hibetterme","maboyong","vczh-nichijou",
16 | "xiepanda","niceliving","uglypeoplefuckbooks","doubtsinreading","Wisdom","oh-hard"};
17 |
18 | public static String photography_ids[] = {"kotandroid","Photography","he110world","ciciatc",
19 | "japan-talk","limiao","hikarifromtokyo","ethanlam","1chivnjapan"};
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.design.widget.CollapsingToolbarLayout;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 |
11 | import com.wu.allen.zhuanlan.R;
12 |
13 | public class AboutActivity extends BaseActivity {
14 | @Override
15 | protected void onCreate(@Nullable Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_about);
18 |
19 | //Toolbar
20 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
21 | setSupportActionBar(toolbar);
22 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
23 |
24 | //CollapsingToolbarLayout
25 | CollapsingToolbarLayout collapsingToolbar =
26 | (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
27 | //collapsingToolbar.setTitle("关于");
28 |
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/ArticleDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.design.widget.CollapsingToolbarLayout;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.util.Log;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.webkit.WebSettings;
15 | import android.webkit.WebView;
16 | import android.webkit.WebViewClient;
17 | import android.widget.ImageView;
18 |
19 | import com.afollestad.materialdialogs.MaterialDialog;
20 | import com.bumptech.glide.Glide;
21 | import com.wu.allen.zhuanlan.R;
22 | import com.wu.allen.zhuanlan.model.ArticleDetail;
23 | import com.wu.allen.zhuanlan.model.ZhuanLan;
24 | import com.wu.allen.zhuanlan.net.Network;
25 | import com.wu.allen.zhuanlan.util.ToastUtil;
26 |
27 | import rx.Subscriber;
28 | import rx.android.schedulers.AndroidSchedulers;
29 | import rx.schedulers.Schedulers;
30 |
31 | /**
32 | * Created by allen on 2016/6/18.
33 | */
34 | public class ArticleDetailActivity extends BaseActivity {
35 | private static final String TAG = "ArticleDetailActivity";
36 | private String titleImage,articleTitle;
37 | private int articleSlug;
38 | private ImageView imageView;
39 | private WebView webView;
40 | @Override
41 | protected void onCreate(@Nullable Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_articledetail);
44 | getData();
45 | initView();
46 | loadView();
47 | }
48 | // InitView
49 | public void initView(){
50 | webView = (WebView) findViewById(R.id.wb_main);
51 | imageView = (ImageView) findViewById(R.id.iv_article);
52 | Glide.with(ArticleDetailActivity.this)
53 | .load(titleImage)
54 | .centerCrop()
55 | .into(imageView);
56 | //Toolbar
57 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
58 | setSupportActionBar(toolbar);
59 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
60 |
61 | CollapsingToolbarLayout mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
62 | mCollapsingToolbarLayout.setTitle(articleTitle);
63 | mCollapsingToolbarLayout.setExpandedTitleColor(Color.WHITE);//设置还没收缩时状态下字体颜色
64 | mCollapsingToolbarLayout.setCollapsedTitleTextColor(Color.GREEN);//设置收缩后Toolbar上字体的颜色
65 | }
66 | // Get data from ZhanlanDetailActivity
67 | public void getData() {
68 | Intent intent = getIntent();
69 | articleSlug = Integer.parseInt(intent.getStringExtra("slug"));
70 | articleTitle = intent.getStringExtra("title");
71 | titleImage = intent.getStringExtra("image");
72 |
73 | getArticleDetailData(articleSlug);
74 | }
75 | // reference is https://github.com/marktony/zhuanlan/blob/master/app/src/main/java/com/marktony/zhuanlan/ui/ReadActivity.java
76 | private void loadView() {
77 | webView.getSettings().setJavaScriptEnabled(true);
78 | webView.getSettings().setBuiltInZoomControls(false);
79 | webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
80 | webView.getSettings().setDomStorageEnabled(true);
81 | webView.getSettings().setAppCacheEnabled(false);
82 | webView.setWebViewClient(new WebViewClient() {
83 | @Override
84 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
85 | webView.loadUrl(url);
86 | return true;
87 | }
88 |
89 | @Override
90 | public void onPageFinished(WebView view, String url) {
91 | super.onPageFinished(view, url);
92 | }
93 | });
94 | }
95 | // Get Article Detail
96 | private void getArticleDetailData(int articleSlug) {
97 | Network.getArticleDetailApi()
98 | .getArticleDetail(articleSlug)
99 | .subscribeOn(Schedulers.io())
100 | .observeOn(AndroidSchedulers.mainThread())
101 | .subscribe(new Subscriber() {
102 | @Override
103 | public void onCompleted() {
104 | }
105 |
106 | @Override
107 | public void onError(Throwable e) {
108 | Log.e(TAG,e.getMessage());
109 |
110 | }
111 | @Override
112 | public void onNext(ArticleDetail articleDetail) {
113 | Log.e(TAG,articleDetail.getTitle());
114 | processData(articleDetail);
115 | }
116 | });
117 | }
118 | // Return data of Content is HTML ,Process here and show with webView
119 | private void processData(ArticleDetail articleDetail) {
120 | String content = articleDetail.getContent();
121 | String css = "";
122 | String html = "\n"
123 | + "\n"
124 | + "\n"
125 | + "\t\n\n"
126 | + css
127 | + "\n"
128 | + content
129 | + "\n";
130 | webView.loadData(html,"text/html; charset=UTF-8", null);
131 | }
132 |
133 | @Override
134 | public boolean onCreateOptionsMenu(Menu menu) {
135 | // Inflate the menu; this adds items to the action bar if it is present.
136 | getMenuInflater().inflate(R.menu.articledetail_menu_, menu);
137 | return true;
138 | }
139 |
140 | @Override
141 | public boolean onOptionsItemSelected(MenuItem item) {
142 | // Handle action bar item clicks here. The action bar will
143 | // automatically handle clicks on the Home/Up button, so long
144 | // as you specify a parent activity in AndroidManifest.xml.
145 | int id = item.getItemId();
146 |
147 | //noinspection SimplifiableIfStatement
148 | if (id == R.id.action_post) {
149 | ToastUtil.showLong(this,"Post");
150 | }else if (id == R.id.action_share){
151 | //Intent intent = new Intent(getApplicationContext(),AboutActivity.class);
152 | //startActivity(intent);
153 | ToastUtil.showLong(this,"Share");
154 | }else if (id == android.R.id.home){
155 | onBackPressed();
156 | }
157 |
158 | return super.onOptionsItemSelected(item);
159 | }
160 |
161 |
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.os.PersistableBundle;
7 | import android.support.v4.content.ContextCompat;
8 | import android.support.v4.widget.SwipeRefreshLayout;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 |
16 | import com.afollestad.materialdialogs.MaterialDialog;
17 | import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
18 | import com.wu.allen.zhuanlan.R;
19 | import com.wu.allen.zhuanlan.util.ToastUtil;
20 |
21 | /**
22 | * Created by allen on 2016/6/14.
23 | */
24 | public class BaseActivity extends AppCompatActivity implements SwipeRefreshLayout
25 | .OnRefreshListener,RecyclerArrayAdapter.OnLoadMoreListener{
26 |
27 | @Override
28 | public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
29 | super.onCreate(savedInstanceState, persistentState);
30 | //initView();
31 | }
32 |
33 |
34 | @Override
35 | public boolean onCreateOptionsMenu(Menu menu) {
36 | // Inflate the menu; this adds items to the action bar if it is present.
37 | getMenuInflater().inflate(R.menu.menu_main, menu);
38 | return true;
39 | }
40 |
41 | @Override
42 | public boolean onOptionsItemSelected(MenuItem item) {
43 | // Handle action bar item clicks here. The action bar will
44 | // automatically handle clicks on the Home/Up button, so long
45 | // as you specify a parent activity in AndroidManifest.xml.
46 | int id = item.getItemId();
47 |
48 | //noinspection SimplifiableIfStatement
49 | if (id == R.id.action_settings) {
50 | new MaterialDialog.Builder(this)
51 | .title(R.string.dialog_title)
52 | .items(R.array.todo_item)
53 | .itemsCallback(new MaterialDialog.ListCallback() {
54 | @Override
55 | public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
56 | }
57 | })
58 | .show();
59 | }else if (id == R.id.action_about){
60 | Intent intent = new Intent(getApplicationContext(),AboutActivity.class);
61 | startActivity(intent);
62 | }else if (id == android.R.id.home){
63 | onBackPressed();
64 | }
65 |
66 | return super.onOptionsItemSelected(item);
67 | }
68 |
69 |
70 | @Override
71 | public void onRefresh() {
72 |
73 | }
74 |
75 | @Override
76 | public void onLoadMore() {
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/GirlActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v7.widget.Toolbar;
9 | import android.transition.Explode;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.Window;
13 | import android.widget.ImageView;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
17 | import com.bumptech.glide.request.animation.GlideAnimation;
18 | import com.bumptech.glide.request.target.SimpleTarget;
19 | import com.wu.allen.zhuanlan.R;
20 | import com.wu.allen.zhuanlan.model.Girl;
21 | import com.wu.allen.zhuanlan.util.ImgSaveUtil;
22 | import com.wu.allen.zhuanlan.util.ImgShareUtil;
23 | import com.wu.allen.zhuanlan.util.ToastUtil;
24 |
25 | import uk.co.senab.photoview.PhotoViewAttacher;
26 |
27 | /**
28 | * Created by allen on 2016/6/14.
29 | */
30 | public class GirlActivity extends BaseActivity {
31 |
32 | private static final String TAG = "GirlActivity";
33 | private Toolbar toolbar;
34 | private ImageView image;
35 | private String desc;
36 | private String url;
37 | private PhotoViewAttacher attacher;
38 | private Bitmap bitmap;
39 |
40 | @Override
41 | protected void onCreate(@Nullable Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | beforeInitView();
44 | setContentView(R.layout.girldetail_layout);
45 | getData();
46 | initView();
47 | }
48 | // Animated transitions
49 | public void beforeInitView(){
50 | getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
51 | getWindow().setEnterTransition(new Explode());
52 | getWindow().setExitTransition(new Explode());
53 | }
54 | // Get data from MainFragment
55 | public void getData() {
56 | Intent intent = getIntent();
57 | desc = intent.getStringExtra("desc");
58 | url = intent.getStringExtra("url");
59 | }
60 | // initView
61 | public void initView() {
62 | toolbar = (Toolbar) findViewById(R.id.toolbar);
63 | setSupportActionBar(toolbar);
64 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
65 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_white_24dp);
66 | getSupportActionBar().setTitle(desc);
67 | image = (ImageView) findViewById(R.id.image_meizhi);
68 | attacher = new PhotoViewAttacher(image);
69 | // Glide
70 | Glide.with(this)
71 | .load(url)
72 | .asBitmap()
73 | .diskCacheStrategy(DiskCacheStrategy.SOURCE)
74 | .into(new SimpleTarget() {// 这样写有什么好处?
75 | @Override
76 | public void onResourceReady(Bitmap resource, GlideAnimation super Bitmap> glideAnimation) {
77 | image.setImageBitmap(resource);
78 | attacher.update();
79 | bitmap = resource;
80 | }
81 | });
82 |
83 | }
84 |
85 | @Override
86 | public boolean onCreateOptionsMenu(Menu menu) {
87 | // Inflate the menu; this adds items to the action bar if it is present.
88 | getMenuInflater().inflate(R.menu.girl_menu, menu);
89 | return true;
90 | }
91 |
92 | @Override
93 | public boolean onOptionsItemSelected(MenuItem item) {
94 | int id = item.getItemId();
95 |
96 | //noinspection SimplifiableIfStatement
97 | if (id == R.id.action_save) {
98 | //ImgSaveUtil.saveImage(GirlActivity.this,url,bitmap,image,"saveImg");
99 | //Snackbar.make(GirlActivity.this,"bug here in android 6.0",Snackbar.LENGTH_SHORT).show();
100 | ToastUtil.showLong(this,"bug here in android 6.0");
101 | }else if (id == R.id.action_share){
102 | ImgShareUtil.shareImage(this,ImgSaveUtil.saveImage(this,url,bitmap,image,"share"));
103 | }else if (id == android.R.id.home){
104 | onBackPressed();
105 | }
106 |
107 | return super.onOptionsItemSelected(item);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 |
4 | import android.app.Fragment;
5 | import android.os.Bundle;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v13.app.FragmentPagerAdapter;
8 | import android.support.v4.view.ViewPager;
9 | import android.support.v7.widget.Toolbar;
10 |
11 | import com.nispok.snackbar.Snackbar;
12 | import com.nispok.snackbar.SnackbarManager;
13 | import com.nispok.snackbar.listeners.ActionClickListener;
14 | import com.wu.allen.zhuanlan.R;
15 | import com.wu.allen.zhuanlan.util.NetWorkUtil;
16 | import com.wu.allen.zhuanlan.view.fragment.GirlFragment;
17 | import com.wu.allen.zhuanlan.view.fragment.ZhihuFragment;
18 |
19 | import java.util.List;
20 |
21 | public class MainActivity extends BaseActivity {
22 | private static final String TAG = "MainActivity";
23 | private TabLayout tabLayout;
24 | private ViewPager viewPager;
25 | private List fragments;
26 | private String[] titles = {"专栏","妹纸"};
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_main);
32 | initView();
33 | switchToFragmnent();
34 | isNetOk();
35 | }
36 | // Judge network is ok
37 | public void isNetOk(){
38 | if(!NetWorkUtil.isNetworkConnected(getApplicationContext())){
39 | SnackbarManager.show(
40 | Snackbar.with(getApplicationContext()) // context
41 | .text("没有网络==") // text to display
42 | .actionLabel("重试?") // action button label
43 | .actionListener(new ActionClickListener() {
44 | @Override
45 | public void onActionClicked(Snackbar snackbar) {
46 | isNetOk();
47 | }
48 | }) // action button's ActionClickListener
49 | , this);
50 | }
51 | }
52 | // initView
53 | public void initView(){
54 | //Toolbar
55 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
56 | tabLayout = (TabLayout) findViewById(R.id.tab_layout);
57 | setSupportActionBar(toolbar);
58 | }
59 | // switch fragment
60 | public void switchToFragmnent() {
61 |
62 | viewPager = (ViewPager) findViewById(R.id.view_pager);
63 | viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {
64 | @Override
65 | public Fragment getItem(int position) {
66 | switch (position) {
67 | case 0:
68 | return new ZhihuFragment();
69 | case 1:
70 | return new GirlFragment();
71 | default:
72 | return new ZhihuFragment();
73 | }
74 | }
75 |
76 | @Override
77 | public int getCount() {
78 | return 2;
79 | }
80 |
81 | @Override
82 | public CharSequence getPageTitle(int position) {
83 | switch (position) {
84 | case 0:
85 | return getString(R.string.zhihu);
86 | case 1:
87 | return getString(R.string.girl);
88 | default:
89 | return getString(R.string.zhihu);
90 | }
91 | }
92 | });
93 |
94 | tabLayout.setupWithViewPager(viewPager);
95 | }
96 |
97 | @Override
98 | protected void onDestroy() {
99 | super.onDestroy();
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/activity/ZhlanDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.activity;
2 |
3 | import android.app.ActivityOptions;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.support.annotation.Nullable;
8 | import android.support.design.widget.CollapsingToolbarLayout;
9 | import android.support.v4.widget.SwipeRefreshLayout;
10 | import android.support.v7.widget.LinearLayoutManager;
11 | import android.support.v7.widget.Toolbar;
12 | import android.transition.Explode;
13 | import android.transition.Fade;
14 | import android.util.Log;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.view.Window;
18 |
19 | import com.afollestad.materialdialogs.MaterialDialog;
20 | import com.jude.easyrecyclerview.EasyRecyclerView;
21 | import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
22 | import com.wu.allen.zhuanlan.R;
23 | import com.wu.allen.zhuanlan.adapter.ArticleAdapter;
24 | import com.wu.allen.zhuanlan.model.Article;
25 | import com.wu.allen.zhuanlan.net.Network;
26 | import com.wu.allen.zhuanlan.util.ToastUtil;
27 |
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | import rx.Subscriber;
32 | import rx.android.schedulers.AndroidSchedulers;
33 | import rx.schedulers.Schedulers;
34 |
35 | /**
36 | * Created by allen on 2016/6/14.
37 | */
38 | public class ZhlanDetailActivity extends BaseActivity {
39 |
40 | private static final String TAG = "ZhlanDetailActivity";
41 | private Toolbar toolbar;
42 | private String slug,title,name,articeSlug,titleImage,profileUrl;
43 | private EasyRecyclerView recyclerView;
44 | private List articleList;
45 | private ArticleAdapter articleAdapter;
46 | private Handler handler = new Handler();
47 | private int page = 1;
48 | private CollapsingToolbarLayout toolbarLayout;
49 |
50 | @Override
51 | protected void onCreate(@Nullable Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 | beforeInitView();
54 | setContentView(R.layout.zhuanlan_layout);
55 | getData();
56 | initView();
57 | }
58 | // Animated transitions
59 | public void beforeInitView(){
60 | getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
61 | getWindow().setEnterTransition(new Explode());
62 | getWindow().setExitTransition(new Explode());
63 | }
64 | // Get data from MainFragment
65 | public void getData() {
66 | Intent intent = getIntent();
67 | slug = intent.getStringExtra("slug");
68 | title = intent.getStringExtra("title");
69 | profileUrl = intent.getStringExtra("profile_url");
70 | }
71 | // initView
72 | public void initView() {
73 | articleList = new ArrayList<>();
74 | recyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view);
75 | toolbar = (Toolbar) findViewById(R.id.toolbar);
76 | setSupportActionBar(toolbar);
77 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
78 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_white_24dp);
79 | getSupportActionBar().setTitle(slug);
80 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
81 | recyclerView.setLayoutManager(linearLayoutManager);
82 | articleAdapter = new ArticleAdapter(getApplicationContext());
83 | doWithArticle(articleAdapter);
84 | recyclerView.setRefreshListener(ZhlanDetailActivity.this);
85 | onRefresh();
86 | }
87 | // here can intent to ArticleDetailActivity
88 | private void doWithArticle(final RecyclerArrayAdapter adapter) {
89 | recyclerView.setAdapterWithProgress(adapter);
90 | adapter.setMore(R.layout.load_more_layout,this);
91 | adapter.setNoMore(R.layout.no_more_layout);
92 | adapter.setError(R.layout.error_layout);
93 | adapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {
94 | @Override
95 | public void onItemClick(int position) {
96 | Intent intent = new Intent(ZhlanDetailActivity.this,ArticleDetailActivity.class);
97 | intent.putExtra("slug",adapter.getItem(position).getArticleSlug());
98 | intent.putExtra("image",adapter.getItem(position).getTitleImage());
99 | intent.putExtra("title",adapter.getItem(position).getTitle());
100 | startActivity(intent);
101 | }
102 | });
103 | }
104 | // Get Article List with the zhuanlan
105 | private void getArticleData(String slug,int limit,int offest) {
106 | Network.getZhLanArticleApi()
107 | .getArticle(slug,limit,offest)
108 | .subscribeOn(Schedulers.io())
109 | .observeOn(AndroidSchedulers.mainThread())
110 | .subscribe(new Subscriber>() {
111 | @Override
112 | public void onCompleted() {
113 | }
114 |
115 | @Override
116 | public void onError(Throwable e) {
117 | Log.e(TAG,e.getMessage());
118 | }
119 | @Override
120 | public void onNext(List article) {
121 | ProcessData(article);
122 | articleAdapter.addAll(articleList);
123 | }
124 | });
125 | }
126 | // process data so that can be posted to ArticleAdapter
127 | private List ProcessData(List article) {
128 | for (int i = 0; i < article.size(); i++) {
129 | String title = article.get(i).getTitle();
130 | String content = article.get(i).getContent();
131 | titleImage = article.get(i).getTitleImage();
132 | // no data why?
133 | String sumary = article.get(i).getSummary();
134 | int commentsCount = article.get(i).getCommentsCount();
135 | // no use
136 | int likesCount =article.get(i).getLikeCount();
137 | articeSlug = article.get(i).getSlug();
138 | Article articleItem = new Article(title,titleImage,content
139 | ,sumary,commentsCount,likesCount,slug,articeSlug,profileUrl);
140 | articleList.add(articleItem);
141 | }
142 | return articleList;
143 | }
144 |
145 | @Override
146 | public void onLoadMore() {
147 | handler.postDelayed(new Runnable() {
148 | @Override
149 | public void run() {
150 | // bug here
151 | getArticleData(slug,page*5,0);
152 | page++;
153 | }
154 | }, 1000);
155 | }
156 |
157 | @Override
158 | public void onRefresh() {
159 | articleAdapter.clear();
160 | getArticleData(slug,5,0);
161 | }
162 |
163 | // override
164 |
165 | @Override
166 | public boolean onOptionsItemSelected(MenuItem item) {
167 | // Handle action bar item clicks here. The action bar will
168 | // automatically handle clicks on the Home/Up button, so long
169 | // as you specify a parent activity in AndroidManifest.xml.
170 | int id = item.getItemId();
171 |
172 | //noinspection SimplifiableIfStatement
173 | if (id == R.id.action_share) {
174 | ToastUtil.showLong(getApplicationContext(),"wait me");
175 | }else if (id == android.R.id.home){
176 | onBackPressed();
177 | }
178 |
179 | return super.onOptionsItemSelected(item);
180 | }
181 |
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.fragment;
2 |
3 | import android.app.Fragment;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 |
6 | import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
7 |
8 | import rx.Subscription;
9 |
10 | /**
11 | * Created by allen on 2016/6/17.
12 | */
13 | public class BaseFragment extends Fragment implements SwipeRefreshLayout
14 | .OnRefreshListener,RecyclerArrayAdapter.OnLoadMoreListener{
15 | protected Subscription subscription;
16 |
17 |
18 |
19 | @Override
20 | public void onDestroyView() {
21 | super.onDestroyView();
22 | unsubscribe();
23 | }
24 |
25 | protected void unsubscribe() {
26 | if (subscription != null && !subscription.isUnsubscribed()) {
27 | subscription.unsubscribe();
28 | }
29 | }
30 |
31 | @Override
32 | public void onRefresh() {
33 |
34 | }
35 |
36 | @Override
37 | public void onLoadMore() {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/fragment/GirlFragment.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.fragment;
2 |
3 | import android.app.ActivityOptions;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.widget.DefaultItemAnimator;
9 | import android.support.v7.widget.StaggeredGridLayoutManager;
10 | import android.util.Log;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 |
15 | import com.jude.easyrecyclerview.EasyRecyclerView;
16 | import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
17 | import com.jude.easyrecyclerview.decoration.SpaceDecoration;
18 | import com.wu.allen.zhuanlan.R;
19 | import com.wu.allen.zhuanlan.adapter.GirlAdapter;
20 | import com.wu.allen.zhuanlan.cache.Data;
21 | import com.wu.allen.zhuanlan.model.Item;
22 | import com.wu.allen.zhuanlan.util.Dp2PxUtil;
23 | import com.wu.allen.zhuanlan.view.activity.GirlActivity;
24 |
25 | import java.util.List;
26 |
27 | import rx.Observer;
28 | import rx.Subscription;
29 |
30 | /**
31 | * Created by allen on 2016/6/17.
32 | */
33 | public class GirlFragment extends BaseFragment {
34 |
35 | private static final String TAG = "GirlFragment";
36 | protected Subscription subscription;
37 | private EasyRecyclerView recyclerView;
38 | private GirlAdapter girlAdapter;
39 | private String title;
40 | private int page = 1;
41 | private Handler handler = new Handler();
42 | private String[] ids;
43 | private String msgTopic;
44 |
45 | @Nullable
46 | @Override
47 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
48 | View view = inflater.inflate(R.layout.fragment_girl_layout, container, false);
49 | initView(view);
50 | return view;
51 | }
52 | // initView
53 | public void initView(View view){
54 | recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);
55 | StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
56 | recyclerView.setLayoutManager(staggeredGridLayoutManager);
57 | recyclerView.setItemAnimator(new DefaultItemAnimator());
58 | girlAdapter = new GirlAdapter(getActivity());
59 | doWithGirl(girlAdapter);
60 | // for itemDecoration
61 | SpaceDecoration itemDecoration = new SpaceDecoration((int) Dp2PxUtil.convertDpToPixel(8,getActivity()));
62 | itemDecoration.setPaddingEdgeSide(true);
63 | itemDecoration.setPaddingStart(true);
64 | itemDecoration.setPaddingHeaderFooter(false);
65 | recyclerView.addItemDecoration(itemDecoration);
66 | recyclerView.setRefreshListener(this);
67 | // load data while init
68 | getGirlData(page);
69 | }
70 | // can intent to GirlActivity here
71 | private void doWithGirl(final RecyclerArrayAdapter- adapter) {
72 | recyclerView.setAdapterWithProgress(adapter);
73 | adapter.setMore(R.layout.load_more_layout,this);
74 | adapter.setNoMore(R.layout.no_more_layout);
75 | adapter.setError(R.layout.error_layout);
76 | adapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {
77 | @Override
78 | public void onItemClick(int position) {
79 |
80 | Intent intent = new Intent(getActivity(), GirlActivity.class);
81 | intent.putExtra("desc",adapter.getItem(position).description);
82 | intent.putExtra("url",adapter.getItem(position).imageUrl);
83 | startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
84 | }
85 | });
86 | }
87 | // Here get data from cache or net
88 | private void getGirlData(int page) {
89 | unsubscribe();
90 | subscription = Data.getInstance()
91 | .subscribeData(new Observer
>() {
92 | @Override
93 | public void onCompleted() {}
94 |
95 | @Override
96 | public void onError(Throwable e) {
97 | Log.e(TAG,e.getMessage());
98 | }
99 |
100 | @Override
101 | public void onNext(List- items) {
102 | girlAdapter.addAll(items);
103 | }
104 | },page);
105 | }
106 | // Load and Refresh data
107 | @Override
108 | public void onRefresh() {
109 | handler.postDelayed(new Runnable() {
110 | @Override
111 | public void run() {
112 | // before refresh clean cache
113 | girlAdapter.clear();
114 | Data.getInstance().clearMemoryAndDiskCache();
115 | getGirlData(page);
116 |
117 | }
118 | }, 1000);
119 | }
120 |
121 | @Override
122 | public void onLoadMore() {
123 | handler.postDelayed(new Runnable() {
124 | @Override
125 | public void run() {
126 | // before load more ,clean cache
127 | Data.getInstance().clearMemoryAndDiskCache();
128 | page ++;
129 | getGirlData(page);
130 | }
131 | }, 1000);
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/view/fragment/ZhihuFragment.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.view.fragment;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorInflater;
5 | import android.app.ActivityOptions;
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.os.Handler;
9 | import android.support.annotation.Nullable;
10 | import android.support.design.widget.FloatingActionButton;
11 | import android.support.v7.widget.DefaultItemAnimator;
12 | import android.support.v7.widget.LinearLayoutManager;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.view.animation.CycleInterpolator;
18 | import android.widget.LinearLayout;
19 |
20 | import com.jude.easyrecyclerview.EasyRecyclerView;
21 | import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
22 | import com.wu.allen.zhuanlan.R;
23 | import com.wu.allen.zhuanlan.adapter.ZhuanLanAdapter;
24 | import com.wu.allen.zhuanlan.model.ZhuanLan;
25 | import com.wu.allen.zhuanlan.net.Network;
26 | import com.wu.allen.zhuanlan.util.NetWorkUtil;
27 | import com.wu.allen.zhuanlan.util.TopicData;
28 | import com.wu.allen.zhuanlan.view.activity.ZhlanDetailActivity;
29 | import java.util.List;
30 | import java.util.Random;
31 |
32 | import rx.Subscriber;
33 | import rx.android.schedulers.AndroidSchedulers;
34 | import rx.schedulers.Schedulers;
35 |
36 | /**
37 | * Created by allen on 2016/6/17.
38 | */
39 | public class ZhihuFragment extends BaseFragment {
40 |
41 | private static final String TAG = "ZhihuFragment";
42 | private EasyRecyclerView recyclerView;
43 | private List zhuanLanList;
44 | private LinearLayout noNetLayout;
45 | private ZhuanLanAdapter zhuanLanAdapter;
46 | private String title;
47 | private int page = 1;
48 | private Handler handler = new Handler();
49 | private String[] ids;
50 | private String[] TopicIds = {"TopicData.music_film_ids","TopicData.life_talks_ids",
51 | "TopicData.photography_ids","TopicData.photography_ids"};
52 | private String msgTopic;
53 |
54 | @Override
55 | public void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | ids = TopicData.default_ids;
58 |
59 | }
60 |
61 | @Nullable
62 | @Override
63 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
64 | View view = inflater.inflate(R.layout.fragment_zhuanlan_layout, container, false);
65 | initView(view);
66 | if(!NetWorkUtil.isNetworkConnected(getActivity())){
67 | noNetLayout.setVisibility(View.VISIBLE);
68 | }
69 |
70 | return view;
71 | }
72 | // initView
73 | public void initView(View view){
74 |
75 | final FloatingActionButton fab = (FloatingActionButton)view.findViewById(R.id.fab);
76 | fab.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View view) {
79 | Animator animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.animator_rotation);
80 | animator.setTarget(fab);
81 | animator.setInterpolator(new CycleInterpolator(2));
82 | animator.start();
83 | // bug here still
84 | changeTopic();
85 | onRefresh();
86 | }
87 | });
88 |
89 | noNetLayout = (LinearLayout) view.findViewById(R.id.no_network);
90 | recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);
91 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
92 | recyclerView.setItemAnimator(new DefaultItemAnimator());
93 | recyclerView.setLayoutManager(linearLayoutManager);
94 | zhuanLanAdapter = new ZhuanLanAdapter(getActivity());
95 | doWithZhuanLan(zhuanLanAdapter);
96 | recyclerView.setRefreshListener(this);
97 | onRefresh();
98 | }
99 | // Because of Api , there is a Skill
100 | private void changeTopic() {
101 | int max=3;
102 | int min=0;
103 | Random random = new Random();
104 | int s = random.nextInt(max)%(max-min+1) + min;
105 |
106 | ids = TopicData.life_talks_ids;
107 | }
108 | // Intent to ZhlanDetailActivity
109 | private void doWithZhuanLan(final RecyclerArrayAdapter adapter) {
110 | recyclerView.setAdapterWithProgress(adapter);
111 | adapter.setMore(R.layout.load_more_layout,this);
112 | adapter.setNoMore(R.layout.no_more_layout);
113 | adapter.setError(R.layout.error_layout);
114 | adapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {
115 | @Override
116 | public void onItemClick(int position) {
117 | Intent intent = new Intent(getActivity(),ZhlanDetailActivity.class);
118 | intent.putExtra("slug",adapter.getItem(position).getSlug());
119 | intent.putExtra("title",adapter.getItem(position).getName());
120 | intent.putExtra("profile_url",adapter.getItem(position).getCreator().getProfileUrl());
121 | startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
122 | }
123 | });
124 | }
125 |
126 | // Get Zhuanlan Author List
127 | private void getZhuanLanData(String zhuanlanname) {
128 | Network.getZhuanLanApi()
129 | .getZhuanLan(zhuanlanname)
130 | .subscribeOn(Schedulers.io())
131 | .observeOn(AndroidSchedulers.mainThread())
132 | .subscribe(new Subscriber() {
133 | @Override
134 | public void onCompleted() {
135 | Log.e(TAG,"onCompleted");
136 | }
137 |
138 | @Override
139 | public void onError(Throwable e) {
140 | Log.e(TAG,e.getMessage());
141 |
142 | }
143 | @Override
144 | public void onNext(ZhuanLan zhuanLan) {
145 | Log.e(TAG,"OnNext");
146 | zhuanLanAdapter.add(zhuanLan);
147 | }
148 | });
149 | }
150 |
151 | @Override
152 | public void onRefresh() {
153 | handler.postDelayed(new Runnable() {
154 | @Override
155 | public void run() {
156 | zhuanLanAdapter.clear();
157 | for (int i = 0;i < ids.length; i++) {
158 | getZhuanLanData(ids[i]);
159 | }
160 | }
161 | }, 1000);
162 | }
163 |
164 | @Override
165 | public void onLoadMore() {
166 | handler.postDelayed(new Runnable() {
167 | @Override
168 | public void run() {
169 | ids = TopicData.photography_ids;
170 | //zhuanLanAdapter.clear();
171 | for (int i = 0;i < ids.length; i++) {
172 | getZhuanLanData(ids[i]);
173 | }
174 | }
175 | }, 1000);
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wu/allen/zhuanlan/widget/ScrollAwareFABBehavior.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan.widget;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.support.design.widget.CoordinatorLayout;
6 | import android.support.design.widget.FloatingActionButton;
7 | import android.support.v4.view.ViewCompat;
8 | import android.support.v4.view.ViewPropertyAnimatorListener;
9 | import android.support.v4.view.animation.FastOutSlowInInterpolator;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 | import android.view.animation.Animation;
13 | import android.view.animation.AnimationUtils;
14 | import android.view.animation.Interpolator;
15 |
16 | import com.wu.allen.zhuanlan.R;
17 |
18 | /**
19 | * Created by allen on 2016/6/15.
20 | */
21 | public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior {
22 | private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator();
23 | private boolean mIsAnimatingOut = false;
24 |
25 | public ScrollAwareFABBehavior(Context context, AttributeSet attrs) {
26 | super();
27 | }
28 |
29 | @Override
30 | public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
31 | final View directTargetChild, final View target, final int nestedScrollAxes) {
32 | // Ensure we react to vertical scrolling
33 | return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
34 | || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
35 | }
36 |
37 | @Override
38 | public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
39 | final View target, final int dxConsumed, final int dyConsumed,
40 | final int dxUnconsumed, final int dyUnconsumed) {
41 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
42 | if (dyConsumed > 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
43 | // User scrolled down and the FAB is currently visible -> hide the FAB
44 | animateOut(child);
45 | } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
46 | // User scrolled up and the FAB is currently not visible -> show the FAB
47 | animateIn(child);
48 | }
49 | }
50 |
51 | // Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits
52 | private void animateOut(final FloatingActionButton button) {
53 | if (Build.VERSION.SDK_INT >= 14) {
54 | ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR).withLayer()
55 | .setListener(new ViewPropertyAnimatorListener() {
56 | public void onAnimationStart(View view) {
57 | ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
58 | }
59 |
60 | public void onAnimationCancel(View view) {
61 | ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
62 | }
63 |
64 | public void onAnimationEnd(View view) {
65 | ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
66 | view.setVisibility(View.GONE);
67 | }
68 | }).start();
69 | } else {
70 | Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
71 | anim.setInterpolator(INTERPOLATOR);
72 | anim.setDuration(200L);
73 | anim.setAnimationListener(new Animation.AnimationListener() {
74 | public void onAnimationStart(Animation animation) {
75 | ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
76 | }
77 |
78 | public void onAnimationEnd(Animation animation) {
79 | ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
80 | button.setVisibility(View.GONE);
81 | }
82 |
83 | @Override
84 | public void onAnimationRepeat(final Animation animation) {
85 | }
86 | });
87 | button.startAnimation(anim);
88 | }
89 | }
90 |
91 | // Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout enters
92 | private void animateIn(FloatingActionButton button) {
93 | button.setVisibility(View.VISIBLE);
94 | if (Build.VERSION.SDK_INT >= 14) {
95 | ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
96 | .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
97 | .start();
98 | } else {
99 | Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_in);
100 | anim.setDuration(200L);
101 | anim.setInterpolator(INTERPOLATOR);
102 | button.startAnimation(anim);
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fab_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
22 |
23 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fab_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/animator_rotation.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/about_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/about_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/aboutbg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/aboutbg.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/change.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/change.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/error.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/error.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_find_replace_black_24dp.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/ic_find_replace_black_24dp.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/logo.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/read.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/drawable/read.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
25 |
26 |
32 |
33 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
58 |
59 |
65 |
66 |
77 |
78 |
86 |
87 |
88 |
96 |
97 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_articledetail.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
49 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
15 |
16 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/error_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_girl_layout.xml:
--------------------------------------------------------------------------------
1 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_zhuanlan_layout.xml:
--------------------------------------------------------------------------------
1 |
8 |
15 |
16 |
23 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/girl_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/girldetail_layout.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/load_more_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/no_more_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/progress_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/zhuanlan_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
24 |
25 |
33 |
41 |
49 |
50 |
55 |
56 |
61 |
62 |
68 |
69 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/zhuanlan_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/zhuanlanpost_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
17 |
18 |
22 |
23 |
33 |
34 |
43 |
44 |
45 |
50 |
51 |
58 |
59 |
67 |
68 |
69 |
70 |
71 |
72 |
78 |
79 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/articledetail_menu_.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/girl_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v19:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/app/src/main/res/values-v19
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 专栏
3 | 设置
4 | 关于
5 | 专栏
6 | 妹子
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/array.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
- 模式切换
5 | - 缓存清理
6 | - 专栏内容加上缓存
7 | - 专栏文章评论接口的实现
8 | - 专栏文章作者圆角头像的实现
9 | - 专栏文章分享功能的实现
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #202529
4 | #202529
5 | #202529
6 | #202529
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 专栏
3 | ToDo
4 | About
5 | 专栏
6 | 妹子
7 |
8 | 保存
9 | 分享
10 | 评论、
11 | ToDo
12 |
13 | ZhuanLan Meizhi\nGitHub:https://github.com/wuchangfeng/ZhuanLan
14 | 个人一个练手 App,主要学习 RxJava 和 Retrofit 以及基于 RxJava 的缓存技术以及一些常用开源库的使用。\n
15 | App 中的知乎专栏 API 为并非由知乎官方提供,侵权删。妹子图的 API 来自 Gank.io。\n感谢。
16 | 开源库:\nrxjava\nretrofit\nokhttp\nPhotoView\nglide\neasyrecyclerview\ncom.nispok:snackbar\nom.afollestad.material-dialogs
17 |
18 | 专栏内容的缓存还在进行中ing Orz
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
11 |
12 |
13 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/test/java/com/wu/allen/zhuanlan/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.wu.allen.zhuanlan;
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.2.0-alpha4'
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 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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/.idea/.name:
--------------------------------------------------------------------------------
1 | ZhuanLan
--------------------------------------------------------------------------------
/gradle/.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 |
--------------------------------------------------------------------------------
/gradle/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/PhotoView_1_2_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/adapter_rxjava_2_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/android_android_23.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/animated_vector_drawable_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/appcompat_v7_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/cardview_v7_23_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/circleimageview_2_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/converter_gson_2_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/core_0_8_5_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/design_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/easyrecyclerview_4_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/glide_3_7_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/gson_2_6_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/hamcrest_core_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/junit_4_12.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/library_1_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/library_1_1_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/library_2_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/logging_interceptor_3_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/okhttp_3_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/okio_1_6_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/recyclerview_v7_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/retrofit_2_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/rxandroid_1_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/rxjava_1_1_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/snackbar_2_11_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/support_annotations_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/support_v13_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/support_v4_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle/.idea/libraries/support_vector_drawable_23_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.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 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/gradle/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuchangfeng/zhuanlan/62eac2d1af5a25e5df5fe448d9f13ab2f11a59f0/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 |
--------------------------------------------------------------------------------