In order to earn a monthly salary of 18,000 yuan, we must continue to learn and summarize. Today, I will introduce to you the common Android architecture pattern - MVP, which is very detailed and worth learning. Why should you learn MVP? Just look at the picture below to know. 1. Preface In actual development, choose the appropriate architecture based on the business. This blog briefly introduces the MVC model and introduces the MVP model in detail. After reading this blog, if you can’t write MVP, just leave a message and I’ll kneel on the washboard! 2. Introduction to MVC Pattern - M: Model: Model layer: responsible for business logic.
- V:View: View layer: responsible for interface presentation
- C:Controller: Control layer: responsible for the interaction between Model and View.
Simply put: MVC uses the Controller to manipulate the data in the Model layer and returns it to the View layer for display. 3. Disadvantages of MVC pattern in Android Android is not a standard Controller in the MVC model. Its primary responsibility is to load the layout of the application and initialize the user interface, accept and process operation requests from users, and then respond. As the complexity of the interface and its logic continues to increase, the responsibilities of the Activity class continue to increase, making it large and bloated. Since Android's Controller is usually in Activity or Fragment, the Model and View layers are severely coupled, making them difficult to develop and maintain. 4. Introduction to MVP Mode - M: Model: responsible for obtaining and storing data.
- V:View: Responsible for the display of user events and view parts.
- P:Presenter: serves as a bridge for communication between View and Model.
Simply put: MVP retrieves data from the Model layer through Presenter and returns it to the View layer. 5. Advantages of MVP pattern in Android Presenter completely separates Model and View, and the main logic is implemented in Presenter. 6. MVP Example 6.1 Adding Dependencies - compile 'cn.finalteam:okhttpfinal:2.0.7'
6.2 Initialize 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 Implementing the Model ① Create entity class TitleData: - public class TitleData {
- /**
- * reason : Successful return
- * result : { "stat" : "1" , "data" :[{ "uniquekey" : "68388dafd210bd9e6e733f28f35d36d9" , "title" : "14 bodyweight exercises without going to the gym! Get your pump pumping anytime!" , "date" : "2018-04-15 22:27" , "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" : "2018-04-15 22:06" , "category" : "Headlines" , "author_name" : "Ministry of Foreign Affairs 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 bombed again by the US proves that only the weak will be attacked? Wrong, it was because of internal disunity that they were beaten." , "date" : "2018-04-15 21:58" , "category" : "Headline" , "author_name" : "Qingfengxiao" , "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" : "An airplane hijacking occurred this morning Do you know how the captain uses code to inform the ground?" , "date" : "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 criticized for following Trump's lead in launching strikes against Syria without domestic authorization" , "date" : "2018-04-15 21:52" , "category" : "Headline" , "author_name" : "Observer Network" , "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 was bombed and Hainan was all over the news. Should I go long or short?" , "date" : "2018-04-15 21:35" , "category" : "Headline" , "author_name" : "Chenghong 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 oral cancer patients in Xiangya Hospital, 44 of them chewed betel nuts for a long time" , "date" : "2018-04-15 21:17" , "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 Arabia and Israel's relations are gradually improving. Iran: They are committing joint crimes" , "date" : "2018-04-15 21:13" , "category" : "Headlines" , "author_name" : "Middle East Research 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, an island country in the Indian Ocean: looking forward to common development with China" , "date" : "2018-04-15 21:13" , "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 field when he found a hole in his grave. The scene inside shocked him." , "date" : "2018-04-15 21:02" , "category" : "Headline" , "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" : "Yoga can heal your body and mind. It's actually very simple. You just need to breathe" , "date" : "2018-04-15 21:00" , " category" : "Headline" , "author_name" : "Yoga Postures" , "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 you seize this industry, a large number of people will become rich! " , "date" : "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" : How to promote high - quality development in Northeast China ? Experts: First of all, we should talk more about the concept of "New Northeast China". " date" : "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" : "The Australian Chinese worship ceremony of Emperor Huangdi in the year of Wuxu was held in Sydney" , "date" : "2018-04-15 20:54" , "category" : "Headline" , "author_name" : " People's Daily" , "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" : "The snow in Antarctica is getting more and more, increasing by 10% in 200 years! However, this is the beginning of something bad! " , "date" : "2018-04-15 20:33" , "category" : "Headline" , "author_name" : "China Weather Enthusiasts" , "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" : "Integrating the spirit of the Constitution into notarial practice" , "date" : "2018-04-15 20:31" , "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" : "PLA's new regulations release benefits: Soldiers are given compensatory leave after holidays" , "date" : "2018-04-15 20:27" , "category" : "Headlines" , "author_name" : "Global Network" , "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" : "The dead are buried in peace? " , "date" : "2018-04-15 20:26" , "category" : "Headline" , "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" : "Want to have bigger breasts and thinner arms but can't do push-ups? Try these six moves!" , "date" : "2018-04-15 20:25" , "category" : "Headline" , "author_name" : "Breast Enlargement Instructor_Xiaoyu" , "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" : "2018-04-15 20:24" , "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" : "70% successful interception rate. Who is lying, Russia or the United States? Reality slaps the country in the face" , "date" : "2018-04-15 20:20" , "category" : "Headline" , "author_name" : "Fire Front" , "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!" , "date" : "2018-04-15 20:19" , "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 has the conditions to become an innovation and technology hub" , "date" : "2018-04-15 20:18" , "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 demonize China has not succeeded, but has made more countries understand China!" , "date" : "2018-04-15 20:13" , "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 Investment and Trade Fair invited nearly 20,000 merchants from home and abroad to highlight its international nature" , "date" : "2018-04-15 20:12" , "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" : "The 8th Beijing Film Festival opened with a star-studded red carpet ceremony" , "date" : "2018-04-15 20:12" , "category" : "Headlines" , "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" : "u201ckindergarten to primary schoolu201dcitizens recruit students at the same time, guided by the u201cnew high school entrance examinationu201d, parents are becoming more rational during this year's campus open day" , "date" : "2018-04-15 20:08" , "category" : "Headline" , "author_name" : "Jiefang.com" , "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 endured for many years, but has not been able to get rid of the title of cuckold, and now he has finally decided to divorce! " , "date" : "2018-04-15 20:05" , "category" : "Headline" , "author_name" : "The Soul of War" , "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 with Song Tao, head of the Chinese art troupe in Pyongyang" , "date" : "2018-04-15 20:04" , "category" : "Headline" , "author_name" : "CCTV" , "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·Master Craftsmen】Striving for excellence and diligent research, the spirit of craftsmen sets an example" , "date" : "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" : "14 bodyweight exercises without going to the gym! Get your body pumped at any time!" , "date" : "2018-04-15 22:27" , "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" : "2018-04-15 22:06" , "category" : "Headlines" , "author_name" : "Ministry of Foreign Affairs 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 bombed again by the US proves that only the weak will be attacked? Wrong, it was because of internal disunity that they were beaten." , "date" : "2018-04-15 21:58" , "category" : "Headline" , "author_name" : "Qingfengxiao" , "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" : "An airplane hijacking occurred this morning Do you know how the captain uses code to inform the ground?" , "date" : "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 criticized for following Trump's lead in launching strikes against Syria without domestic authorization" , "date" : "2018-04-15 21:52" , "category" : "Headline" , "author_name" : "Observer Network" , "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 was bombed and Hainan was all over the news. Should I go long or short?" , "date" : "2018-04-15 21:35" , "category" : "Headline" , "author_name" : "Chenghong 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 oral cancer patients in Xiangya Hospital, 44 of them chewed betel nuts for a long time" , "date" : "2018-04-15 21:17" , "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 Arabia and Israel's relations are gradually improving. Iran: They are committing joint crimes" , "date" : "2018-04-15 21:13" , "category" : "Headlines" , "author_name" : "Middle East Research 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, an island country in the Indian Ocean: looking forward to common development with China" , "date" : "2018-04-15 21:13" , "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 field when he found a hole in his grave. The scene inside shocked him." , "date" : "2018-04-15 21:02" , "category" : "Headline" , "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" : "Yoga can heal your body and mind. It's actually very simple. You just need to breathe" , "date" : "2018-04-15 21:00" , " category" : "Headline" , "author_name" : "Yoga Postures" , "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 you seize this industry, a large number of people will become rich! " , "date" : "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" : How to promote high - quality development in Northeast China ? Experts: First of all, we should talk more about the concept of "New Northeast China". " date" : "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" : "The Australian Chinese worship ceremony of Emperor Huangdi in the year of Wuxu was held in Sydney" , "date" : "2018-04-15 20:54" , "category" : "Headline" , "author_name" : " People's Daily" , "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" : "The snow in Antarctica is getting more and more, increasing by 10% in 200 years! However, this is the beginning of something bad! : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "9a12e11575a3e258ed577e26c802bcdb" , "title" : "People's Liberation Army's new regulations release dividends: officers and soldiers arrange compensatory leave after duty on holidays" , "date" : "2018-04-15 20:27" , "category" : "Toutiao" , "author_name" : "Global Network" , "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" : "Why are the deceased buried in the soil? : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "http://03.imgmini.eastday.com/mobile/20180415/20180415202409_db2bf6b3f75b110448a65f9d1bc83659_2_mwpm_03200403.jpg" },{ "uniquekey" : "86bb5027d938238d8606c6d1c1740e52" , "title" : "70% successful interception rate Who is lying in Russia or the United States? : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" , : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "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" : "Shizo Abe has endured for many years and has not been able to get rid of the title of u201c cuckold u201d, and now he has finally decided to divorce! " , "date" : "2018-04-15 20:05" , "category" : "Telephone" , "author_name" : "The Soul of War" , "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" : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "65e0297026cbefe2a2a38d720393372d" , "title" : "【Chinese Dream·Great Country Craftsmen Chapter】Strive to study hard, craftsmen's spirit is modeled" , "date" : "2018-04-15 20:03" , "category" : "Toutiao" , "author_name" : "China Daily Network" , "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: No need to go to the gym to bare hands and exercise 14 styles! It will make your body pumping soar at any time!
- * date : 2018-04-15 22:27
- * category : Headlines
- * 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
- */
- 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;
- }
- }
- }
- }
② Define the network listening callback interface - public interface LoadTasksCallBack<T> {
- void onStart();
- void onFinish();
- void onSuccess(T t);
- void onFailed();
- }
③ Define the interface class to obtain network data - public interface NetTask<T> {
- void execute (T data,LoadTasksCallBack callBack);
- }
④ Write NetTask implementation class 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();
- }
- });
- }
- }
Note: IpInfoTask is a singleton class that obtains data through okhttpfinal in the execute method, and at the same time, call the self-defined callback function loadTasksCallBack in the okhttpfinal callback function. 6.4 Implementing Presenter ① Define the contract interface 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 isActive();
- }
- }
illustrate: The contract interface is mainly used to store the Presenter and View interfaces of the same business, which is easy to find and maintain. Here we see that the Presenter interface defines the method of obtaining data, and the View defines the method of interacting with the interface. Among them, the isActive method is used to determine whether the Fragment is added to the Activity. In addition: The View interface inherits from the BaseView interface. The purpose of the BaseView interface is to bind the Presenter to the View: - public interface BaseView<T> {
- void setPresenter(T presenter);
- }
② Implement the 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);
- }
- }
illustrate: IpInfoPresenter contains instances of NetTask and InfoContract.View, and implements the LoadTasksCallBack interface. mNetTask.execute(ip, this) is used to obtain data and call back to InInfoPresenter, call back to InInfoPresenter, then interact with the page through mAddTaskView to change the interface. substance: Presenter is actually a middleman. It obtains and saves data through NetTask (Model layer), and then updates the interface through View. During this period, the interface is defined so that the View and Model have no interaction. 6.5 Implement 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( "Get Data" );
- 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(), "Network Error" , Toast.LENGTH_SHORT).show();
- }
- @Override
- public boolean isActive() {
- return isAdded();
- }
- }
illustrate: - setPresenter方法注入IpInfoPresenter。
- The getIpInfo method gets the information of the IP address: that is, call presenter.
- fragment implements the view interface, which is used to receive callbacks from IpinfoPresenter and update the interface.
6.6 setPresenter in Activity Inject IpInfoTask(Model) and Fragment(View) into Presenter. Inject Presenter into Fragment via setPresenter - public class MainActivity extends AppCompatActivity {
- private IpInfoPresenter ipInfoPresenter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- // Add Fragment to Activity
- IpInfoFragment ipInfoFragment = (IpInfoFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
- if (ipInfoFragment == null ) {
- ipInfoFragment = IpInfoFragment.newInstance();
- ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), ipInfoFragment, R.id.contentFrame);
- }
- // Inject Model and View into Presenter, and inject Presenter into 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. Summary - There is no connection between View and Model.
- View and Presenter interact through interfaces.
- Presenter and View inject each other in Activity.
7. Download address (Star welcome) https://github.com/OnlyYouMyLove/MVP |