From aa5e7ec930f83c415f93660f2b355986c3f66b97 Mon Sep 17 00:00:00 2001 From: maning <154292322@qq.com> Date: Wed, 30 Sep 2020 17:20:12 +0800 Subject: [PATCH] =?UTF-8?q?gank=E6=89=80=E6=9C=89=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E9=87=87=E7=94=A8=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maning/gankmm/bean/gank/GankBaseBean.java | 19 +++ .../{DayEntity.java => gank/GankDayBean.java} | 23 +--- .../gankmm/bean/gank/GankHistoryListBean.java | 26 ++++ .../gankmm/http/gank/APIGankService.java | 15 +-- .../com/maning/gankmm/http/gank/GankApi.java | 96 ++------------ .../gankmm/http/update/APIUpdateService.java | 33 ----- .../ui/presenter/impl/GankPresenterImpl.java | 117 ++++++++---------- .../presenter/impl/HistoryPresenterImpl.java | 51 +++----- 8 files changed, 137 insertions(+), 243 deletions(-) create mode 100644 app/src/main/java/com/maning/gankmm/bean/gank/GankBaseBean.java rename app/src/main/java/com/maning/gankmm/bean/{DayEntity.java => gank/GankDayBean.java} (50%) create mode 100644 app/src/main/java/com/maning/gankmm/bean/gank/GankHistoryListBean.java diff --git a/app/src/main/java/com/maning/gankmm/bean/gank/GankBaseBean.java b/app/src/main/java/com/maning/gankmm/bean/gank/GankBaseBean.java new file mode 100644 index 0000000..0ba4cab --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/gank/GankBaseBean.java @@ -0,0 +1,19 @@ +package com.maning.gankmm.bean.gank; + +/** + * @author : maning + * @date : 2020-09-29 + * @desc : 第一版本的Gank + */ +public class GankBaseBean { + + private boolean error; + + public boolean isError() { + return error; + } + + public void setError(boolean error) { + this.error = error; + } +} diff --git a/app/src/main/java/com/maning/gankmm/bean/DayEntity.java b/app/src/main/java/com/maning/gankmm/bean/gank/GankDayBean.java similarity index 50% rename from app/src/main/java/com/maning/gankmm/bean/DayEntity.java rename to app/src/main/java/com/maning/gankmm/bean/gank/GankDayBean.java index 55f5c46..aac1dcb 100644 --- a/app/src/main/java/com/maning/gankmm/bean/DayEntity.java +++ b/app/src/main/java/com/maning/gankmm/bean/gank/GankDayBean.java @@ -1,4 +1,7 @@ -package com.maning.gankmm.bean; +package com.maning.gankmm.bean.gank; + +import com.maning.gankmm.bean.GankEntity; +import com.maning.gankmm.bean.gank.GankBaseBean; import java.io.Serializable; import java.util.List; @@ -7,28 +10,12 @@ * Created by maning on 16/6/2. * 获取每日数据的接口 */ -public class DayEntity implements Serializable { +public class GankDayBean extends GankBaseBean implements Serializable { private static final long serialVersionUID = 1437313256335061579L; - - /** - * category : ["iOS","拓展资源","Android","休息视频","福利"] - * error : false - * results : {"Android":[{"_id":"56cc6d23421aa95caa707bba","createdAt":"2015-08-06T02:05:32.826Z","desc":"一个查看设备规格的库,并且可以计算哪一年被定为\u201c高端\u201d机","publishedAt":"2015-08-06T04:16:55.575Z","type":"Android","url":"https://github.com/facebook/device-year-class","used":true,"who":"有时放纵"},{"_id":"56cc6d23421aa95caa707c67","createdAt":"2015-08-05T16:36:19.591Z","desc":"一个好玩的自定义字体库","publishedAt":"2015-08-06T04:16:55.805Z","type":"Android","url":"https://github.com/vsvankhede/easyfonts","used":true,"who":"有时放纵"},{"_id":"56cc6d23421aa95caa707c6a","createdAt":"2015-08-06T02:07:23.290Z","desc":"一个小清新spinner","publishedAt":"2015-08-06T04:16:55.582Z","type":"Android","url":"https://github.com/arcadefire/nice-spinner","used":true,"who":"有时放纵"}],"iOS":[{"_id":"56cc6d1d421aa95caa70777e","createdAt":"2015-08-06T01:55:36.30Z","desc":"iOS 核心动画高级技巧","publishedAt":"2015-08-06T04:16:55.592Z","type":"iOS","url":"http://zsisme.gitbooks.io/ios-/content/","used":true,"who":"Andrew Liu"},{"_id":"56cc6d23421aa95caa707a65","createdAt":"2015-08-05T03:45:12.537Z","desc":"设定label,text等视图的属性,你喜欢这种方式么?","publishedAt":"2015-08-06T04:16:55.584Z","type":"iOS","url":"http://natashatherobot.com/ios-a-beautiful-way-of-styling-iboutlets-in-swift/?utm_campaign=This%2BWeek%2Bin%2BSwift&utm_medium=web&utm_source=This_Week_in_Swift_47","used":true,"who":"Huan"},{"_id":"56cc6d23421aa95caa707c62","createdAt":"2015-08-06T01:56:32.207Z","desc":"iOS开发之block终极篇","publishedAt":"2015-08-06T04:16:55.589Z","type":"iOS","url":"http://www.90159.com/2015/08/05/ios-block-ultimate/","used":true,"who":"Andrew Liu"},{"_id":"56cc6d23421aa95caa707c70","createdAt":"2015-08-05T12:17:08.481Z","desc":"Status Board 2 - Panic 公司推出的 iOS App,可以生成可视化数据图表,用以监测项目效率、Bug量,团队动态、销售情况等多种数据(稀土圈)","publishedAt":"2015-08-06T04:16:55.601Z","type":"iOS","url":"https://www.panic.com/statusboard/","used":true,"who":"LHF"}],"休息视频":[{"_id":"56cc6d23421aa95caa707c2b","createdAt":"2015-08-06T03:55:07.175Z","desc":"重温字幕版倒鸭子~~~","publishedAt":"2015-08-06T04:16:55.578Z","type":"休息视频","url":"http://video.weibo.com/show?fid=1034:0c79a69b1bafe17df62e750391d92118","used":true,"who":"代码家"}],"拓展资源":[{"_id":"56cc6d1d421aa95caa707781","createdAt":"2015-08-06T00:53:43.851Z","desc":"node express 源码接卸","publishedAt":"2015-08-06T04:16:55.601Z","type":"拓展资源","url":"https://gist.github.com/dlutwuwei/3faf88d535ac81c4e263","used":true,"who":"YJX"},{"_id":"56cc6d23421aa95caa707a66","createdAt":"2015-08-06T00:49:19.237Z","desc":"MongoDB从入门到精通系列","publishedAt":"2015-08-06T04:16:55.579Z","type":"拓展资源","url":"http://codefrom.com/t/mongodb%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A%E7%B3%BB%E5%88%97%E4%B8%93%E9%A2%98","used":true,"who":"YJX"}],"福利":[{"_id":"56cc6d23421aa95caa707c6f","createdAt":"2015-08-06T01:33:55.463Z","desc":"8.6","publishedAt":"2015-08-06T04:16:55.601Z","type":"福利","url":"http://ww4.sinaimg.cn/large/7a8aed7bgw1eusn3niy2bj20hs0qo0wb.jpg","used":true,"who":"张涵宇"}]} - */ - - private boolean error; private ResultsEntity results; private List category; - public boolean isError() { - return error; - } - - public void setError(boolean error) { - this.error = error; - } - public ResultsEntity getResults() { return results; } diff --git a/app/src/main/java/com/maning/gankmm/bean/gank/GankHistoryListBean.java b/app/src/main/java/com/maning/gankmm/bean/gank/GankHistoryListBean.java new file mode 100644 index 0000000..ca69c13 --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/gank/GankHistoryListBean.java @@ -0,0 +1,26 @@ +package com.maning.gankmm.bean.gank; + +import java.util.List; + +/** + * @author : maning + * @date : 2020-09-30 + * @desc : + */ +public class GankHistoryListBean extends GankBaseBean{ + + /** + * error : false + * results : ["2019-04-10","2019-01-21","2019-01-03","2018-12-28","2018-12-13","2018-11-28","2018-11-19","2018-11-06","2018-10-22","2018-10-15","2018-10-08","2018-09-19","2018-09-11","2018-08-28","2018-08-21","2018-08-16","2018-08-13","2018-08-09","2018-08-06","2018-08-03","2018-08-01","2018-07-31","2018-07-30","2018-07-19","2018-07-18","2018-07-13","2018-07-11","2018-07-10","2018-07-09","2018-07-06","2018-07-05","2018-07-03","2018-07-02","2018-06-28","2018-06-27","2018-06-26","2018-06-25","2018-06-22","2018-06-21","2018-06-20","2018-06-19","2018-06-15","2018-06-14","2018-06-13","2018-06-12","2018-06-11","2018-06-08","2018-06-07","2018-06-06","2018-06-05","2018-06-04","2018-06-01","2018-05-31","2018-05-30","2018-05-29","2018-05-28","2018-05-25","2018-05-24","2018-05-23","2018-05-22","2018-05-21","2018-05-19","2018-05-18","2018-05-17","2018-05-16","2018-05-15","2018-05-14","2018-05-13","2018-05-12","2018-05-11","2018-05-10","2018-05-09","2018-05-08","2018-05-06","2018-05-05","2018-05-04","2018-03-12","2018-02-22","2018-02-08","2018-01-29","2018-01-23","2018-01-16","2018-01-10","2018-01-04","2018-01-02","2017-12-27","2017-12-25","2017-12-19","2017-12-15","2017-12-11","2017-12-06","2017-12-05","2017-11-30","2017-11-24","2017-11-20","2017-11-17","2017-11-16","2017-11-14","2017-11-13","2017-11-10","2017-11-08","2017-11-06","2017-11-01","2017-10-31","2017-10-27","2017-10-25","2017-10-24","2017-10-23","2017-10-20","2017-10-17","2017-10-16","2017-10-11","2017-10-10","2017-10-09","2017-09-29","2017-09-26","2017-09-21","2017-09-20","2017-09-19","2017-09-14","2017-09-12","2017-09-07","2017-09-06","2017-09-05","2017-09-01","2017-08-31","2017-08-29","2017-08-24","2017-08-23","2017-08-22","2017-08-21","2017-08-17","2017-08-15","2017-08-14","2017-08-11","2017-08-09","2017-08-08","2017-08-03","2017-08-02","2017-08-01","2017-07-27","2017-07-26","2017-07-25","2017-07-24","2017-07-21","2017-07-20","2017-07-19","2017-07-18","2017-07-17","2017-07-14","2017-07-13","2017-07-12","2017-07-11","2017-07-10","2017-07-07","2017-07-06","2017-07-05","2017-07-04","2017-06-15","2017-06-14","2017-06-12","2017-06-09","2017-06-08","2017-06-07","2017-06-06","2017-06-05","2017-06-03","2017-06-02","2017-06-01","2017-05-26","2017-05-25","2017-05-24","2017-05-23","2017-05-22","2017-05-16","2017-05-15","2017-05-12","2017-05-11","2017-05-10","2017-05-09","2017-05-08","2017-05-05","2017-05-04","2017-05-03","2017-05-02","2017-04-28","2017-04-27","2017-04-26","2017-04-25","2017-04-24","2017-04-21","2017-04-20","2017-04-19","2017-04-18","2017-04-17","2017-04-14","2017-04-13","2017-04-12","2017-04-11","2017-04-10","2017-04-07","2017-04-06","2017-04-05","2017-03-31","2017-03-30","2017-03-29","2017-03-28","2017-03-27","2017-03-24","2017-03-23","2017-03-22","2017-03-21","2017-03-20","2017-03-17","2017-03-16","2017-03-15","2017-03-14","2017-03-13","2017-03-10","2017-03-09","2017-03-08","2017-03-07","2017-03-06","2017-03-03","2017-03-02","2017-03-01","2017-02-28","2017-02-27","2017-02-24","2017-02-23","2017-02-22","2017-02-21","2017-02-20","2017-02-17","2017-02-16","2017-02-15","2017-02-14","2017-02-13","2017-02-10","2017-02-09","2017-02-08","2017-02-07","2017-02-06","2017-02-04","2017-02-03","2017-01-23","2017-01-22","2017-01-20","2017-01-19","2017-01-16","2017-01-13","2017-01-12","2017-01-11","2017-01-10","2017-01-09","2017-01-06","2017-01-05","2017-01-04","2017-01-03","2016-12-30","2016-12-29","2016-12-28","2016-12-27","2016-12-26","2016-12-23","2016-12-22","2016-12-21","2016-12-20","2016-12-19","2016-12-16","2016-12-15","2016-12-14","2016-12-13","2016-12-12","2016-12-09","2016-12-08","2016-12-07","2016-12-06","2016-12-05","2016-12-02","2016-12-01","2016-11-30","2016-11-29","2016-11-28","2016-11-25","2016-11-24","2016-11-23","2016-11-22","2016-11-21","2016-11-18","2016-11-17","2016-11-16","2016-11-15","2016-11-14","2016-11-11","2016-11-10","2016-11-09","2016-11-08","2016-11-07","2016-11-04","2016-11-03","2016-11-02","2016-11-01","2016-10-31","2016-10-28","2016-10-27","2016-10-26","2016-10-25","2016-10-24","2016-10-21","2016-10-20","2016-10-19","2016-10-18","2016-10-17","2016-10-14","2016-10-13","2016-10-12","2016-10-11","2016-10-10","2016-10-09","2016-10-08","2016-09-30","2016-09-29","2016-09-28","2016-09-27","2016-09-26","2016-09-23","2016-09-22","2016-09-21","2016-09-20","2016-09-19","2016-09-18","2016-09-14","2016-09-13","2016-09-12","2016-09-09","2016-09-08","2016-09-07","2016-09-06","2016-09-05","2016-09-02","2016-09-01","2016-08-31","2016-08-30","2016-08-29","2016-08-26","2016-08-25","2016-08-24","2016-08-23","2016-08-22","2016-08-19","2016-08-18","2016-08-17","2016-08-16","2016-08-15","2016-08-12","2016-08-11","2016-08-10","2016-08-09","2016-08-08","2016-08-05","2016-08-03","2016-08-02","2016-08-01","2016-07-29","2016-07-28","2016-07-27","2016-07-26","2016-07-25","2016-07-22","2016-07-21","2016-07-20","2016-07-19","2016-07-18","2016-07-15","2016-07-14","2016-07-13","2016-07-12","2016-07-11","2016-07-08","2016-07-07","2016-07-06","2016-07-05","2016-07-04","2016-07-01","2016-06-30","2016-06-29","2016-06-28","2016-06-27","2016-06-24","2016-06-23","2016-06-22","2016-06-21","2016-06-20","2016-06-17","2016-06-16","2016-06-15","2016-06-14","2016-06-13","2016-06-12","2016-06-08","2016-06-07","2016-06-06","2016-06-03","2016-06-02","2016-06-01","2016-05-31","2016-05-30","2016-05-27","2016-05-26","2016-05-25","2016-05-24","2016-05-23","2016-05-20","2016-05-19","2016-05-18","2016-05-17","2016-05-16","2016-05-13","2016-05-12","2016-05-11","2016-05-10","2016-05-09","2016-05-06","2016-05-05","2016-05-04","2016-05-03","2016-04-29","2016-04-28","2016-04-27","2016-04-26","2016-04-25","2016-04-22","2016-04-21","2016-04-20","2016-04-19","2016-04-18","2016-04-15","2016-04-14","2016-04-13","2016-04-12","2016-04-11","2016-04-08","2016-04-07","2016-04-06","2016-04-05","2016-04-01","2016-03-31","2016-03-30","2016-03-29","2016-03-28","2016-03-25","2016-03-24","2016-03-23","2016-03-22","2016-03-21","2016-03-18","2016-03-17","2016-03-16","2016-03-15","2016-03-14","2016-03-11","2016-03-10","2016-03-09","2016-03-08","2016-03-07","2016-03-04","2016-03-03","2016-03-02","2016-03-01","2016-02-29","2016-02-26","2016-02-25","2016-02-24","2016-02-23","2016-02-22","2016-02-19","2016-02-18","2016-02-17","2016-02-16","2016-02-15","2016-02-04","2016-02-03","2016-02-02","2016-02-01","2016-01-29","2016-01-28","2016-01-27","2016-01-26","2016-01-25","2016-01-22","2016-01-21","2016-01-20","2016-01-19","2016-01-18","2016-01-15","2016-01-14","2016-01-13","2016-01-12","2016-01-11","2016-01-08","2016-01-07","2016-01-06","2016-01-05","2016-01-04","2015-12-31","2015-12-30","2015-12-29","2015-12-28","2015-12-25","2015-12-24","2015-12-23","2015-12-22","2015-12-21","2015-12-18","2015-12-17","2015-12-16","2015-12-15","2015-12-14","2015-12-11","2015-12-10","2015-12-09","2015-12-08","2015-12-07","2015-12-04","2015-12-03","2015-12-02","2015-12-01","2015-11-30","2015-11-27","2015-11-26","2015-11-25","2015-11-24","2015-11-23","2015-11-20","2015-11-19","2015-11-18","2015-11-17","2015-11-16","2015-11-13","2015-11-12","2015-11-11","2015-11-10","2015-11-09","2015-11-06","2015-11-05","2015-11-04","2015-11-03","2015-11-02","2015-10-30","2015-10-29","2015-10-28","2015-10-27","2015-10-26","2015-10-23","2015-10-22","2015-10-21","2015-10-20","2015-10-19","2015-10-16","2015-10-15","2015-10-14","2015-10-13","2015-10-12","2015-10-10","2015-10-09","2015-10-08","2015-09-30","2015-09-29","2015-09-28","2015-09-25","2015-09-24","2015-09-23","2015-09-22","2015-09-21","2015-09-18","2015-09-17","2015-09-16","2015-09-15","2015-09-14","2015-09-11","2015-09-10","2015-09-09","2015-09-08","2015-09-07","2015-09-06","2015-09-02","2015-09-01","2015-08-31","2015-08-28","2015-08-27","2015-08-26","2015-08-25","2015-08-24","2015-08-21","2015-08-20","2015-08-19","2015-08-18","2015-08-17","2015-08-14","2015-08-13","2015-08-12","2015-08-11","2015-08-10","2015-08-07","2015-08-06","2015-08-05","2015-08-04","2015-08-03","2015-07-31","2015-07-30","2015-07-29","2015-07-28","2015-07-27","2015-07-24","2015-07-23","2015-07-22","2015-07-21","2015-07-20","2015-07-17","2015-07-16","2015-07-15","2015-07-14","2015-07-13","2015-07-10","2015-07-09","2015-07-08","2015-07-07","2015-07-06","2015-07-03","2015-07-02","2015-07-01","2015-06-30","2015-06-29","2015-06-26","2015-06-19","2015-06-18","2015-06-17","2015-06-16","2015-06-15","2015-06-12","2015-06-11","2015-06-10","2015-06-09","2015-06-08","2015-06-05","2015-06-04","2015-06-03","2015-06-02","2015-06-01","2015-05-29","2015-05-28","2015-05-27","2015-05-26","2015-05-25","2015-05-22","2015-05-21","2015-05-20","2015-05-19","2015-05-18","2015-05-15","2015-05-14","2015-05-13","2015-05-12","2015-05-11","2015-05-08","2015-05-07","2015-05-06","2015-05-04","2015-04-30","2015-04-29","2015-04-27","2015-04-24","2015-04-23","2015-04-22","2015-04-21","2015-04-20","2015-04-17","2015-04-16","2015-04-15","2015-04-14","2015-04-13","2015-04-10","2015-04-09","2015-04-08","2015-04-07","2015-04-03","2015-04-02","2015-04-01","2015-03-31","2015-03-30","2015-03-26","2015-03-25","2015-03-24","2015-03-23","2015-03-20","2015-03-19","2015-03-18","2015-03-17","2015-03-16","2015-03-13","2015-03-12","2015-03-11"] + */ + + private List results; + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } +} diff --git a/app/src/main/java/com/maning/gankmm/http/gank/APIGankService.java b/app/src/main/java/com/maning/gankmm/http/gank/APIGankService.java index e64f3b0..750afad 100644 --- a/app/src/main/java/com/maning/gankmm/http/gank/APIGankService.java +++ b/app/src/main/java/com/maning/gankmm/http/gank/APIGankService.java @@ -1,11 +1,9 @@ package com.maning.gankmm.http.gank; -import com.maning.gankmm.bean.DayEntity; -import com.maning.gankmm.bean.HttpResult; +import com.maning.gankmm.bean.gank.GankDayBean; +import com.maning.gankmm.bean.gank.GankHistoryListBean; import com.maning.gankmm.constant.Constants; -import java.util.List; - import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Headers; @@ -20,14 +18,13 @@ public interface APIGankService { //这里填写全部路径就会覆盖掉Build得BaseUrl @Headers("Cache-Control: public, max-age=3600") @GET(Constants.URL_HistoryDate) - Call>> getGankHistoryDate(); + Call getGankHistoryDate(); //http://gank.io/api/day/2015/08/06 --- 每日数据 - @Headers("Cache-Control: public, max-age=300") @GET("day/{year}/{month}/{day}") - Call getOneDayData(@Path("year") String year, - @Path("month") String month, - @Path("day") String day + Call getOneDayData(@Path("year") String year, + @Path("month") String month, + @Path("day") String day ); } diff --git a/app/src/main/java/com/maning/gankmm/http/gank/GankApi.java b/app/src/main/java/com/maning/gankmm/http/gank/GankApi.java index aa3ac5a..2d86341 100644 --- a/app/src/main/java/com/maning/gankmm/http/gank/GankApi.java +++ b/app/src/main/java/com/maning/gankmm/http/gank/GankApi.java @@ -1,65 +1,18 @@ package com.maning.gankmm.http.gank; -import com.maning.gankmm.R; -import com.maning.gankmm.app.MyApplication; -import com.maning.gankmm.bean.DayEntity; -import com.maning.gankmm.bean.HttpResult; +import com.maning.gankmm.bean.gank.GankDayBean; +import com.maning.gankmm.bean.gank.GankHistoryListBean; import com.maning.gankmm.http.BuildApi; -import com.maning.gankmm.http.callback.MyCallBack; -import com.socks.library.KLog; - -import java.util.List; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; +import com.maning.gankmm.http.callback.CommonHttpCallback; /** * Created by maning on 16/3/2. - *

- * 所有的网络请求 + * gankid 第一版本接口 */ public class GankApi { - public final static String GET_DATA_FAIL = MyApplication.getIntstance().getString(R.string.gank_get_data_fail); - public final static String NET_FAIL = MyApplication.getIntstance().getString(R.string.gank_net_fail); - - - public static Call>> getHistoryData(final int what, final MyCallBack myCallBack) { - - Call>> gankHistoryDate = BuildApi.getGankAPIService().getGankHistoryDate(); - - gankHistoryDate.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, Response>> response) { - if (response.isSuccessful()) { - HttpResult> httpResult = response.body(); - if (httpResult != null) { - if (!httpResult.isError()) { - List gankEntityList = httpResult.getResults(); - KLog.i("getHistoryData---success:" + gankEntityList.toString()); - myCallBack.onSuccessList(what, gankEntityList); - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - KLog.e("getHistoryData-----onFailure:" + t.toString()); - //数据错误 - myCallBack.onFail(what, NET_FAIL); - } - }); - - return gankHistoryDate; - + public static void getHistoryData(CommonHttpCallback httpCallback) { + BuildApi.getGankAPIService().getGankHistoryDate().enqueue(httpCallback); } /** @@ -68,43 +21,10 @@ public void onFailure(Call>> call, Throwable t) { * @param year * @param month * @param day - * @param what - * @param myCallBack * @return */ - public static Call getOneDayData(String year, String month, String day, final int what, final MyCallBack myCallBack) { - - Call oneDayData = BuildApi.getGankAPIService().getOneDayData(year, month, day); - - oneDayData.enqueue(new Callback() { - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful()) { - DayEntity body = response.body(); - if (body != null) { - if (!body.isError()) { - KLog.i("getOneDayData---success:" + body.toString()); - myCallBack.onSuccess(what, body); - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } else { - myCallBack.onFail(what, GET_DATA_FAIL); - } - } - - @Override - public void onFailure(Call call, Throwable t) { - KLog.e("getOneDayData-----onFailure:" + t.toString()); - //数据错误 - myCallBack.onFail(what, NET_FAIL); - } - }); - - return oneDayData; + public static void getOneDayData(String year, String month, String day, CommonHttpCallback httpCallback) { + BuildApi.getGankAPIService().getOneDayData(year, month, day).enqueue(httpCallback); } } diff --git a/app/src/main/java/com/maning/gankmm/http/update/APIUpdateService.java b/app/src/main/java/com/maning/gankmm/http/update/APIUpdateService.java index 9f6d512..d08fa90 100644 --- a/app/src/main/java/com/maning/gankmm/http/update/APIUpdateService.java +++ b/app/src/main/java/com/maning/gankmm/http/update/APIUpdateService.java @@ -1,44 +1,11 @@ package com.maning.gankmm.http.update; import com.maning.gankmm.bean.AppUpdateInfo; -import com.maning.gankmm.bean.CalendarInfoEntity; -import com.maning.gankmm.bean.CitysEntity; -import com.maning.gankmm.bean.DayEntity; -import com.maning.gankmm.bean.HttpResult; -import com.maning.gankmm.bean.MobBaseEntity; -import com.maning.gankmm.bean.WeatherBeseEntity; -import com.maning.gankmm.bean.mob.MobBankCard; -import com.maning.gankmm.bean.mob.MobCarDetailsEntity; -import com.maning.gankmm.bean.mob.MobCarEntity; -import com.maning.gankmm.bean.mob.MobCarItemEntity; -import com.maning.gankmm.bean.mob.MobCookCategoryEntity; -import com.maning.gankmm.bean.mob.MobCookDetailEntity; -import com.maning.gankmm.bean.mob.MobDictEntity; -import com.maning.gankmm.bean.mob.MobFlightEntity; -import com.maning.gankmm.bean.mob.MobHealthEntity; -import com.maning.gankmm.bean.mob.MobHistoryTodayEntity; -import com.maning.gankmm.bean.mob.MobIdCardEntity; -import com.maning.gankmm.bean.mob.MobIdiomEntity; -import com.maning.gankmm.bean.mob.MobIpEntity; -import com.maning.gankmm.bean.mob.MobLotteryEntity; -import com.maning.gankmm.bean.mob.MobOilPriceEntity; -import com.maning.gankmm.bean.mob.MobPhoneAddressEntity; -import com.maning.gankmm.bean.mob.MobPostCodeEntity; -import com.maning.gankmm.bean.mob.MobTrainEntity; -import com.maning.gankmm.bean.mob.MobTrainNoEntity; -import com.maning.gankmm.bean.mob.MobUserInfo; -import com.maning.gankmm.bean.mob.MobWxArticleListEntity; -import com.maning.gankmm.bean.mob.MobWxCategoryEntity; import com.maning.gankmm.constant.Constants; -import java.util.ArrayList; -import java.util.List; - import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Headers; -import retrofit2.http.Path; -import retrofit2.http.Query; /** diff --git a/app/src/main/java/com/maning/gankmm/ui/presenter/impl/GankPresenterImpl.java b/app/src/main/java/com/maning/gankmm/ui/presenter/impl/GankPresenterImpl.java index 5c49bba..6dffa88 100644 --- a/app/src/main/java/com/maning/gankmm/ui/presenter/impl/GankPresenterImpl.java +++ b/app/src/main/java/com/maning/gankmm/ui/presenter/impl/GankPresenterImpl.java @@ -5,10 +5,10 @@ import android.view.View; import com.maning.gankmm.app.MyApplication; -import com.maning.gankmm.bean.DayEntity; import com.maning.gankmm.bean.GankEntity; +import com.maning.gankmm.bean.gank.GankDayBean; +import com.maning.gankmm.http.callback.CommonHttpCallback; import com.maning.gankmm.http.gank.GankApi; -import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.ui.iView.IGankView; import com.maning.gankmm.ui.presenter.IGankPresenter; import com.socks.library.KLog; @@ -21,62 +21,6 @@ */ public class GankPresenterImpl extends BasePresenterImpl implements IGankPresenter { - private MyCallBack httpCallBack = new MyCallBack() { - @Override - public void onSuccessList(int what, List results) { - - } - - @Override - public void onSuccess(int what, Object result) { - if (mView == null) { - return; - } - final DayEntity dayEntity = (DayEntity) result; - if (dayEntity != null) { - DayEntity.ResultsEntity results = dayEntity.getResults(); - if (results != null) { - - List 福利 = dayEntity.getResults().get福利(); - if (福利 != null && 福利.size() > 0) { - String url = dayEntity.getResults().get福利().get(0).getUrl(); - mView.setProgressBarVisility(View.GONE); - mView.showImageView(url); - } else { - mView.setProgressBarVisility(View.GONE); - mView.showToast("糟糕,图片没找到"); - } - try { - //初始化数据 - new Thread(new Runnable() { - @Override - public void run() { - initDatas(dayEntity); - } - }).start(); - } catch (Exception e) { - mView.showToast("抱歉,出错了..."); - } - } else { - mView.showToast("抱歉,当天数据没有..."); - } - } else { - mView.showToast("抱歉,当天数据没有..."); - } - } - - @Override - public void onFail(int what, String result) { - if (mView == null) { - return; - } - mView.hideBaseProgressDialog(); - if (!TextUtils.isEmpty(result)) { - mView.showToast(result); - } - } - }; - private Context context; public GankPresenterImpl(Context context, IGankView iGankView) { @@ -92,17 +36,62 @@ public void getOneDayDatas(String timeStr) { //切割 String[] dayArray = timeStr.split("-"); if (dayArray.length > 2) { - GankApi.getOneDayData(dayArray[0], dayArray[1], dayArray[2], 0x001, httpCallBack); + GankApi.getOneDayData(dayArray[0], dayArray[1], dayArray[2], new CommonHttpCallback() { + @Override + public void onSuccess(final GankDayBean result) { + if (result != null) { + GankDayBean.ResultsEntity results = result.getResults(); + if (results != null) { + + List 福利 = result.getResults().get福利(); + if (福利 != null && 福利.size() > 0) { + String url = result.getResults().get福利().get(0).getUrl(); + mView.setProgressBarVisility(View.GONE); + mView.showImageView(url); + } else { + mView.setProgressBarVisility(View.GONE); + mView.showToast("糟糕,图片没找到"); + } + try { + //初始化数据 + new Thread(new Runnable() { + @Override + public void run() { + initDatas(result); + } + }).start(); + } catch (Exception e) { + mView.showToast("抱歉,出错了..."); + } + } else { + mView.showToast("抱歉,当天数据没有..."); + } + } else { + mView.showToast("抱歉,当天数据没有..."); + } + } + + @Override + public void onFail(int code, String message) { + if (mView == null) { + return; + } + mView.hideBaseProgressDialog(); + if (!TextUtils.isEmpty(message)) { + mView.showToast(message); + } + } + }); } } private List dayEntityArrayList = new ArrayList<>(); - private void initDatas(DayEntity dayEntity) { + private void initDatas(GankDayBean gankDayBean) { dayEntityArrayList.clear(); - List androidEntityList = dayEntity.getResults().getAndroid(); + List androidEntityList = gankDayBean.getResults().getAndroid(); if (androidEntityList != null && androidEntityList.size() > 0) { GankEntity gankEntity_title = new GankEntity(); gankEntity_title.setType("title"); @@ -112,7 +101,7 @@ private void initDatas(DayEntity dayEntity) { } - List iosEntityList = dayEntity.getResults().getIOS(); + List iosEntityList = gankDayBean.getResults().getIOS(); if (iosEntityList != null && iosEntityList.size() > 0) { GankEntity gankEntity_title = new GankEntity(); gankEntity_title.setType("title"); @@ -122,7 +111,7 @@ private void initDatas(DayEntity dayEntity) { } - List 休息视频EntityList = dayEntity.getResults().get休息视频(); + List 休息视频EntityList = gankDayBean.getResults().get休息视频(); if (休息视频EntityList != null && 休息视频EntityList.size() > 0) { GankEntity gankEntity_title = new GankEntity(); gankEntity_title.setType("title"); @@ -132,7 +121,7 @@ private void initDatas(DayEntity dayEntity) { } - List 拓展资源EntityList = dayEntity.getResults().get拓展资源(); + List 拓展资源EntityList = gankDayBean.getResults().get拓展资源(); if (拓展资源EntityList != null && 拓展资源EntityList.size() > 0) { GankEntity gankEntity_title = new GankEntity(); gankEntity_title.setType("title"); diff --git a/app/src/main/java/com/maning/gankmm/ui/presenter/impl/HistoryPresenterImpl.java b/app/src/main/java/com/maning/gankmm/ui/presenter/impl/HistoryPresenterImpl.java index dabf014..778a736 100644 --- a/app/src/main/java/com/maning/gankmm/ui/presenter/impl/HistoryPresenterImpl.java +++ b/app/src/main/java/com/maning/gankmm/ui/presenter/impl/HistoryPresenterImpl.java @@ -1,15 +1,13 @@ package com.maning.gankmm.ui.presenter.impl; import android.content.Context; -import android.text.TextUtils; +import com.maning.gankmm.bean.gank.GankHistoryListBean; +import com.maning.gankmm.http.callback.CommonHttpCallback; import com.maning.gankmm.http.gank.GankApi; -import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.ui.iView.IHistoryView; import com.maning.gankmm.ui.presenter.IHistoryPresenter; -import java.util.List; - /** * Created by maning on 16/6/21. */ @@ -22,36 +20,27 @@ public HistoryPresenterImpl(Context context, IHistoryView iHistoryView) { attachView(iHistoryView); } - private MyCallBack httpCallBack = new MyCallBack() { - @Override - public void onSuccessList(int what, List results) { - if(mView == null){ - return; + @Override + public void getHistoryDatas() { + GankApi.getHistoryData(new CommonHttpCallback() { + @Override + public void onSuccess(GankHistoryListBean result) { + if (mView == null) { + return; + } + mView.overRefresh(); + mView.setHistoryList(result.getResults()); } - mView.overRefresh(); - mView.setHistoryList(results); - } - - @Override - public void onSuccess(int what, Object result) { - - } - @Override - public void onFail(int what, String result) { - if(mView == null){ - return; + @Override + public void onFail(int code, String message) { + if (mView == null) { + return; + } + mView.overRefresh(); + mView.showToast(message); } - mView.overRefresh(); - if (!TextUtils.isEmpty(result)) { - mView.showToast(result); - } - } - }; - - @Override - public void getHistoryDatas() { - GankApi.getHistoryData(0x001, httpCallBack); + }); } }