Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 9f0da09

Browse files
committed
解决博主博客列表数据加载错误问题
1 parent d21188a commit 9f0da09

File tree

8 files changed

+84
-46
lines changed

8 files changed

+84
-46
lines changed

app/src/main/java/com/rae/cnblogs/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void initTab() {
104104
// 初始化TAB
105105
addTab(mAdapter, R.string.tab_home, R.drawable.tab_home, AppRoute.newHomeFragment());
106106
addTab(mAdapter, R.string.tab_sns, R.drawable.tab_news, AppRoute.newMomentFragment());
107-
addTab(mAdapter, R.string.tab_discover, R.drawable.tab_library, AppRoute.newDiscoverFragment());
107+
// addTab(mAdapter, R.string.tab_discover, R.drawable.tab_library, AppRoute.newDiscoverFragment());
108108
addTab(mAdapter, R.string.tab_mine, R.drawable.tab_mine, AppRoute.newMineFragment());
109109

110110
mViewPager.setOffscreenPageLimit(mAdapter.getCount());

module-basic/src/main/java/com/rae/cnblogs/basic/BasicFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import butterknife.ButterKnife;
1515
import butterknife.Unbinder;
1616

17-
public abstract class BasicFragment extends Fragment {
17+
public abstract class BasicFragment extends Fragment implements IPresenterView {
1818

1919
@Nullable
2020
private Unbinder mUnBinder;

module-blog/src/main/java/com/rae/cnblogs/blog/BloggerActivity.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
import com.rae.cnblogs.basic.GlideRequest;
3131
import com.rae.cnblogs.blog.blogger.BloggerContract;
3232
import com.rae.cnblogs.blog.blogger.BloggerPresenterImpl;
33+
import com.rae.cnblogs.blog.fragment.BloggerListFragment;
3334
import com.rae.cnblogs.blog.fragment.FeedListFragment;
3435
import com.rae.cnblogs.blog.fragment.MultipleTypeBlogListFragment;
3536
import com.rae.cnblogs.sdk.UserProvider;
3637
import com.rae.cnblogs.sdk.bean.BlogCommentBean;
37-
import com.rae.cnblogs.sdk.bean.CategoryBean;
3838
import com.rae.cnblogs.sdk.bean.FriendsInfoBean;
3939
import com.rae.cnblogs.sdk.event.UserInfoEvent;
4040
import com.rae.cnblogs.theme.ThemeCompat;
@@ -133,11 +133,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
133133
}
134134

135135
RaeFragmentAdapter adapter = new RaeFragmentAdapter(getSupportFragmentManager());
136-
CategoryBean category = new CategoryBean();
137-
category.setCategoryId(getBlogApp()); // 这里设置blogApp
138136

139137
mFeedListFragment = FeedListFragment.newInstance(getBlogApp());
140-
mBlogListFragment = MultipleTypeBlogListFragment.newInstance(category);
138+
mBlogListFragment = BloggerListFragment.newInstance(getBlogApp());
141139

142140
adapter.add(getString(R.string.feed), mFeedListFragment);
143141
adapter.add(getString(R.string.blog), mBlogListFragment);

module-blog/src/main/java/com/rae/cnblogs/blog/content/BlogListPresenterImpl.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.rae.cnblogs.blog.comm.ContentListContract;
66
import com.rae.cnblogs.sdk.CnblogsApiFactory;
77
import com.rae.cnblogs.sdk.api.IBlogApi;
8+
import com.rae.cnblogs.sdk.api.IFriendsApi;
89
import com.rae.cnblogs.sdk.bean.BlogBean;
910
import com.rae.cnblogs.sdk.bean.BlogType;
1011
import com.rae.cnblogs.sdk.bean.CategoryBean;
@@ -21,17 +22,29 @@
2122
public class BlogListPresenterImpl extends BasicBlogPresenterImpl {
2223

2324
private IBlogApi mBlogApi;
25+
private IFriendsApi mFriendsApi;
2426

25-
public BlogListPresenterImpl(ContentListContract.View view) {
26-
super(view, BlogType.BLOG);
27+
public BlogListPresenterImpl(ContentListContract.View view, BlogType type) {
28+
super(view, type);
29+
if (type == BlogType.BLOGGER)
30+
mFriendsApi = CnblogsApiFactory.getInstance(getContext()).getFriendApi();
2731
mBlogApi = CnblogsApiFactory.getInstance(getContext()).getBlogApi();
2832
}
2933

34+
public BlogListPresenterImpl(ContentListContract.View view) {
35+
this(view, BlogType.BLOG);
36+
}
37+
3038
@Override
3139
protected Observable<List<BlogBean>> onCreateObserver(@Nullable CategoryBean category, int page) {
3240
if (category == null) {
3341
return Observable.error(new NullPointerException("the category is null."));
3442
}
43+
if (getBlogType() == BlogType.BLOGGER) {
44+
45+
// 博主的博客列表
46+
return mFriendsApi.getBlogList(page, category.getCategoryId());
47+
}
3548
// 博客列表接口
3649
return mBlogApi.getBlogList(page, category.getType(), category.getParentId(), category.getCategoryId());
3750
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.rae.cnblogs.blog.fragment;
2+
3+
import android.os.Bundle;
4+
5+
import com.rae.cnblogs.blog.comm.ContentListContract;
6+
import com.rae.cnblogs.blog.content.BlogListPresenterImpl;
7+
import com.rae.cnblogs.sdk.bean.BlogType;
8+
import com.rae.cnblogs.sdk.bean.CategoryBean;
9+
10+
public class BloggerListFragment extends MultipleTypeBlogListFragment {
11+
12+
public static BloggerListFragment newInstance(String blogApp) {
13+
Bundle args = new Bundle();
14+
CategoryBean category = new CategoryBean();
15+
category.setCategoryId(blogApp);
16+
args.putParcelable("category", category);
17+
BloggerListFragment fragment = new BloggerListFragment();
18+
fragment.setArguments(args);
19+
return fragment;
20+
}
21+
22+
@Override
23+
protected ContentListContract.Presenter makePresenter() {
24+
return new BlogListPresenterImpl(this, BlogType.BLOGGER);
25+
}
26+
}

module-blog/src/main/res/layout/fm_blogger_info.xml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
@@ -12,16 +11,18 @@
1211
android:layout_height="wrap_content"
1312
android:background="@color/white"
1413
android:orientation="vertical"
14+
1515
android:theme="@style/ThemeOverlay.AppCompat.Light"
1616
app:elevation="0dp">
1717

1818

1919
<android.support.design.widget.CollapsingToolbarLayout
2020
android:id="@+id/toolbar_layout"
2121
android:layout_width="match_parent"
22+
app:contentScrim="@color/white"
2223
android:layout_height="wrap_content"
23-
app:layout_scrollFlags="scroll|enterAlwaysCollapsed|exitUntilCollapsed"
24-
app:statusBarScrim="?colorPrimaryDark">
24+
app:layout_scrollFlags="scroll|enterAlwaysCollapsed|exitUntilCollapsed|snap"
25+
app:statusBarScrim="@color/colorAccent">
2526

2627
<!--底图-->
2728
<RelativeLayout
@@ -34,23 +35,23 @@
3435
<!--默认大图-->
3536
<ImageView
3637
android:layout_width="match_parent"
37-
android:layout_height="240dp"
38+
android:layout_height="360dp"
3839
android:background="@drawable/bg_blogger_blur"
39-
android:minHeight="240dp"
40-
android:scaleType="center"/>
40+
android:minHeight="360dp"
41+
android:scaleType="center" />
4142

4243
<!--贴图大图-->
4344
<ImageView
4445
android:id="@+id/img_background"
4546
android:layout_width="match_parent"
46-
android:layout_height="240dp"
47-
android:minHeight="240dp"
48-
android:scaleType="center"/>
47+
android:layout_height="360dp"
48+
android:minHeight="360dp"
49+
android:scaleType="center" />
4950

5051
<LinearLayout
5152
android:layout_width="match_parent"
5253
android:layout_height="wrap_content"
53-
android:layout_marginTop="160dp"
54+
android:layout_marginTop="240dp"
5455
android:background="@drawable/bg_blogger_blur_new"
5556
android:orientation="vertical">
5657

@@ -60,23 +61,23 @@
6061
android:id="@+id/ll_blog_avatar"
6162
android:layout_width="wrap_content"
6263
android:layout_height="wrap_content"
63-
android:layout_marginLeft="16dp"
6464
android:layout_marginStart="16dp"
65+
android:layout_marginLeft="16dp"
6566
android:paddingTop="20dp">
6667

6768
<com.makeramen.roundedimageview.RoundedImageView
6869
android:layout_width="62dp"
6970
android:layout_height="62dp"
7071
android:src="@color/white"
71-
app:riv_corner_radius="74dp"/>
72+
app:riv_corner_radius="74dp" />
7273

7374
<com.makeramen.roundedimageview.RoundedImageView
7475
android:id="@+id/img_blog_avatar"
7576
android:layout_width="60dp"
7677
android:layout_height="60dp"
7778
android:scaleType="centerCrop"
7879
android:src="@drawable/boy"
79-
app:riv_corner_radius="70dp"/>
80+
app:riv_corner_radius="70dp" />
8081

8182
<TextView
8283
android:id="@+id/tv_blogger_name"
@@ -87,7 +88,7 @@
8788
android:paddingStart="12dp"
8889
android:textColor="@android:color/black"
8990
android:textSize="@dimen/h1"
90-
android:textStyle="bold"/>
91+
android:textStyle="bold" />
9192

9293

9394
<LinearLayout
@@ -109,18 +110,18 @@
109110
android:indeterminateDuration="3000"
110111
android:indeterminateTint="@android:color/white"
111112
android:indeterminateTintMode="src_in"
112-
android:visibility="gone"/>
113+
android:visibility="gone" />
113114

114115
<Button
115116
android:id="@+id/btn_blogger_follow"
116-
android:layout_width="62dp"
117-
android:layout_height="26dp"
117+
android:layout_width="72dp"
118+
android:layout_height="28dp"
118119
android:background="@drawable/bg_btn_follow_blogger"
119120
android:text="@string/following"
120-
android:textColor="@android:color/black"
121+
android:textColor="@color/white"
121122
android:textSize="@dimen/h3"
122123
android:textStyle="bold"
123-
android:visibility="visible"/>
124+
android:visibility="visible" />
124125
</LinearLayout>
125126

126127
<TextView
@@ -130,12 +131,12 @@
130131
android:layout_below="@id/tv_blogger_name"
131132
android:layout_marginStart="18dp"
132133
android:layout_marginTop="12dp"
133-
android:layout_toEndOf="@id/img_blog_avatar"
134134
android:layout_toStartOf="@id/rl_blogger_follow"
135+
android:layout_toEndOf="@id/img_blog_avatar"
135136
android:paddingStart="12dp"
136137
android:text="@string/blogger_default_introduce"
137138
android:textColor="#FF9B9B9B"
138-
android:textSize="@dimen/h2"/>
139+
android:textSize="@dimen/h2" />
139140

140141

141142
</RelativeLayout>
@@ -145,12 +146,12 @@
145146
<LinearLayout
146147
android:layout_width="match_parent"
147148
android:layout_height="wrap_content"
148-
android:layout_marginBottom="40dp"
149149
android:layout_marginLeft="18dp"
150150
android:layout_marginTop="20dp"
151+
android:layout_marginBottom="40dp"
151152
android:gravity="start|center_vertical"
152-
android:paddingBottom="6dp"
153-
android:paddingTop="6dp">
153+
android:paddingTop="6dp"
154+
android:paddingBottom="6dp">
154155

155156
<LinearLayout
156157
android:id="@+id/layout_account_fans"
@@ -172,15 +173,15 @@
172173
android:text="0"
173174
android:textColor="@android:color/black"
174175
android:textSize="@dimen/h2"
175-
android:textStyle="bold"/>
176+
android:textStyle="bold" />
176177

177178
<TextView
178179
android:layout_width="wrap_content"
179180
android:layout_height="wrap_content"
180181
android:layout_marginTop="4dp"
181182
android:text="粉丝"
182183
android:textColor="@android:color/black"
183-
android:textSize="@dimen/h3"/>
184+
android:textSize="@dimen/h3" />
184185

185186

186187
</LinearLayout>
@@ -205,15 +206,15 @@
205206
android:text="0"
206207
android:textColor="@android:color/black"
207208
android:textSize="@dimen/h2"
208-
android:textStyle="bold"/>
209+
android:textStyle="bold" />
209210

210211
<TextView
211212
android:layout_width="wrap_content"
212213
android:layout_height="wrap_content"
213214
android:layout_marginTop="4dp"
214215
android:text="关注"
215216
android:textColor="@android:color/black"
216-
android:textSize="@dimen/h3"/>
217+
android:textSize="@dimen/h3" />
217218

218219
</LinearLayout>
219220

@@ -238,15 +239,15 @@
238239
android:text="0"
239240
android:textColor="@android:color/black"
240241
android:textSize="@dimen/h2"
241-
android:textStyle="bold"/>
242+
android:textStyle="bold" />
242243

243244
<TextView
244245
android:layout_width="wrap_content"
245246
android:layout_height="wrap_content"
246247
android:layout_marginTop="4dp"
247248
android:text="园龄"
248249
android:textColor="@android:color/black"
249-
android:textSize="@dimen/h3"/>
250+
android:textSize="@dimen/h3" />
250251

251252
</LinearLayout>
252253

@@ -275,9 +276,9 @@
275276
android:layout_height="wrap_content"
276277
android:layout_marginEnd="48dp"
277278
android:gravity="center"
278-
android:textColor="@color/white"
279+
android:textColor="@color/ph1"
279280
android:textSize="@dimen/h1"
280-
android:visibility="gone"/>
281+
android:visibility="gone" />
281282
</android.support.v7.widget.Toolbar>
282283

283284

@@ -307,12 +308,12 @@
307308
<android.support.design.widget.TabItem
308309
android:layout_width="wrap_content"
309310
android:layout_height="wrap_content"
310-
android:text="动态"/>
311+
android:text="动态" />
311312

312313
<android.support.design.widget.TabItem
313314
android:layout_width="wrap_content"
314315
android:layout_height="wrap_content"
315-
android:text="博客"/>
316+
android:text="博客" />
316317

317318
</com.rae.cnblogs.widget.RaeSkinDesignTabLayout>
318319

@@ -323,6 +324,6 @@
323324
android:layout_width="match_parent"
324325
android:layout_height="wrap_content"
325326
android:background="@color/white"
326-
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
327+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
327328

328329
</android.support.design.widget.CoordinatorLayout>

module-resource/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@
165165
<string name="default_image_desc">正在加载</string>
166166
<string name="loading_blog_content">加载博客中</string>
167167
<string name="unfollow">取消关注</string>
168-
<string name="blogger_default_introduce">这人很懒,什么都没有留</string>
168+
<string name="blogger_default_introduce">本宝宝暂时没有想到我的签名</string>
169169
</resources>

module-widget/src/main/java/com/rae/cnblogs/widget/LoginPlaceholderView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void loadingWithTimer(String msg) {
6363
// 定时器
6464
removeCallbacks(this);
6565
// 连接超时
66-
postDelayed(this, 15000);
66+
postDelayed(this, 6000);
6767
}
6868

6969
@Override

0 commit comments

Comments
 (0)