為了月薪1.8萬,我們要不斷地學習和總結,今天給大家帶來常見的android架構模式——mvp,非常詳細,很值得學習。
為什麼要去學習MVP,看看下面的一張圖就知道了。
1. 序言
- 實際開發中根據業務選擇合適的架構。
- 這篇部落格簡單介紹MVC模式,詳細介紹MVP模式。
- 看完這篇部落格,不會寫MVP,直接留言,我跪搓板!
2. MVC模式簡介
- M:Model:模型層:負責業務邏輯。
- V:View:檢視層:負責介面呈現
- C:Controller:控制層:負責Model與View互動。
- 簡單說:MVC就是通過Controller來操作Model層的資料,並且返回給View層展示。
3. Android中的MVC模式缺點
- Android並不是一個標準的MVC模式中的Controller,它的首要職責是載入應用的佈局和初始化使用者介面,接受並處理來自使用者的操作請求,進而做出響應。隨著介面及其邏輯的複雜度不斷提升,Activity類的職責不斷增加,以致變得龐大臃腫。
- 由於Android的Controller通常在Activity、Fragment中,所以Model和View層耦合嚴重,不易開發和維護。
4. MVP模式簡介
- M:Model:負責獲取和儲存資料。
- V:View:負責使用者事件和檢視部分的展示。
- P:Presenter:作為View和Model之間溝通的橋樑。
- 簡單說:MVP就是通過Presenter從Model層檢索資料後返回給View層。
5. Android中的MVP模式的優點
- Presenter完全將Model和View進行了分離,主要邏輯在Presenter裡實現。
6. MVP示例
6.1 新增依賴
compile 'cn.finalteam:okhttpfinal:2.0.7'
複製程式碼
6.2 初始化okhttpfinal
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
OkHttpFinalConfiguration.Builder builder = new OkHttpFinalConfiguration.Builder();
OkHttpFinal.getInstance().init(builder.build());
}
}
複製程式碼
6.3 實現Model ① 建立實體類TitleData:
public class TitleData {
/**
* reason : 成功的返回
* result : {"stat":"1","data":[{"uniquekey":"68388dafd210bd9e6e733f28f35d36d9","title":"不用去健身房的徒手健身14式!隨時讓你身體泵感飆升!","date":"2018-04-15 22:27","category":"頭條","author_name":"極限肌湯","url":"http://mini.eastday.com/mobile/180415222744706.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_9_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_15_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_14_mwpm_03200403.jpg"},{"uniquekey":"c792b6c975915e0f353e1525d74361a2","title":"王毅同日本外相河野太郎舉行會談","date":"2018-04-15 22:06","category":"頭條","author_name":"外交部新聞","url":"http://mini.eastday.com/mobile/180415220602296.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415220602_8c06c36f699b2cdb6e7fbcabe0980cb2_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415220602_8c06c36f699b2cdb6e7fbcabe0980cb2_2_mwpm_03200403.jpg"},{"uniquekey":"393182746325575e28816c7a52fcd891","title":"敘利亞遭美再轟炸證明弱小才會捱打?錯了,是內部不團結才挨的打","date":"2018-04-15 21:58","category":"頭條","author_name":"清風曉","url":"http://mini.eastday.com/mobile/180415215840462.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415_d00823627f77600d8294d9a8927b59dd_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415_454c1ef82a92a1c6ba787e763c275b89_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415_08123e1f126ec2b83ca5325ed7f0fb62_cover_mwpm_03200403.jpg"},{"uniquekey":"21a6ff821f95eb5b36783f68aeea103c","title":"今早發生飛機被劫持事件 你知道機長是如何用程式碼通知地面嗎?","date":"2018-04-15 21:57","category":"頭條","author_name":"1039航空線上","url":"http://mini.eastday.com/mobile/180415215736534.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_9bea759e1382a2b897cbb9e40d8e37fd_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_add9d74fe93e7e6c5b107aab523a6395_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_680d3e100a59ae3aa6dee89cc8b39eac_3_mwpm_03200403.jpg"},{"uniquekey":"56fb7f21b478d88d29513f84f8b6ea67","title":"未經國內授權就發動對敘打擊,英法領導人被批\u201c跟在川普後面\u201d","date":"2018-04-15 21:52","category":"頭條","author_name":"觀察者網","url":"http://mini.eastday.com/mobile/180415215211363.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_4_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_5_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_3_mwpm_03200403.jpg"},{"uniquekey":"6378cc37d7cd029989058172c115da59","title":"敘利亞被轟炸,海南被刷屏,該滿倉還是空倉?","date":"2018-04-15 21:35","category":"頭條","author_name":"澄泓財經","url":"http://mini.eastday.com/mobile/180415213527945.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_3_mwpm_03200403.jpg"},{"uniquekey":"610d5f5ae0b7649e55c2b9c4c376a49a","title":"湘雅醫院45個口腔癌患者中,44人長期大量嚼檳榔","date":"2018-04-15 21:17","category":"頭條","author_name":"澎湃新聞網","url":"http://mini.eastday.com/mobile/180415211747158.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415211747_bb6663066717047a755cf1dc406940e6_1_mwpm_03200403.jpg"},{"uniquekey":"9b264e90b08601075c184967360d11d0","title":"沙特和以色列關係逐步提升 伊朗:他們正進行聯合犯罪","date":"2018-04-15 21:13","category":"頭條","author_name":"中東研究通訊","url":"http://mini.eastday.com/mobile/180415211352158.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_4_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_5_mwpm_03200403.jpg"},{"uniquekey":"931a6c79dd80e7c66c4f07e093f56bbd","title":"印度洋島國模里西斯的華人故事:盼與中國共發展","date":"2018-04-15 21:13","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415211349598.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415211349_0166b7c8152d1f8559d9440af2f0d7b3_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415211349_0166b7c8152d1f8559d9440af2f0d7b3_1_mwpm_03200403.jpg"},{"uniquekey":"9247330c735b0659b69c57b9575853fd","title":"男子在地裡幹活,發現自家墳墓出現一個洞,裡面的景象讓他傻了眼","date":"2018-04-15 21:02","category":"頭條","author_name":"奇聞達人","url":"http://mini.eastday.com/mobile/180415210205138.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415_2f3e4f4f731ed25bb5326153f5e1f6df_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415_99ee412a06367ae94c45d5d0e7eec74e_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415_f8627d97c7d3f333233a9fa5762e43ff_cover_mwpm_03200403.jpg"},{"uniquekey":"bdc1efa1c2deff034f8e3cd8cd1d4a49","title":"瑜伽療愈身心其實很簡單 只需會呼吸就好","date":"2018-04-15 21:00","category":"頭條","author_name":"瑜伽體式精講","url":"http://mini.eastday.com/mobile/180415210010479.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415_dc6d0c014ca7a6590974ded3664f56f9_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://02.imgmini.eastday.com/mobile/20180415/20180415_98a99725b647080e302912d8895b8107_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://02.imgmini.eastday.com/mobile/20180415/20180415_6ff58e524feddd2983bd555008b9454b_cover_mwpm_03200403.jpg"},{"uniquekey":"d840acd294d7d3d7224f775b40a31f22","title":"馬雲說:2018年只要抓住這個行業 將會有大批人暴富 !","date":"2018-04-15 20:58","category":"頭條","author_name":"星座的情感巫師","url":"http://mini.eastday.com/mobile/180415205834831.html","thumbnail_pic_s":"http://05.imgmini.eastday.com/mobile/20180415/20180415_5898b55ce7882d86bb3d5d5db9110296_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://05.imgmini.eastday.com/mobile/20180415/20180415_e0c5592edf6745d7bdbdc2bfa49eee61_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://05.imgmini.eastday.com/mobile/20180415/20180415_497e816851327038a86ffb15e2c4ac7d_cover_mwpm_03200403.jpg"},{"uniquekey":"3af2890c7503ecb5ac8d6e857baca49b","title":"如何推動東北高質量發展?專家:首先多提\u201c新東北\u201d概念","date":"2018-04-15 20:57","category":"頭條","author_name":"澎湃新聞網","url":"http://mini.eastday.com/mobile/180415205719783.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415205719_e2ab1c506ddf063125e41dde1651db6d_1_mwpm_03200403.jpg"},{"uniquekey":"81c06482d6b62ebb89e24b902de05370","title":"戊戌年澳大利亞華人恭拜軒轅黃帝大典在悉尼舉行","date":"2018-04-15 20:54","category":"頭條","author_name":"人民網","url":"http://mini.eastday.com/mobile/180415205436408.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_5_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_4_mwpm_03200403.jpg"},{"uniquekey":"0f2e01526bc03873e14c7af24715f1c9","title":"南極下的雪越來越多,200年增加10%!然而這是大壞事的開始!","date":"2018-04-15 20:33","category":"頭條","author_name":"中國氣象愛好者","url":"http://mini.eastday.com/mobile/180415203300175.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_1_mwpm_03200403.jpg"},{"uniquekey":"c6d48e1ce2b07f411533f4c2e1ab336a","title":"把憲法精神融入公證實踐","date":"2018-04-15 20:31","category":"頭條","author_name":"法制網","url":"http://mini.eastday.com/mobile/180415203159176.html","thumbnail_pic_s":"http://03.imgmini.eastday.com/mobile/20180415/20180415203159_4586775d679b2a5b89662570e41bd0c0_1_mwpm_03200403.jpg"},{"uniquekey":"9a12e11575a3e258ed577e26c802bcdb","title":"解放軍新條令釋放紅利:官兵節假日值班後安排補休","date":"2018-04-15 20:27","category":"頭條","author_name":"環球網","url":"http://mini.eastday.com/mobile/180415202715963.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415202715_f7a7655284bcd56685b5b47808a3089c_1_mwpm_03200403.jpg"},{"uniquekey":"d8b3e71020284251c4e73956ccf684ae","title":"死者入土為安?印尼神祕村莊人死後十年依然吃飯洗澡,堪稱活死人","date":"2018-04-15 20:26","category":"頭條","author_name":"格林憋悶ss","url":"http://mini.eastday.com/mobile/180415202626177.html","thumbnail_pic_s":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_3_mwpm_03200403.jpg","thumbnail_pic_s03":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_2_mwpm_03200403.jpg"},{"uniquekey":"f3d228eecfd4793f166e79914ad92374","title":"想要豐胸和瘦臂卻做不了俯臥撐?試試這六個動作吧!","date":"2018-04-15 20:25","category":"頭條","author_name":"豐胸導師_曉雨","url":"http://mini.eastday.com/mobile/180415202535878.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_6_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_1_mwpm_03200403.jpg"},{"uniquekey":"8a909ff6fd43d4e092eabd5e5576cafe","title":"如何續寫\u201c來了就不想走\u201d的海南故事? | 銳評","date":"2018-04-15 20:24","category":"頭條","author_name":"人民日報","url":"http://mini.eastday.com/mobile/180415202409259.html","thumbnail_pic_s":"http://03.imgmini.eastday.com/mobile/20180415/20180415202409_db2bf6b3f75b110448a65f9d1bc83659_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://03.imgmini.eastday.com/mobile/20180415/20180415202409_db2bf6b3f75b110448a65f9d1bc83659_2_mwpm_03200403.jpg"},{"uniquekey":"86bb5027d938238d8606c6d1c1740e52","title":"70%成功攔截率 俄羅斯和美國到底誰在說謊?現實讓該國打臉","date":"2018-04-15 20:20","category":"頭條","author_name":"火線前沿","url":"http://mini.eastday.com/mobile/180415202013958.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415_6532706a61497aa32b70eddd8bcb3962_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415_0928e06e8a0fcfcb3c1ed05032772c53_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415_d57856f7e01bfa71ab29e0ee3145fa07_cover_mwpm_03200403.jpg"},{"uniquekey":"3f42a0b047d6ab4870eca9d18c5b1ecf","title":"無燒烤,不夏天!這些才是成都燒烤界的扛把子!","date":"2018-04-15 20:19","category":"頭條","author_name":"成都生活圈","url":"http://mini.eastday.com/mobile/180415201933928.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_28_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_12_mwpm_03200403.jpg","thumbnail_pic_s03":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_66_mwpm_03200403.jpg"},{"uniquekey":"949c8738919d784b49c9ced4a426a14c","title":"林鄭月娥:香港具備條件成為創科樞紐","date":"2018-04-15 20:18","category":"頭條","author_name":"國際線上","url":"http://mini.eastday.com/mobile/180415201853732.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_3_mwpm_03200403.jpg"},{"uniquekey":"6e405694c1e5d4ee4c9bdcf36d7891c6","title":"澳大利亞將中國妖魔化企圖沒有成功,反而讓更多的國家理解中國!","date":"2018-04-15 20:13","category":"頭條","author_name":"環球新聞","url":"http://mini.eastday.com/mobile/180415201358006.html","thumbnail_pic_s":"http://04.imgmini.eastday.com/mobile/20180415/20180415201358_7174cd1b5a28c3bf37cf12719f935f61_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://04.imgmini.eastday.com/mobile/20180415/20180415201358_7174cd1b5a28c3bf37cf12719f935f61_2_mwpm_03200403.jpg"},{"uniquekey":"1932da294e569b5177b5013593a2b7d7","title":"第十二屆河南投洽會邀海內外客商近兩萬人 突出國際性","date":"2018-04-15 20:12","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415201258277.html","thumbnail_pic_s":"http://07.imgmini.eastday.com/mobile/20180415/20180415201258_25ee36c89b0b8c28d55f373e3c4f0783_1_mwpm_03200403.jpg"},{"uniquekey":"1b1b2d050ed24ce7804fb19db5fec1bc","title":"第八屆北京電影節開幕 紅毯儀式星光熠熠","date":"2018-04-15 20:12","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415201257389.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_8_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_5_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_6_mwpm_03200403.jpg"},{"uniquekey":"86d60fe3db18a77f00d3f58f5fe6aa52","title":"\u201c幼升小\u201d公民同招,受\u201c新中考\u201d引導,今年校園開放日家長日趨理性","date":"2018-04-15 20:08","category":"頭條","author_name":"解放網","url":"http://mini.eastday.com/mobile/180415200807125.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_2_mwpm_03200403.jpg"},{"uniquekey":"f570d395e734c3a81a9c02cbbad5b36d","title":"安倍晉三隱忍多年,未能擺脫\u201c綠帽子\u201d頭銜,如今終於決定離婚!","date":"2018-04-15 20:05","category":"頭條","author_name":"戰魂不息","url":"http://mini.eastday.com/mobile/180415200557521.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415_de26aaf0831973b0e0341f26b4aff3d4_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415_c9d9ea6863bb00bce5ae429236991b58_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://09.imgmini.eastday.com/mobile/20180415/20180415_54a1150e82fcd52b6e950ad3c8353794_cover_mwpm_03200403.jpg"},{"uniquekey":"99e3626c3f70b4b99c094be3613364cb","title":"金正恩在平壤會見中國藝術團團長宋濤","date":"2018-04-15 20:04","category":"頭條","author_name":"央視網","url":"http://mini.eastday.com/mobile/180415200405028.html","thumbnail_pic_s":"http://01.imgmini.eastday.com/mobile/20180415/20180415200405_b738aea415821905d6a3165d74490caa_1_mwpm_03200403.jpg"},{"uniquekey":"65e0297026cbefe2a2a38d720393372d","title":"【中國夢·大國工匠篇】精益求精勤鑽研,匠人精神塑楷模","date":"2018-04-15 20:03","category":"頭條","author_name":"中國日報網","url":"http://mini.eastday.com/mobile/180415200354400.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415200354_d686eba1caaf4314de166fcfe22e1898_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415200354_d686eba1caaf4314de166fcfe22e1898_1_mwpm_03200403.jpg"}]}
* error_code : 0
*/
private String reason;
private ResultBean result;
private int error_code;
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public int getError_code() {
return error_code;
}
public void setError_code(int error_code) {
this.error_code = error_code;
}
public static class ResultBean {
/**
* stat : 1
* data : [{"uniquekey":"68388dafd210bd9e6e733f28f35d36d9","title":"不用去健身房的徒手健身14式!隨時讓你身體泵感飆升!","date":"2018-04-15 22:27","category":"頭條","author_name":"極限肌湯","url":"http://mini.eastday.com/mobile/180415222744706.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_9_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_15_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_14_mwpm_03200403.jpg"},{"uniquekey":"c792b6c975915e0f353e1525d74361a2","title":"王毅同日本外相河野太郎舉行會談","date":"2018-04-15 22:06","category":"頭條","author_name":"外交部新聞","url":"http://mini.eastday.com/mobile/180415220602296.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415220602_8c06c36f699b2cdb6e7fbcabe0980cb2_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415220602_8c06c36f699b2cdb6e7fbcabe0980cb2_2_mwpm_03200403.jpg"},{"uniquekey":"393182746325575e28816c7a52fcd891","title":"敘利亞遭美再轟炸證明弱小才會捱打?錯了,是內部不團結才挨的打","date":"2018-04-15 21:58","category":"頭條","author_name":"清風曉","url":"http://mini.eastday.com/mobile/180415215840462.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415_d00823627f77600d8294d9a8927b59dd_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415_454c1ef82a92a1c6ba787e763c275b89_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415_08123e1f126ec2b83ca5325ed7f0fb62_cover_mwpm_03200403.jpg"},{"uniquekey":"21a6ff821f95eb5b36783f68aeea103c","title":"今早發生飛機被劫持事件 你知道機長是如何用程式碼通知地面嗎?","date":"2018-04-15 21:57","category":"頭條","author_name":"1039航空線上","url":"http://mini.eastday.com/mobile/180415215736534.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_9bea759e1382a2b897cbb9e40d8e37fd_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_add9d74fe93e7e6c5b107aab523a6395_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415215736_680d3e100a59ae3aa6dee89cc8b39eac_3_mwpm_03200403.jpg"},{"uniquekey":"56fb7f21b478d88d29513f84f8b6ea67","title":"未經國內授權就發動對敘打擊,英法領導人被批\u201c跟在川普後面\u201d","date":"2018-04-15 21:52","category":"頭條","author_name":"觀察者網","url":"http://mini.eastday.com/mobile/180415215211363.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_4_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_5_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415215211_05ec6bcc67f0f14bb72cb6f6fe4f5b9e_3_mwpm_03200403.jpg"},{"uniquekey":"6378cc37d7cd029989058172c115da59","title":"敘利亞被轟炸,海南被刷屏,該滿倉還是空倉?","date":"2018-04-15 21:35","category":"頭條","author_name":"澄泓財經","url":"http://mini.eastday.com/mobile/180415213527945.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://02.imgmini.eastday.com/mobile/20180415/20180415213527_456b2a35bbbe09f2a1e48d65556b591b_3_mwpm_03200403.jpg"},{"uniquekey":"610d5f5ae0b7649e55c2b9c4c376a49a","title":"湘雅醫院45個口腔癌患者中,44人長期大量嚼檳榔","date":"2018-04-15 21:17","category":"頭條","author_name":"澎湃新聞網","url":"http://mini.eastday.com/mobile/180415211747158.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415211747_bb6663066717047a755cf1dc406940e6_1_mwpm_03200403.jpg"},{"uniquekey":"9b264e90b08601075c184967360d11d0","title":"沙特和以色列關係逐步提升 伊朗:他們正進行聯合犯罪","date":"2018-04-15 21:13","category":"頭條","author_name":"中東研究通訊","url":"http://mini.eastday.com/mobile/180415211352158.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_4_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415211352_85311a103046811efbf4b604d63ff949_5_mwpm_03200403.jpg"},{"uniquekey":"931a6c79dd80e7c66c4f07e093f56bbd","title":"印度洋島國模里西斯的華人故事:盼與中國共發展","date":"2018-04-15 21:13","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415211349598.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415211349_0166b7c8152d1f8559d9440af2f0d7b3_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415211349_0166b7c8152d1f8559d9440af2f0d7b3_1_mwpm_03200403.jpg"},{"uniquekey":"9247330c735b0659b69c57b9575853fd","title":"男子在地裡幹活,發現自家墳墓出現一個洞,裡面的景象讓他傻了眼","date":"2018-04-15 21:02","category":"頭條","author_name":"奇聞達人","url":"http://mini.eastday.com/mobile/180415210205138.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415_2f3e4f4f731ed25bb5326153f5e1f6df_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415_99ee412a06367ae94c45d5d0e7eec74e_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415_f8627d97c7d3f333233a9fa5762e43ff_cover_mwpm_03200403.jpg"},{"uniquekey":"bdc1efa1c2deff034f8e3cd8cd1d4a49","title":"瑜伽療愈身心其實很簡單 只需會呼吸就好","date":"2018-04-15 21:00","category":"頭條","author_name":"瑜伽體式精講","url":"http://mini.eastday.com/mobile/180415210010479.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415_dc6d0c014ca7a6590974ded3664f56f9_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://02.imgmini.eastday.com/mobile/20180415/20180415_98a99725b647080e302912d8895b8107_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://02.imgmini.eastday.com/mobile/20180415/20180415_6ff58e524feddd2983bd555008b9454b_cover_mwpm_03200403.jpg"},{"uniquekey":"d840acd294d7d3d7224f775b40a31f22","title":"馬雲說:2018年只要抓住這個行業 將會有大批人暴富 !","date":"2018-04-15 20:58","category":"頭條","author_name":"星座的情感巫師","url":"http://mini.eastday.com/mobile/180415205834831.html","thumbnail_pic_s":"http://05.imgmini.eastday.com/mobile/20180415/20180415_5898b55ce7882d86bb3d5d5db9110296_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://05.imgmini.eastday.com/mobile/20180415/20180415_e0c5592edf6745d7bdbdc2bfa49eee61_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://05.imgmini.eastday.com/mobile/20180415/20180415_497e816851327038a86ffb15e2c4ac7d_cover_mwpm_03200403.jpg"},{"uniquekey":"3af2890c7503ecb5ac8d6e857baca49b","title":"如何推動東北高質量發展?專家:首先多提\u201c新東北\u201d概念","date":"2018-04-15 20:57","category":"頭條","author_name":"澎湃新聞網","url":"http://mini.eastday.com/mobile/180415205719783.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415205719_e2ab1c506ddf063125e41dde1651db6d_1_mwpm_03200403.jpg"},{"uniquekey":"81c06482d6b62ebb89e24b902de05370","title":"戊戌年澳大利亞華人恭拜軒轅黃帝大典在悉尼舉行","date":"2018-04-15 20:54","category":"頭條","author_name":"人民網","url":"http://mini.eastday.com/mobile/180415205436408.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_5_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415205436_53b5c2ea3edef971d0e9edaf373b6875_4_mwpm_03200403.jpg"},{"uniquekey":"0f2e01526bc03873e14c7af24715f1c9","title":"南極下的雪越來越多,200年增加10%!然而這是大壞事的開始!","date":"2018-04-15 20:33","category":"頭條","author_name":"中國氣象愛好者","url":"http://mini.eastday.com/mobile/180415203300175.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415203300_eebd0303e57d1ffda38264ca0ad9527f_1_mwpm_03200403.jpg"},{"uniquekey":"c6d48e1ce2b07f411533f4c2e1ab336a","title":"把憲法精神融入公證實踐","date":"2018-04-15 20:31","category":"頭條","author_name":"法制網","url":"http://mini.eastday.com/mobile/180415203159176.html","thumbnail_pic_s":"http://03.imgmini.eastday.com/mobile/20180415/20180415203159_4586775d679b2a5b89662570e41bd0c0_1_mwpm_03200403.jpg"},{"uniquekey":"9a12e11575a3e258ed577e26c802bcdb","title":"解放軍新條令釋放紅利:官兵節假日值班後安排補休","date":"2018-04-15 20:27","category":"頭條","author_name":"環球網","url":"http://mini.eastday.com/mobile/180415202715963.html","thumbnail_pic_s":"http://02.imgmini.eastday.com/mobile/20180415/20180415202715_f7a7655284bcd56685b5b47808a3089c_1_mwpm_03200403.jpg"},{"uniquekey":"d8b3e71020284251c4e73956ccf684ae","title":"死者入土為安?印尼神祕村莊人死後十年依然吃飯洗澡,堪稱活死人","date":"2018-04-15 20:26","category":"頭條","author_name":"格林憋悶ss","url":"http://mini.eastday.com/mobile/180415202626177.html","thumbnail_pic_s":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_3_mwpm_03200403.jpg","thumbnail_pic_s03":"http://04.imgmini.eastday.com/mobile/20180415/20180415202626_54722af09b478d592ad7301984a63444_2_mwpm_03200403.jpg"},{"uniquekey":"f3d228eecfd4793f166e79914ad92374","title":"想要豐胸和瘦臂卻做不了俯臥撐?試試這六個動作吧!","date":"2018-04-15 20:25","category":"頭條","author_name":"豐胸導師_曉雨","url":"http://mini.eastday.com/mobile/180415202535878.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_6_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_2_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415202535_a42e5527a457894d2a6f4f7db9625096_1_mwpm_03200403.jpg"},{"uniquekey":"8a909ff6fd43d4e092eabd5e5576cafe","title":"如何續寫\u201c來了就不想走\u201d的海南故事? | 銳評","date":"2018-04-15 20:24","category":"頭條","author_name":"人民日報","url":"http://mini.eastday.com/mobile/180415202409259.html","thumbnail_pic_s":"http://03.imgmini.eastday.com/mobile/20180415/20180415202409_db2bf6b3f75b110448a65f9d1bc83659_1_mwpm_03200403.jpg","thumbnail_pic_s02":"http://03.imgmini.eastday.com/mobile/20180415/20180415202409_db2bf6b3f75b110448a65f9d1bc83659_2_mwpm_03200403.jpg"},{"uniquekey":"86bb5027d938238d8606c6d1c1740e52","title":"70%成功攔截率 俄羅斯和美國到底誰在說謊?現實讓該國打臉","date":"2018-04-15 20:20","category":"頭條","author_name":"火線前沿","url":"http://mini.eastday.com/mobile/180415202013958.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415_6532706a61497aa32b70eddd8bcb3962_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415_0928e06e8a0fcfcb3c1ed05032772c53_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415_d57856f7e01bfa71ab29e0ee3145fa07_cover_mwpm_03200403.jpg"},{"uniquekey":"3f42a0b047d6ab4870eca9d18c5b1ecf","title":"無燒烤,不夏天!這些才是成都燒烤界的扛把子!","date":"2018-04-15 20:19","category":"頭條","author_name":"成都生活圈","url":"http://mini.eastday.com/mobile/180415201933928.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_28_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_12_mwpm_03200403.jpg","thumbnail_pic_s03":"http://09.imgmini.eastday.com/mobile/20180415/20180415201933_ad77866ffc53dd21f26db58b0c7af8c2_66_mwpm_03200403.jpg"},{"uniquekey":"949c8738919d784b49c9ced4a426a14c","title":"林鄭月娥:香港具備條件成為創科樞紐","date":"2018-04-15 20:18","category":"頭條","author_name":"國際線上","url":"http://mini.eastday.com/mobile/180415201853732.html","thumbnail_pic_s":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://08.imgmini.eastday.com/mobile/20180415/20180415201853_1a2a3e54aea6c551f4d2e617a7574fd4_3_mwpm_03200403.jpg"},{"uniquekey":"6e405694c1e5d4ee4c9bdcf36d7891c6","title":"澳大利亞將中國妖魔化企圖沒有成功,反而讓更多的國家理解中國!","date":"2018-04-15 20:13","category":"頭條","author_name":"環球新聞","url":"http://mini.eastday.com/mobile/180415201358006.html","thumbnail_pic_s":"http://04.imgmini.eastday.com/mobile/20180415/20180415201358_7174cd1b5a28c3bf37cf12719f935f61_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://04.imgmini.eastday.com/mobile/20180415/20180415201358_7174cd1b5a28c3bf37cf12719f935f61_2_mwpm_03200403.jpg"},{"uniquekey":"1932da294e569b5177b5013593a2b7d7","title":"第十二屆河南投洽會邀海內外客商近兩萬人 突出國際性","date":"2018-04-15 20:12","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415201258277.html","thumbnail_pic_s":"http://07.imgmini.eastday.com/mobile/20180415/20180415201258_25ee36c89b0b8c28d55f373e3c4f0783_1_mwpm_03200403.jpg"},{"uniquekey":"1b1b2d050ed24ce7804fb19db5fec1bc","title":"第八屆北京電影節開幕 紅毯儀式星光熠熠","date":"2018-04-15 20:12","category":"頭條","author_name":"中國新聞網","url":"http://mini.eastday.com/mobile/180415201257389.html","thumbnail_pic_s":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_8_mwpm_03200403.jpg","thumbnail_pic_s02":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_5_mwpm_03200403.jpg","thumbnail_pic_s03":"http://00.imgmini.eastday.com/mobile/20180415/20180415201257_5e767f1c848445b38a961be448891242_6_mwpm_03200403.jpg"},{"uniquekey":"86d60fe3db18a77f00d3f58f5fe6aa52","title":"\u201c幼升小\u201d公民同招,受\u201c新中考\u201d引導,今年校園開放日家長日趨理性","date":"2018-04-15 20:08","category":"頭條","author_name":"解放網","url":"http://mini.eastday.com/mobile/180415200807125.html","thumbnail_pic_s":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_3_mwpm_03200403.jpg","thumbnail_pic_s02":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_1_mwpm_03200403.jpg","thumbnail_pic_s03":"http://06.imgmini.eastday.com/mobile/20180415/20180415200807_c093b191b7c42d8b61123396c93cc872_2_mwpm_03200403.jpg"},{"uniquekey":"f570d395e734c3a81a9c02cbbad5b36d","title":"安倍晉三隱忍多年,未能擺脫\u201c綠帽子\u201d頭銜,如今終於決定離婚!","date":"2018-04-15 20:05","category":"頭條","author_name":"戰魂不息","url":"http://mini.eastday.com/mobile/180415200557521.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415_de26aaf0831973b0e0341f26b4aff3d4_cover_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415_c9d9ea6863bb00bce5ae429236991b58_cover_mwpm_03200403.jpg","thumbnail_pic_s03":"http://09.imgmini.eastday.com/mobile/20180415/20180415_54a1150e82fcd52b6e950ad3c8353794_cover_mwpm_03200403.jpg"},{"uniquekey":"99e3626c3f70b4b99c094be3613364cb","title":"金正恩在平壤會見中國藝術團團長宋濤","date":"2018-04-15 20:04","category":"頭條","author_name":"央視網","url":"http://mini.eastday.com/mobile/180415200405028.html","thumbnail_pic_s":"http://01.imgmini.eastday.com/mobile/20180415/20180415200405_b738aea415821905d6a3165d74490caa_1_mwpm_03200403.jpg"},{"uniquekey":"65e0297026cbefe2a2a38d720393372d","title":"【中國夢·大國工匠篇】精益求精勤鑽研,匠人精神塑楷模","date":"2018-04-15 20:03","category":"頭條","author_name":"中國日報網","url":"http://mini.eastday.com/mobile/180415200354400.html","thumbnail_pic_s":"http://09.imgmini.eastday.com/mobile/20180415/20180415200354_d686eba1caaf4314de166fcfe22e1898_2_mwpm_03200403.jpg","thumbnail_pic_s02":"http://09.imgmini.eastday.com/mobile/20180415/20180415200354_d686eba1caaf4314de166fcfe22e1898_1_mwpm_03200403.jpg"}]
*/
private String stat;
private List<DataBean> data;
public String getStat() {
return stat;
}
public void setStat(String stat) {
this.stat = stat;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* uniquekey : 68388dafd210bd9e6e733f28f35d36d9
* title : 不用去健身房的徒手健身14式!隨時讓你身體泵感飆升!
* date : 2018-04-15 22:27
* category : 頭條
* author_name : 極限肌湯
* url : http://mini.eastday.com/mobile/180415222744706.html
* thumbnail_pic_s : http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_9_mwpm_03200403.jpg
* thumbnail_pic_s02 : http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_15_mwpm_03200403.jpg
* thumbnail_pic_s03 : http://06.imgmini.eastday.com/mobile/20180415/20180415222744_1f0504d02a116dbd1c1b2e25c4038b5a_14_mwpm_03200403.jpg
*/
private String uniquekey;
private String title;
private String date;
private String category;
private String author_name;
private String url;
private String thumbnail_pic_s;
private String thumbnail_pic_s02;
private String thumbnail_pic_s03;
public String getUniquekey() {
return uniquekey;
}
public void setUniquekey(String uniquekey) {
this.uniquekey = uniquekey;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getAuthor_name() {
return author_name;
}
public void setAuthor_name(String author_name) {
this.author_name = author_name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getThumbnail_pic_s() {
return thumbnail_pic_s;
}
public void setThumbnail_pic_s(String thumbnail_pic_s) {
this.thumbnail_pic_s = thumbnail_pic_s;
}
public String getThumbnail_pic_s02() {
return thumbnail_pic_s02;
}
public void setThumbnail_pic_s02(String thumbnail_pic_s02) {
this.thumbnail_pic_s02 = thumbnail_pic_s02;
}
public String getThumbnail_pic_s03() {
return thumbnail_pic_s03;
}
public void setThumbnail_pic_s03(String thumbnail_pic_s03) {
this.thumbnail_pic_s03 = thumbnail_pic_s03;
}
}
}
}
複製程式碼
② 定義網路監聽回撥介面
public interface LoadTasksCallBack<T> {
void onStart();
void onFinish();
void onSuccess(T t);
void onFailed();
}
複製程式碼
③ 定義獲取網路資料的介面類
public interface NetTask<T> {
void execute(T data,LoadTasksCallBack callBack);
}
複製程式碼
④ 編寫NetTask的實現類以獲取資料
public class IpInfoTask implements NetTask<String> {
private IpInfoTask() {
}
public static IpInfoTask getInstance() {
return SingletonHolder.sInstance;
}
private static class SingletonHolder {
private static final IpInfoTask sInstance = new IpInfoTask();
}
@Override
public void execute(final String url, final LoadTasksCallBack callBack) {
HttpRequest.get(url, new BaseHttpRequestCallback<TitleData>() {
@Override
public void onStart() {
super.onStart();
callBack.onStart();
}
@Override
protected void onSuccess(TitleData ipInfo) {
super.onSuccess(ipInfo);
callBack.onSuccess(ipInfo);
}
@Override
public void onFinish() {
super.onFinish();
callBack.onFinish();
}
@Override
public void onFailure(int errorCode, String msg) {
super.onFailure(errorCode, msg);
callBack.onFailed();
}
});
}
}
複製程式碼
說明:IpInfoTask是一個單例類,在execute方法中通過okhttpfinal獲取資料,同時在okhttpfinal的回撥函式中呼叫自己定義的回撥函式loadTasksCallBack。
6.4 實現Presenter ① 定義契約介面IpInfoContract
public interface IpInfoContract {
interface Presenter {
void getIpInfo(String url);
}
interface View extends BaseView<Presenter> {
void setIpInfo(TitleData ipData);
void showLoading();
void hideLoading();
void showError();
boolean isActivie();
}
}
複製程式碼
說明:
- 契約介面主要用來存放相同業務的Presenter和View的介面,便於查詢和維護。
- 在此看到Presenter介面定義了獲取資料的方法,而View定義了與介面互動的方法。其中,isActive方法用於判斷Fragment是否新增到了Activity中。
- 另外:View介面繼承自BaseView介面,BaseView介面的目的就是給View繫結Presenter:
public interface BaseView<T> {
void setPresenter(T presenter);
}
複製程式碼
② 實現Presenter介面:
public class IpInfoPresenter implements IpInfoContract.Presenter, LoadTasksCallBack<IpInfo> {
private NetTask mNetTask;
private IpInfoContract.View mAddTaskView;
public IpInfoPresenter(NetTask netTask, IpInfoContract.View addTaskView) {
mNetTask = netTask;
mAddTaskView = addTaskView;
}
@Override
public void onStart() {
if (mAddTaskView.isActivie()) {
mAddTaskView.showLoading();
}
}
@Override
public void onFinish() {
if (mAddTaskView.isActivie()) {
mAddTaskView.hideLoading();
}
}
@Override
public void onSuccess(IpInfo ipInfo) {
if (mAddTaskView.isActivie()) {
mAddTaskView.setIpInfo(ipInfo);
}
}
@Override
public void onFailed() {
if (mAddTaskView.isActivie()) {
mAddTaskView.showError();
mAddTaskView.hideLoading();
}
}
@Override
public void getIpInfo(String ip) {
mNetTask.execute(ip, this);
}
}
複製程式碼
說明:
- IpInfoPresenter中含有NetTask和InfoContract.View的例項,並且實現了LoadTasksCallBack介面。
- mNetTask.execute(ip, this)這句話用於獲取資料並且回撥給InInfoPresenter,回撥給InInfoPresenter後通過mAddTaskView和頁面進行互動,更改介面。
實質:
- Presenter實際就是一箇中間人,它通過NetTask(Model層)獲取和儲存資料,然後通過View更新介面。
- 期間通過定義介面使得View和Model沒有任何互動。
6.5 實現View
public class IpInfoFragment extends Fragment implements IpInfoContract.View {
private Button mBt_ipinfo;
private TextView mNews;
private ProgressDialog mProgressDialog;
private IpInfoContract.Presenter mPresenter;
private static final String URL = "http://v.juhe.cn/toutiao/index?type=top&key=cc651913ae067cf88c7d9ec710fe5b3a";
public static IpInfoFragment newInstance() {
return new IpInfoFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_ipinfo, container, false);
mNews = (TextView) root.findViewById(R.id.tv_news);
mBt_ipinfo = (Button) root.findViewById(R.id.bt_ipinfo);
return root;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mProgressDialog = new ProgressDialog(getActivity());
mProgressDialog.setTitle("獲取資料中");
mBt_ipinfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.getIpInfo(URL);
}
});
}
@Override
public void setPresenter(IpInfoContract.Presenter presenter) {
mPresenter = presenter;
}
@Override
public void setIpInfo(TitleData ipInfo) {
if (ipInfo != null && ipInfo.getResult().getData() != null) {
List<TitleData.ResultBean.DataBean> data = ipInfo.getResult().getData();
mNews.setText(data.get(0).getTitle());
}
}
@Override
public void showLoading() {
mProgressDialog.show();
}
@Override
public void hideLoading() {
if (mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
@Override
public void showError() {
Toast.makeText(getActivity(), "網路出錯", Toast.LENGTH_SHORT).show();
}
@Override
public boolean isActivie() {
return isAdded();
}
}
複製程式碼
說明:
- setPresenter方法注入IpInfoPresenter。
- getIpInfo方法獲取ip地址的資訊:也就是呼叫presenter。
- fragment實現了view介面,用來接收IpinfoPresenter的回撥並更新介面。
6.6 Activity中的setPresenter
- 把IpInfoTask(Model)和Fragment(View)注入到Presenter.
- 通過setPresenter將Presenter注入Fragment
public class MainActivity extends AppCompatActivity {
private IpInfoPresenter ipInfoPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 把Fragment新增到Activity中
IpInfoFragment ipInfoFragment = (IpInfoFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
if (ipInfoFragment == null) {
ipInfoFragment = IpInfoFragment.newInstance();
ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), ipInfoFragment, R.id.contentFrame);
}
// 把Model和View注入Presenter,並且把Presenter注入Fragment
IpInfoTask ipInfoTask = IpInfoTask.getInstance();
ipInfoPresenter = new IpInfoPresenter(ipInfoTask, ipInfoFragment);
ipInfoFragment.setPresenter(ipInfoPresenter);
}
}
複製程式碼
public class ActivityUtils {
public static void addFragmentToActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(frameId, fragment);
fragmentTransaction.commit();
}
}
複製程式碼
6.6. 總結
- View和Model之間沒有聯絡。
- View和Presenter通過介面進行互動。
- 在Activity中Presenter和View相互注入。
7. 下載地址(歡迎Star)
8. 後續
如果大家喜歡這篇文章,歡迎點贊;如果想看更多前端移動端後端Java或Python方面的技術,歡迎關注!