1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2024-12-19 12:04:40 +01:00

fixed random fragment crashes

This commit is contained in:
Mariotaku Lee 2016-02-26 19:06:37 +08:00
parent 1e956016f5
commit 670d74132d
2 changed files with 15 additions and 1 deletions

View File

@ -72,13 +72,14 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
public int getStatuses(final long maxId, final long sinceId) {
if (getContext() == null) return -1;
final Bundle args = new Bundle(getArguments());
args.putBoolean(EXTRA_MAKE_GAP, false);
args.putLong(EXTRA_MAX_ID, maxId);
args.putLong(EXTRA_SINCE_ID, sinceId);
args.putBoolean(EXTRA_FROM_USER, true);
getLoaderManager().restartLoader(0, args, this);
return -1;
return 0;
}

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.util;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnScrollListener;
import android.view.MotionEvent;
@ -52,6 +53,9 @@ public class ContentListScrollListener extends OnScrollListener {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (mContentListSupport instanceof Fragment) {
if (((Fragment) mContentListSupport).getContext() == null) return;
}
if (mScrollState != RecyclerView.SCROLL_STATE_IDLE) {
postNotifyScrollStateChanged();
}
@ -60,6 +64,9 @@ public class ContentListScrollListener extends OnScrollListener {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (mContentListSupport instanceof Fragment) {
if (((Fragment) mContentListSupport).getContext() == null) return;
}
//Reset mScrollSum when scrolling in reverse direction
if (dy * mScrollSum < 0) {
mScrollSum = 0;
@ -79,6 +86,9 @@ public class ContentListScrollListener extends OnScrollListener {
}
private void postNotifyScrollStateChanged() {
if (mContentListSupport instanceof Fragment) {
if (((Fragment) mContentListSupport).getContext() == null) return;
}
if (mViewCallback != null) {
mViewCallback.post(new Runnable() {
@Override
@ -96,6 +106,9 @@ public class ContentListScrollListener extends OnScrollListener {
}
private void notifyScrollStateChanged() {
if (mContentListSupport instanceof Fragment) {
if (((Fragment) mContentListSupport).getContext() == null) return;
}
final Object adapter = mContentListSupport.getAdapter();
if (!(adapter instanceof ILoadMoreSupportAdapter)) return;
final ILoadMoreSupportAdapter loadMoreAdapter = (ILoadMoreSupportAdapter) adapter;