修复第三方下拉刷新依赖的造成的闪退问题

This commit is contained in:
chenjuntao
2018-07-03 09:55:53 +08:00
parent cf41572db7
commit 03eebf2c07
2 changed files with 15 additions and 3 deletions

View File

@ -117,7 +117,6 @@ public class AskQuestionsRecommendsFragment extends ListFragment<AnswerEntity, A
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
refreshLayout.setEnableLoadMore(false);
refreshLayout.setOnRefreshListener(
refreshLayout -> {
if (!mInitRefresh) {
@ -226,6 +225,15 @@ public class AskQuestionsRecommendsFragment extends ListFragment<AnswerEntity, A
mAdapter.viewPagerAutoScroll(false);
}
@Override
public void onStop() {
super.onStop();
if (refreshLayout != null) {
mInitRefresh = false;
refreshLayout.finishRefresh(0);
}
}
public void scrollToTop() {
mLayoutManager.smoothScrollToPosition(mListRv, null, 0);
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
@ -7,7 +8,10 @@
android:id = "@+id/refresh_layout"
android:layout_below = "@id/refresh_hint"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
android:layout_height = "match_parent"
app:srlEnableLoadMore = "false"
app:srlEnableAutoLoadMore = "false"
app:srlEnableClipFooterWhenFixedBehind = "false">
<com.gh.common.view.SwipeRefreshHeader
android:id = "@+id/swipe_refresh_header"