Skip to content

Commit 21f7ae8

Browse files
committed
修复登录问题,使用传统的Web登录方式。
1 parent dbd1002 commit 21f7ae8

31 files changed

+947
-484
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
<activity
6767
android:name=".activity.LoginActivity"
6868
android:launchMode="singleTop"
69-
android:screenOrientation="portrait"
70-
android:windowSoftInputMode="stateVisible"/>
69+
android:screenOrientation="portrait"/>
7170

7271

7372
<!--网页登录-->
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.rae.cnblogs;
2+
3+
import android.support.v7.widget.LinearLayoutManager;
4+
import android.support.v7.widget.RecyclerView;
5+
6+
/**
7+
* view ext compat
8+
* Created by ChenRui on 2017/10/23 0023 21:43.
9+
*/
10+
public class RaeViewCompat {
11+
12+
13+
/**
14+
* 滚动到顶部
15+
*/
16+
public static void scrollToTop(RecyclerView recyclerView) {
17+
if (recyclerView == null) return;
18+
19+
20+
//先从RecyclerView的LayoutManager中获取第一项和最后一项的Position
21+
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
22+
int firstItem = layoutManager.findFirstVisibleItemPosition();
23+
int lastItem = layoutManager.findLastVisibleItemPosition();
24+
int visibleCount = lastItem - firstItem;
25+
26+
// 已经处于顶部
27+
if (firstItem <= 1) {
28+
return;
29+
}
30+
31+
// 超过一屏
32+
if (lastItem > visibleCount) {
33+
layoutManager.scrollToPosition(visibleCount + 3);
34+
}
35+
36+
recyclerView.smoothScrollToPosition(0);
37+
}
38+
}

app/src/main/java/com/rae/cnblogs/activity/BlogContentActivity.java

Lines changed: 116 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
package com.rae.cnblogs.activity;
22

3+
import android.content.DialogInterface;
34
import android.os.Bundle;
45
import android.support.annotation.Nullable;
56
import android.support.v4.app.Fragment;
6-
import android.support.v4.app.FragmentTransaction;
7+
import android.support.v7.widget.LinearLayoutManager;
8+
import android.support.v7.widget.RecyclerView;
79
import android.text.TextUtils;
810
import android.view.View;
911
import android.widget.TextView;
1012

1113
import com.rae.cnblogs.AppRoute;
1214
import com.rae.cnblogs.AppUI;
1315
import com.rae.cnblogs.R;
16+
import com.rae.cnblogs.RaeViewCompat;
1417
import com.rae.cnblogs.RxObservable;
18+
import com.rae.cnblogs.adapter.BlogContentAdapter;
1519
import com.rae.cnblogs.dialog.DialogProvider;
1620
import com.rae.cnblogs.dialog.IAppDialog;
1721
import com.rae.cnblogs.dialog.impl.BlogShareDialog;
18-
import com.rae.cnblogs.fragment.BlogContentFragment;
22+
import com.rae.cnblogs.dialog.impl.EditCommentDialog;
23+
import com.rae.cnblogs.dialog.impl.HintCardDialog;
24+
import com.rae.cnblogs.presenter.CnblogsPresenterFactory;
25+
import com.rae.cnblogs.presenter.IBlogCommentPresenter;
1926
import com.rae.cnblogs.sdk.ApiDefaultObserver;
2027
import com.rae.cnblogs.sdk.bean.BlogBean;
28+
import com.rae.cnblogs.sdk.bean.BlogCommentBean;
2129
import com.rae.cnblogs.sdk.bean.BlogType;
2230
import com.rae.cnblogs.sdk.db.DbBlog;
2331
import com.rae.cnblogs.sdk.db.DbFactory;
2432
import com.rae.cnblogs.widget.PlaceholderView;
33+
import com.rae.swift.Rx;
2534

2635
import org.jsoup.Jsoup;
2736

@@ -41,7 +50,7 @@
4150
* 博文查看
4251
* Created by ChenRui on 2016/12/6 21:38.
4352
*/
44-
public class BlogContentActivity extends SwipeBackBaseActivity {
53+
public class BlogContentActivity extends SwipeBackBaseActivity implements EditCommentDialog.OnEditCommentListener, IBlogCommentPresenter.IBlogCommentView {
4554

4655
// @BindView(R.id.tool_bar)
4756
// Toolbar mToolbar;
@@ -72,12 +81,17 @@ public class BlogContentActivity extends SwipeBackBaseActivity {
7281

7382
@BindView(R.id.placeholder)
7483
PlaceholderView mPlaceholderView;
84+
@BindView(R.id.recycler_view)
85+
RecyclerView mRecyclerView;
86+
7587

7688
private BlogShareDialog mShareDialog;
7789
private BlogBean mBlog;
7890
private BlogType mBlogType;
79-
// private BlogCommentFragment mBlogCommentFragment;
80-
private BlogContentFragment mBlogContentFragment;
91+
// private BlogCommentFragment mBlogCommentFragment;
92+
// private BlogContentFragment mBlogContentFragment;
93+
private EditCommentDialog mEditCommentDialog;
94+
private IBlogCommentPresenter mCommentPresenter;
8195

8296
@Override
8397
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -103,6 +117,9 @@ protected void onViewSourceClick() {
103117
}
104118
};
105119

120+
mEditCommentDialog = new EditCommentDialog(getContext());
121+
mEditCommentDialog.setOnEditCommentListener(this);
122+
mCommentPresenter = CnblogsPresenterFactory.getBlogCommentPresenter(this, mBlogType, this);
106123
if (mBlog != null) {
107124
mPlaceholderView.dismiss();
108125
onLoadData(mBlog);
@@ -127,6 +144,10 @@ else if (!TextUtils.isEmpty(blogId)) {
127144
mPlaceholderView.empty("博客不存在");
128145
}
129146

147+
148+
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
149+
mRecyclerView.setAdapter(new BlogContentAdapter());
150+
130151
}
131152

132153
/**
@@ -218,15 +239,15 @@ private void onLoadData(BlogBean blog) {
218239
// 评论
219240
// mBlogCommentFragment = BlogCommentFragment.newInstance(mBlog, mBlogType);
220241
// 内容
221-
mBlogContentFragment = BlogContentFragment.newInstance(mBlog, mBlogType);
242+
// mBlogContentFragment = BlogContentFragment.newInstance(mBlog, mBlogType);
222243

223244

224245
// 加载Fragment
225-
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
246+
// FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
226247
// transaction.add(R.id.fl_comment, mBlogCommentFragment);
227-
transaction.add(R.id.fl_content, mBlogContentFragment);
248+
// transaction.add(R.id.fl_content, mBlogContentFragment);
228249
// fix bugly #472
229-
transaction.commitAllowingStateLoss();
250+
// transaction.commitAllowingStateLoss();
230251
}
231252

232253
// 分享
@@ -245,6 +266,7 @@ public void onCommentClick() {
245266
// 发表评论
246267
@OnClick(R.id.tv_edit_comment)
247268
public void onEditCommentClick() {
269+
mEditCommentDialog.show();
248270
// 通知里面的评论打开发表对话框
249271
// EventBus.getDefault().post(new EditCommentEvent());
250272
}
@@ -270,8 +292,92 @@ public void onActionBarClick() {
270292
// if (mCommentLayout.getVisibility() == View.VISIBLE) {
271293
// mBlogCommentFragment.scrollToTop();
272294
// } else {
273-
mBlogContentFragment.scrollToTop();
295+
// mBlogContentFragment.scrollToTop();
274296
// }
297+
298+
RaeViewCompat.scrollToTop(mRecyclerView);
299+
}
300+
301+
@Override
302+
public void onPostComment(String content, BlogCommentBean parent, boolean isReference) {
303+
// 发表评论
304+
AppUI.loading(getContext(), "正在发表..");
305+
mCommentPresenter.post(parent);
306+
mEditCommentDialog.dismiss();
307+
}
308+
309+
@Override
310+
public void onLoadCommentSuccess(List<BlogCommentBean> data) {
311+
// 不用处理
312+
}
313+
314+
@Override
315+
public BlogBean getBlog() {
316+
return mBlog;
317+
}
318+
319+
@Override
320+
public void onLoadCommentEmpty() {
321+
// 不用处理
322+
}
323+
324+
@Override
325+
public void onLoadMoreCommentEmpty() {
326+
// 不用处理
327+
}
328+
329+
@Override
330+
public String getCommentContent() {
331+
return mEditCommentDialog.getCommentContent();
332+
}
333+
334+
@Override
335+
public void onPostCommentFailed(String msg) {
336+
AppUI.dismiss();
337+
AppUI.failed(getContext(), msg);
338+
}
339+
340+
@Override
341+
public void onPostCommentSuccess() {
342+
AppUI.dismiss();
343+
mEditCommentDialog.dismiss();
344+
// 评论数量加1
345+
int comment = Rx.parseInt(mBlog.getComment()) + 1;
346+
mCommentBadgeView.setText(String.valueOf(comment));
347+
348+
if (config().hasCommentGuide()) {
349+
AppUI.toastInCenter(getContext(), "您伟大的讲话发表成功");
350+
} else {
351+
HintCardDialog dialog = new HintCardDialog(getContext());
352+
dialog.setMessage(getString(R.string.dialog_tips_post_comment));
353+
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
354+
@Override
355+
public void onDismiss(DialogInterface dialog) {
356+
config().commentGuide();
357+
}
358+
});
359+
dialog.show();
360+
}
361+
}
362+
363+
@Override
364+
public boolean enableReferenceComment() {
365+
return mEditCommentDialog.enableReferenceComment();
366+
}
367+
368+
@Override
369+
public void onDeleteCommentSuccess(BlogCommentBean item) {
370+
// 不用处理
371+
}
372+
373+
@Override
374+
public void onDeleteCommentFailed(String msg) {
375+
// 不用处理
376+
}
377+
378+
@Override
379+
public void onLoadCommentFailed(String message) {
380+
// 不用处理
275381
}
276382

277383

app/src/main/java/com/rae/cnblogs/activity/CategoryActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CategoryActivity extends BaseActivity {
1717

1818
@Override
1919
protected void onCreate(@Nullable Bundle savedInstanceState) {
20-
overridePendingTransition(com.rae.cnblogs.R.anim.slide_in_bottom, 0);
20+
overridePendingTransition(com.rae.cnblogs.R.anim.slide_in_bottom, android.R.anim.fade_out);
2121
super.onCreate(savedInstanceState);
2222
setContentView(R.layout.activity_category);
2323
showHomeAsUp();

0 commit comments

Comments
 (0)