fixed random fragment crashes
This commit is contained in:
parent
1e956016f5
commit
670d74132d
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue