In order to earn 18,000 yuan a month, we will continue to learn and summarize, today to bring you a common Android architecture model — MVP, very detailed, it is worth learning.

Take a look at the chart below to see why you should study MVP.

1. Preface

  • Choose the appropriate architecture according to the business in the actual development.
  • This blog post is a brief introduction to the MVC pattern and a detailed introduction to the MVP pattern.
  • After reading this blog, I will not write MVP, direct message, I kneel washboard!

2. Introduction to MVC pattern

  • M:Model layer: Responsible for business logic.
  • V:View layer: responsible for interface presentation
  • C:Controller: control layer: responsible for interaction between Model and View.
  • To put it simply: MVC is to manipulate the data of the Model layer through the Controller and return it to the View layer for display.

3. Disadvantages of MVC pattern in Android

  • Android is not a Controller in the standard MVC pattern. Its primary responsibility is to load the application layout and initialize the user interface, accept and process operation requests from users, and then respond. As the complexity of the interface and its logic increases, the responsibilities of the Activity class increase and become large and bloated.
  • Because Android Controller is usually in Activity and Fragment, the coupling between Model and View layer is serious and difficult to develop and maintain.

4. Introduction to MVP mode

  • M:Model: Obtains and stores data.
  • V:View: display user events and views.
  • P:Presenter: Serves as a bridge between View and Model.
  • To put it simply: The MVP retrieves data from the Model layer via Presenter and returns it to the View layer.

5. Advantages of MVP mode in Android

  • Presenters completely separate the Model from the View, and the main logic is implemented in the Presenter.

6. The MVP example

6.1 Adding a Dependency

compile 'cn. Finalteam: okhttpfinal: 2.0.7'

Copy the code

6.2 Initializing OkHttpFinal

public class App extends Application {
    @Override
    public void onCreate() { super.onCreate(); OkHttpFinalConfiguration.Builder builder = new OkHttpFinalConfiguration.Builder(); OkHttpFinal.getInstance().init(builder.build()); }}Copy the code

TitleData (TitleData)

Public class TitleData {/** * reason: successful return * result: {"stat":"1"."data": [{"uniquekey":"68388dafd210bd9e6e733f28f35d36d9"."title":"Hands-free fitness 14 without going to the gym! Keep your body pumping!"."date":"The 2018-04-15 ends"."category":"Headline"."author_name":"Extreme muscle soup."."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":"Wang Yi holds talks with Japanese Foreign Minister Taro Kono"."date":"The 2018-04-15 22:06"."category":"Headline"."author_name":"Foreign Ministry News"."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":"Syria being bombed again by the US proves weak? No, it was internal disunity that caused the beating."."date":"The 2018-04-15 21:58"."category":"Headline"."author_name":"The Breeze knows"."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":"Do you know how the captain used a code to inform the ground about the hijacking this morning?"."date":"The 2018-04-15 21:57"."category":"Headline"."author_name":"1039 Aviation Online"."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":"British and French leaders criticised for launching strike on Syria without domestic authorisation \ U201C following Trump \ U201d"."date":"The 2018-04-15 21:52"."category":"Headline"."author_name":Watcher."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":"Syria is bombed, Hainan is flooded, full or empty?"."date":"2018-04-15" "."category":"Headline"."author_name":"Cheng Hong Finance"."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":"Among 45 patients with oral cancer in Xiangya Hospital, 44 chewed areca nut for a long time."."date":"The 2018-04-15 he"."category":"Headline"."author_name":"The Paper"."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":"Saudi-israeli relations escalate Iran: They're engaging in joint crime."."date":"And 2018-04-15"."category":"Headline"."author_name":Middle East Studies Newsletter."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":"The Story of the Chinese in Mauritius: Looking forward to Co-development with China"."date":"And 2018-04-15"."category":"Headline"."author_name":"China News Network"."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":"A man was working in the fields when he found a hole in his grave, and the sight inside stunned him."."date":"The 2018-04-15 21:02"."category":"Headline"."author_name":"The Amazing Story."."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":"Yoga healing the body and mind is as simple as breathing."."date":"At about the 2018-04-15"."category":"Headline"."author_name":"Introduction to Yoga Asanas."."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":"Jack Ma said: in 2018 as long as seize this industry will be a large number of people suddenly rich!"."date":"The 2018-04-15 20:58"."category":"Headline"."author_name":"The emotional wizard of the Constellations."."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":"How to promote high-quality development in Northeast China? Expert: First of all, the concept of \ U201C new Northeast \ U201D"."date":"The 2018-04-15 20:57"."category":"Headline"."author_name":"The Paper"."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":"A hundred Days' Worship of the Yellow Emperor by Chinese Australians held in Sydney"."date":"The 2018-04-15 20:54"."category":"Headline"."author_name":People's Daily Online."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":"More and more snow is falling in Antarctica, 10% more in 200 years! But this is the beginning of something bad!"."date":"The 2018-04-15 directed"."category":"Headline"."author_name":"Weather Lovers of China"."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":"To integrate the spirit of the Constitution into notarial practice."."date":"And 2018-04-15"."category":"Headline"."author_name":"Legal Network"."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":"New PLA rules to release bonus: officers and soldiers to take compensatory leave after holiday duty"."date":"The 2018-04-15 children"."category":"Headline"."author_name":"World wide web"."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":"Bury the dead? Mystery Village in Indonesia still eats and showers 10 years after death, living dead"."date":"The 2018-04-15 strip"."category":"Headline"."author_name":"Grimm stifling 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":"Want bigger breasts and slimmer arms but can't do push-ups? Try these six moves!"."date":Rose "2018-04-15"."category":"Headline"."author_name":"Breast Enhancement Tutor _ Xiao Yu"."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":"How to continue the hainan story of \ U201C coming and not wanting to leave \ U201D? | sharp comments"."date":"The 2018-04-15 May flee"."category":"Headline"."author_name":"People's Daily"."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":"Who is lying, Russia or the United States? Reality has made the country face up."."date":"The 2018-04-15 he"."category":"Headline"."author_name":"The Front of the Line"."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":"No barbecue, no summer! These are the leaders of chengdu barbecue industry!"."date":"The 2018-04-15 sons of"."category":"Headline"."author_name":"Chengdu Life Circle"."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":"Carrie Lam: Hong Kong is Ready to become an innovation hub"."date":"The 2018-04-15 formerly"."category":"Headline"."author_name":"International Online"."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":"Australia's attempt to demonise China did not succeed, but made more countries understand China!"."date":"The 2018-04-15 were"."category":"Headline"."author_name":"Global News"."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":"The 12th Henan Cifit invites nearly 20,000 merchants from home and abroad to highlight the international scene"."date":"The 2018-04-15 through the"."category":"Headline"."author_name":"China News Network"."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":"8th Beijing Film Festival opens with star studded red carpet ceremony"."date":"The 2018-04-15 through the"."category":"Headline"."author_name":"China News Network"."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 children rise to young students, U201D citizens with the same enrollment, guided by u201C new High School entrance examination, U201D parents are becoming more rational this year."."date":"The 2018-04-15 20:08"."category":"Headline"."author_name":"Liberation net"."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":"Shinzo Abe has finally decided to divorce after years of hiding behind his \ U201C cuckold title!"."date":"The 2018-04-15 20:05"."category":"Headline"."author_name":"Eternal Warrior."."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":"Kim Jong UN meets Song Tao, head of Chinese art Troupe, in Pyongyang."."date":"The 2018-04-15 20:04"."category":"Headline"."author_name":ccTV.com."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":"[Chinese Dream -- Craftsmen in a Big Country] Strive for excellence and study hard, and the spirit of craftsmen model"."date":"The 2018-04-15 20:03"."category":"Headline"."author_name":China Daily."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":"Hands-free fitness 14 without going to the gym! Keep your body pumping!"."date":"The 2018-04-15 ends"."category":"Headline"."author_name":"Extreme muscle soup."."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":"Wang Yi holds talks with Japanese Foreign Minister Taro Kono"."date":"The 2018-04-15 22:06"."category":"Headline"."author_name":"Foreign Ministry News"."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":"Syria being bombed again by the US proves weak? No, it was internal disunity that caused the beating."."date":"The 2018-04-15 21:58"."category":"Headline"."author_name":"The Breeze knows"."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":"Do you know how the captain used a code to inform the ground about the hijacking this morning?"."date":"The 2018-04-15 21:57"."category":"Headline"."author_name":"1039 Aviation Online"."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":"British and French leaders criticised for launching strike on Syria without domestic authorisation \ U201C following Trump \ U201d"."date":"The 2018-04-15 21:52"."category":"Headline"."author_name":Watcher."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":"Syria is bombed, Hainan is flooded, full or empty?"."date":"2018-04-15" "."category":"Headline"."author_name":"Cheng Hong Finance"."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":"Among 45 patients with oral cancer in Xiangya Hospital, 44 chewed areca nut for a long time."."date":"The 2018-04-15 he"."category":"Headline"."author_name":"The Paper"."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":"Saudi-israeli relations escalate Iran: They're engaging in joint crime."."date":"And 2018-04-15"."category":"Headline"."author_name":Middle East Studies Newsletter."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":"The Story of the Chinese in Mauritius: Looking forward to Co-development with China"."date":"And 2018-04-15"."category":"Headline"."author_name":"China News Network"."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":"A man was working in the fields when he found a hole in his grave, and the sight inside stunned him."."date":"The 2018-04-15 21:02"."category":"Headline"."author_name":"The Amazing Story."."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":"Yoga healing the body and mind is as simple as breathing."."date":"At about the 2018-04-15"."category":"Headline"."author_name":"Introduction to Yoga Asanas."."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":"Jack Ma said: in 2018 as long as seize this industry will be a large number of people suddenly rich!"."date":"The 2018-04-15 20:58"."category":"Headline"."author_name":"The emotional wizard of the Constellations."."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":"How to promote high-quality development in Northeast China? Expert: First of all, the concept of \ U201C new Northeast \ U201D"."date":"The 2018-04-15 20:57"."category":"Headline"."author_name":"The Paper"."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":"A hundred Days' Worship of the Yellow Emperor by Chinese Australians held in Sydney"."date":"The 2018-04-15 20:54"."category":"Headline"."author_name":People's Daily Online."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":"More and more snow is falling in Antarctica, 10% more in 200 years! But this is the beginning of something bad!"."date":"The 2018-04-15 directed"."category":"Headline"."author_name":"Weather Lovers of China"."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":"To integrate the spirit of the Constitution into notarial practice."."date":"And 2018-04-15"."category":"Headline"."author_name":"Legal Network"."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":"New PLA rules to release bonus: officers and soldiers to take compensatory leave after holiday duty"."date":"The 2018-04-15 children"."category":"Headline"."author_name":"World wide web"."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":"Bury the dead? Mystery Village in Indonesia still eats and showers 10 years after death, living dead"."date":"The 2018-04-15 strip"."category":"Headline"."author_name":"Grimm stifling 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":"Want bigger breasts and slimmer arms but can't do push-ups? Try these six moves!"."date":Rose "2018-04-15"."category":"Headline"."author_name":"Breast Enhancement Tutor _ Xiao Yu"."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":"How to continue the hainan story of \ U201C coming and not wanting to leave \ U201D? | sharp comments"."date":"The 2018-04-15 May flee"."category":"Headline"."author_name":"People's Daily"."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":"Who is lying, Russia or the United States? Reality has made the country face up."."date":"The 2018-04-15 he"."category":"Headline"."author_name":"The Front of the Line"."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":"No barbecue, no summer! These are the leaders of chengdu barbecue industry!"."date":"The 2018-04-15 sons of"."category":"Headline"."author_name":"Chengdu Life Circle"."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":"Carrie Lam: Hong Kong is Ready to become an innovation hub"."date":"The 2018-04-15 formerly"."category":"Headline"."author_name":"International Online"."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":"Australia's attempt to demonise China did not succeed, but made more countries understand China!"."date":"The 2018-04-15 were"."category":"Headline"."author_name":"Global News"."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":"The 12th Henan Cifit invites nearly 20,000 merchants from home and abroad to highlight the international scene"."date":"The 2018-04-15 through the"."category":"Headline"."author_name":"China News Network"."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":"8th Beijing Film Festival opens with star studded red carpet ceremony"."date":"The 2018-04-15 through the"."category":"Headline"."author_name":"China News Network"."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 children rise to young students, U201D citizens with the same enrollment, guided by u201C new High School entrance examination, U201D parents are becoming more rational this year."."date":"The 2018-04-15 20:08"."category":"Headline"."author_name":"Liberation net"."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":"Shinzo Abe has finally decided to divorce after years of hiding behind his \ U201C cuckold title!"."date":"The 2018-04-15 20:05"."category":"Headline"."author_name":"Eternal Warrior."."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":"Kim Jong UN meets Song Tao, head of Chinese art Troupe, in Pyongyang."."date":"The 2018-04-15 20:04"."category":"Headline"."author_name":ccTV.com."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":"[Chinese Dream -- Craftsmen in a Big Country] Strive for excellence and study hard, and the spirit of craftsmen model"."date":"The 2018-04-15 20:03"."category":"Headline"."author_name":China Daily."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: 68388 dafd210bd9e6e733f28f35d36d9 * title: don't go to the gym and unarmed fitness 14 type! Let your body pump feeling soar at any time! * date: 2018-04-15 22:27 * category: headlines * AUTHOR_name: extreme myozyme * 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 StringgetUniquekey() {
                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; }}}}Copy the code

② Define the network listening callback interface

public interface LoadTasksCallBack<T> {

    void onStart();

    void onFinish();

    void onSuccess(T t);

    void onFailed();

}

Copy the code

③ Define the interface class for obtaining network data

public interface NetTask<T> {
    void execute(T data,LoadTasksCallBack callBack);
}

Copy the code

④ Write the implementation class of NetTask to obtain data

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(); }}); }}Copy the code

IpInfoTask is a singleton class that executes data from okHttpFinal and calls loadTasksCallBack from okHttpFinal’s callback.

Implement Presenter ① Define 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(); }}Copy the code

Description:

  1. The contract interface is mainly used to store the same business of the Presenter and View interface, easy to find and maintain.
  2. Here you see that the Presenter interface defines methods to get data, and the View defines methods to interact with the interface. The isActive method is used to determine whether the Fragment is added to the Activity.
  3. The BaseView interface is used to bind a View to Presenter:
public interface BaseView<T> {
    void setPresenter(T presenter);
}

Copy the code

Implement Presenter interface:

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); }}Copy the code

Description:

  1. The IpInfoPresenter contains instances of NetTask and InfoContract.View and implements the LoadTasksCallBack interface.
  2. Mnettask.execute (IP, this) is used to fetch data and call back to InInfoPresenter. After calling back to InInfoPresenter, the mAddTaskView interacts with the page to change the interface.

Substance:

  1. Presenter is essentially a middleman who retrieves and saves data via NetTask (the Model layer) and updates the interface via the View.
  2. The interface is defined so that there is no interaction between the View and Model.

6.5 implementation 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("Getting data");
        mBt_ipinfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.getIpInfo(URL); }}); } @Override public voidsetPresenter(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 voidshowLoading() {
        mProgressDialog.show();
    }

    @Override
    public void hideLoading() {
        if (mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
    }

    @Override
    public void showError() {
        Toast.makeText(getActivity(), "Network error", Toast.LENGTH_SHORT).show();
    }

    @Override
    public boolean isActivie() {
        returnisAdded(); }}Copy the code

Description:

  1. The setPresenter method injects IpInfoPresenter.
  2. The getIpInfo method gets information about the IP address: call Presenter.
  3. Fragment implements the View interface to receive IpinfoPresenter callbacks and update the interface.

6.6 setPresenter in an Activity

  1. Inject IpInfoTask(Model) and Fragment(View) into Presenter.
  2. Inject Presenter into a Fragment using setPresenter
public class MainActivity extends AppCompatActivity {

    private IpInfoPresenter ipInfoPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main); IpInfoFragment IpInfoFragment = (IpInfoFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);if(ipInfoFragment == null) { ipInfoFragment = IpInfoFragment.newInstance(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), ipInfoFragment, R.id.contentFrame); } // Inject Presenter into a Fragment IpInfoTask IpInfoTask = ipInfotask.getInstance (); // Inject Presenter into a Fragment IpInfoTask IpInfoTask = ipInfotask.getInstance (); ipInfoPresenter = new IpInfoPresenter(ipInfoTask, ipInfoFragment); ipInfoFragment.setPresenter(ipInfoPresenter); }}Copy the code
public class ActivityUtils { public static void addFragmentToActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(frameId, fragment); fragmentTransaction.commit(); }}Copy the code

6.6. Summarize

  1. There is no connection between the View and Model.
  2. A View and Presenter interact through an interface.
  3. In an Activity, Presenter and View are injected into each other.

7. Download address (welcome Star)

Github.com/OnlyYouMyLo…

8. Subsequent

If you liked this post, please like it. If you want to see more technologies on the front end of mobile and back end of Java or Python, please pay attention!