├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app-debug.apk
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── huaqin
│ │ └── recyclerviewdemo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── huaqin
│ │ │ └── recyclerviewdemo
│ │ │ ├── App.java
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseFragment.java
│ │ │ ├── BaseToolbarActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── core
│ │ │ ├── bean
│ │ │ │ └── NewsItem.java
│ │ │ ├── contract
│ │ │ │ └── NewsContract.java
│ │ │ ├── model
│ │ │ │ ├── BaseModelCallBack.java
│ │ │ │ └── NewsModel.java
│ │ │ ├── presenter
│ │ │ │ ├── BasePresenter.java
│ │ │ │ └── NewsPresenter.java
│ │ │ └── view
│ │ │ │ ├── BaseView.java
│ │ │ │ ├── WelcomeActivity.java
│ │ │ │ ├── adapter
│ │ │ │ ├── ListGridAdapter.java
│ │ │ │ ├── MainFragmentPagerAdapter.java
│ │ │ │ ├── NewsAdapter.java
│ │ │ │ ├── NewsGridAdapter.java
│ │ │ │ ├── StaggeredAdapter.java
│ │ │ │ ├── TecentAdapter.java
│ │ │ │ ├── TecentHolder.java
│ │ │ │ └── ThirdGridAdapter.java
│ │ │ │ └── ui
│ │ │ │ ├── FragmentFactory.java
│ │ │ │ ├── GridFragment.java
│ │ │ │ ├── NewsFragment.java
│ │ │ │ ├── NewsHorFragment.java
│ │ │ │ ├── PullLoadFragment.java
│ │ │ │ ├── StaggeredDemoFragment.java
│ │ │ │ ├── TencentFragment.java
│ │ │ │ └── WebActivity.java
│ │ │ ├── retrofit
│ │ │ ├── ApiManager.java
│ │ │ ├── INewsApi.java
│ │ │ └── RetrofitClient.java
│ │ │ ├── util
│ │ │ ├── Constants.java
│ │ │ ├── FileUtil.java
│ │ │ ├── ImageLoader.java
│ │ │ └── InternetUtil.java
│ │ │ └── widget
│ │ │ ├── NoScrollGridView.java
│ │ │ ├── PicassoImageLoader.java
│ │ │ ├── ProgressWebView.java
│ │ │ ├── RecyclerWidgetProvider.java
│ │ │ └── VpRecyclerView.java
│ └── res
│ │ ├── drawable-xhdpi
│ │ ├── ic_app.png
│ │ ├── ic_refresh.png
│ │ ├── place_holder.png
│ │ ├── tecent_holder.png
│ │ ├── welcome.png
│ │ └── widget_preview.jpg
│ │ ├── drawable
│ │ └── progress_bar.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_web.xml
│ │ ├── activity_welcome.xml
│ │ ├── fragment_grid.xml
│ │ ├── fragment_home_ad.xml
│ │ ├── fragment_home_banner.xml
│ │ ├── fragment_home_category.xml
│ │ ├── fragment_home_list.xml
│ │ ├── fragment_home_third.xml
│ │ ├── fragment_news.xml
│ │ ├── fragment_pullload.xml
│ │ ├── fragment_staggered.xml
│ │ ├── fragment_tencent.xml
│ │ ├── list_grid_layout.xml
│ │ ├── news_grid_item_layout.xml
│ │ ├── news_item_layout.xml
│ │ ├── staggered_item_layout.xml
│ │ ├── third_grid_layout.xml
│ │ ├── toolbar_title_layout.xml
│ │ └── widget_layout.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── widget_info.xml
│ └── test
│ └── java
│ └── com
│ └── huaqin
│ └── recyclerviewdemo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
├── 1.gif
├── 2.gif
├── 3.gif
├── 4.gif
├── 5.gif
├── all.gif
├── recyclerview.png
├── widget.gif
└── widget_click.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Android API 25 Platform
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 
--------------------------------------------------------------------------------
/app-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdleyLong/RecyclerViewDemo/3bda03022e4df0399684bbe3ed8465d2afb89b4a/app-debug.apk
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'android-apt'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 | defaultConfig {
8 | applicationId "com.huaqin.recyclerviewdemo"
9 | minSdkVersion 15
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 |
29 | compile 'com.android.support:appcompat-v7:25.0.0'
30 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
31 | compile 'com.android.support:design:25.0.0'
32 | compile 'com.android.support:cardview-v7:25.0.0'
33 | compile 'com.jakewharton:butterknife:8.4.0'
34 | compile 'com.squareup.picasso:picasso:2.5.2'
35 | compile 'com.squareup.retrofit2:retrofit:2.1.0'
36 | compile 'com.squareup.retrofit2:converter-gson:2.1.0'
37 | compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
38 | compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
39 | compile 'io.reactivex:rxjava:1.1.6'
40 | compile 'io.reactivex:rxandroid:1.2.1'
41 | compile 'com.jcodecraeer:xrecyclerview:1.2.8'
42 | testCompile 'junit:junit:4.12'
43 | apt 'com.jakewharton:butterknife-compiler:8.4.0'
44 | compile 'com.youth.banner:banner:1.4.8'
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/ubuntu/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/huaqin/recyclerviewdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.huaqin.recyclerviewdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/App.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * Created by ubuntu on 17-4-13.
7 | */
8 |
9 | public class App extends Application {
10 | public static App singleton = null;
11 |
12 | private final String TAG = "App";
13 |
14 | public static App getInstance() {
15 | return singleton;
16 | }
17 |
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 | singleton = this;
23 |
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by ubuntu on 17-4-13.
8 | */
9 |
10 | public class BaseActivity extends AppCompatActivity {
11 | /**
12 | * toast弹框
13 | *
14 | * @param toastStr
15 | */
16 | public void showToast(String toastStr) {
17 | Toast.makeText(this, toastStr, Toast.LENGTH_SHORT).show();
18 | }
19 |
20 | /**
21 | * toast弹框
22 | *
23 | * @param toastId
24 | */
25 | public void showToast(int toastId) {
26 | Toast.makeText(this, toastId, Toast.LENGTH_SHORT).show();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by ubuntu on 17-4-13.
8 | */
9 |
10 | public class BaseFragment extends Fragment {
11 |
12 | /**
13 | * toast弹框
14 | * @param toastStr
15 | */
16 | public void showToast(String toastStr){
17 | Toast.makeText(this.getActivity(),toastStr,Toast.LENGTH_SHORT).show();
18 | }
19 |
20 | /**
21 | * toast弹框
22 | * @param toastId
23 | */
24 | public void showToast(int toastId){
25 | Toast.makeText(this.getActivity(),toastId, Toast.LENGTH_SHORT).show();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/BaseToolbarActivity.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.widget.Toolbar;
6 | import android.view.MenuItem;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * Created by ubuntu on 17-4-13.
13 | */
14 |
15 | public abstract class BaseToolbarActivity extends BaseActivity {
16 | private Toolbar mToolbar;
17 | private TextView mTitle;
18 |
19 | @Override
20 | protected void onCreate(@Nullable Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 |
23 | setContentView(getLayoutId());
24 |
25 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
26 | mTitle = (TextView) findViewById(R.id.toolbar_title);
27 | if (mToolbar != null) {
28 | setSupportActionBar(mToolbar);
29 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
30 | getSupportActionBar().setDisplayShowTitleEnabled(false);
31 | }
32 |
33 | }
34 |
35 | @Override
36 | public boolean onOptionsItemSelected(MenuItem item) {
37 | if (item.getItemId() == android.R.id.home) {
38 | finish();
39 | return true;
40 | }
41 | return super.onOptionsItemSelected(item);
42 | }
43 |
44 | public Toolbar getToolbar() {
45 | return (Toolbar) findViewById(R.id.toolbar);
46 | }
47 |
48 | public void setTitle(String title) {
49 | mTitle.setText(title);
50 | }
51 |
52 | public abstract int getLayoutId();
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v4.view.ViewPager;
7 | import android.support.v7.app.AppCompatActivity;
8 |
9 | import com.huaqin.recyclerviewdemo.core.view.adapter.MainFragmentPagerAdapter;
10 |
11 | import butterknife.BindView;
12 | import butterknife.ButterKnife;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | @BindView(R.id.tab_layout)
17 | TabLayout mTabLayout;
18 | @BindView(R.id.viewpager)
19 | ViewPager mViewpager;
20 |
21 | private MainFragmentPagerAdapter mAdapter;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | ButterKnife.bind(this);
28 |
29 | initView();
30 | }
31 |
32 | /**
33 | * 初始化对象
34 | */
35 | private void initView() {
36 | mAdapter = new MainFragmentPagerAdapter(getSupportFragmentManager(), this);
37 | mViewpager.setAdapter(mAdapter);
38 | mViewpager.setOffscreenPageLimit(6);
39 | mTabLayout.setupWithViewPager(mViewpager);
40 | // mTabLayout.setTabMode(TabLayout.MODE_FIXED);
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/core/bean/NewsItem.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo.core.bean;
2 |
3 | /**
4 | * Created by ubuntu on 17-4-13.
5 | */
6 |
7 | public class NewsItem {
8 |
9 |
10 | /**
11 | * postid : CHTCNO4S00038FO9
12 | * url_3w : http://ent.163.com/17/0413/12/CHTCNO4S00038FO9.html
13 | * votecount : 6984
14 | * replyCount : 7767
15 | * skipID : S1491970484761
16 | * ltitle : 白百何出轨第二弹!与男模泰国算命 当街大玩捏臀
17 | * digest : 网易娱乐4月13日报道4月12日,卓伟在直播中曝出大料,出轨女主就是白百何。白百何在泰国会面男模张爱朋,两人贴面喂食泳边嬉戏,上演“一指禅”,画面尺度惊人。今天
18 | * skipType : special
19 | * url : http://3g.163.com/ent/17/0413/12/CHTCNO4S00038FO9.html
20 | * specialID : S1491970484761
21 | * docid : CHTCNO4S00038FO9
22 | * title : 白百何出轨第二弹!与男模泰国算命 当街大玩捏臀
23 | * source : 网易娱乐
24 | * priority : 151
25 | * lmodify : 2017-04-13 13:38:06
26 | * boardid : ent2_bbs
27 | * subtitle :
28 | * imgsrc : http://cms-bucket.nosdn.127.net/ad53a86aef044d0b87e359f7b224fecc20170413121507.png
29 | * ptime : 2017-04-13 12:15:11
30 | */
31 |
32 | private String postid;
33 | private String url_3w;
34 | private int votecount;
35 | private int replyCount;
36 | private String skipID;
37 | private String ltitle;
38 | private String digest;
39 | private String skipType;
40 | private String url;
41 | private String specialID;
42 | private String docid;
43 | private String title;
44 | private String source;
45 | private int priority;
46 | private String lmodify;
47 | private String boardid;
48 | private String subtitle;
49 | private String imgsrc;
50 | private String ptime;
51 |
52 | public String getPostid() {
53 | return postid;
54 | }
55 |
56 | public void setPostid(String postid) {
57 | this.postid = postid;
58 | }
59 |
60 | public String getUrl_3w() {
61 | return url_3w;
62 | }
63 |
64 | public void setUrl_3w(String url_3w) {
65 | this.url_3w = url_3w;
66 | }
67 |
68 | public int getVotecount() {
69 | return votecount;
70 | }
71 |
72 | public void setVotecount(int votecount) {
73 | this.votecount = votecount;
74 | }
75 |
76 | public int getReplyCount() {
77 | return replyCount;
78 | }
79 |
80 | public void setReplyCount(int replyCount) {
81 | this.replyCount = replyCount;
82 | }
83 |
84 | public String getSkipID() {
85 | return skipID;
86 | }
87 |
88 | public void setSkipID(String skipID) {
89 | this.skipID = skipID;
90 | }
91 |
92 | public String getLtitle() {
93 | return ltitle;
94 | }
95 |
96 | public void setLtitle(String ltitle) {
97 | this.ltitle = ltitle;
98 | }
99 |
100 | public String getDigest() {
101 | return digest;
102 | }
103 |
104 | public void setDigest(String digest) {
105 | this.digest = digest;
106 | }
107 |
108 | public String getSkipType() {
109 | return skipType;
110 | }
111 |
112 | public void setSkipType(String skipType) {
113 | this.skipType = skipType;
114 | }
115 |
116 | public String getUrl() {
117 | return url;
118 | }
119 |
120 | public void setUrl(String url) {
121 | this.url = url;
122 | }
123 |
124 | public String getSpecialID() {
125 | return specialID;
126 | }
127 |
128 | public void setSpecialID(String specialID) {
129 | this.specialID = specialID;
130 | }
131 |
132 | public String getDocid() {
133 | return docid;
134 | }
135 |
136 | public void setDocid(String docid) {
137 | this.docid = docid;
138 | }
139 |
140 | public String getTitle() {
141 | return title;
142 | }
143 |
144 | public void setTitle(String title) {
145 | this.title = title;
146 | }
147 |
148 | public String getSource() {
149 | return source;
150 | }
151 |
152 | public void setSource(String source) {
153 | this.source = source;
154 | }
155 |
156 | public int getPriority() {
157 | return priority;
158 | }
159 |
160 | public void setPriority(int priority) {
161 | this.priority = priority;
162 | }
163 |
164 | public String getLmodify() {
165 | return lmodify;
166 | }
167 |
168 | public void setLmodify(String lmodify) {
169 | this.lmodify = lmodify;
170 | }
171 |
172 | public String getBoardid() {
173 | return boardid;
174 | }
175 |
176 | public void setBoardid(String boardid) {
177 | this.boardid = boardid;
178 | }
179 |
180 | public String getSubtitle() {
181 | return subtitle;
182 | }
183 |
184 | public void setSubtitle(String subtitle) {
185 | this.subtitle = subtitle;
186 | }
187 |
188 | public String getImgsrc() {
189 | return imgsrc;
190 | }
191 |
192 | public void setImgsrc(String imgsrc) {
193 | this.imgsrc = imgsrc;
194 | }
195 |
196 | public String getPtime() {
197 | return ptime;
198 | }
199 |
200 | public void setPtime(String ptime) {
201 | this.ptime = ptime;
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/core/contract/NewsContract.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo.core.contract;
2 |
3 | import android.app.Activity;
4 |
5 | import com.huaqin.recyclerviewdemo.core.bean.NewsItem;
6 | import com.huaqin.recyclerviewdemo.core.presenter.BasePresenter;
7 | import com.huaqin.recyclerviewdemo.core.view.BaseView;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by ubuntu on 17-4-13.
13 | */
14 |
15 | public class NewsContract {
16 | public interface View extends BaseView {
17 | void onSuccess(List list);
18 |
19 | void onFailure(String error);
20 |
21 | }
22 |
23 |
24 | public interface Presenter extends BasePresenter {
25 | void getData(Activity activity);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/core/model/BaseModelCallBack.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo.core.model;
2 |
3 | /**
4 | * Created by ubuntu on 17-4-13.
5 | */
6 |
7 | public interface BaseModelCallBack {
8 | void onResponse(T response);
9 |
10 | void onFailure(String error);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/huaqin/recyclerviewdemo/core/model/NewsModel.java:
--------------------------------------------------------------------------------
1 | package com.huaqin.recyclerviewdemo.core.model;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import com.google.gson.JsonArray;
7 | import com.google.gson.JsonObject;
8 | import com.google.gson.annotations.JsonAdapter;
9 | import com.huaqin.recyclerviewdemo.core.bean.NewsItem;
10 | import com.huaqin.recyclerviewdemo.retrofit.ApiManager;
11 |
12 | import org.json.JSONArray;
13 | import org.json.JSONException;
14 | import org.json.JSONObject;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 | import java.util.Map;
19 |
20 | import rx.Subscriber;
21 | import rx.android.schedulers.AndroidSchedulers;
22 | import rx.schedulers.Schedulers;
23 |
24 | /**
25 | * Created by ubuntu on 17-4-13.
26 | */
27 |
28 | public class NewsModel {
29 | private static final String TAG = "NewsModel";
30 |
31 | public void getData(Activity activity, final BaseModelCallBack callBack) {
32 | ApiManager.getInstance().apiNews()
33 | .getNewsList("T1348648517839", 0, 20)
34 | .subscribeOn(Schedulers.io())
35 | .observeOn(AndroidSchedulers.mainThread())
36 | .subscribe(new Subscriber