fix crash in TimelineFragment
This commit is contained in:
parent
b2c0ed69f6
commit
67f90d050c
1 changed files with 24 additions and 20 deletions
|
@ -206,6 +206,9 @@ public class TimelineFragment extends SFragment implements
|
|||
|| kind == Kind.LIST) {
|
||||
hashtagOrId = arguments.getString(HASHTAG_OR_ID_ARG);
|
||||
}
|
||||
|
||||
adapter = new TimelineAdapter(dataSource, this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,9 +221,6 @@ public class TimelineFragment extends SFragment implements
|
|||
progressBar = rootView.findViewById(R.id.progress_bar);
|
||||
nothingMessageView = rootView.findViewById(R.id.nothing_message);
|
||||
|
||||
adapter = new TimelineAdapter(dataSource, this);
|
||||
|
||||
|
||||
setupSwipeRefreshLayout();
|
||||
setupRecyclerView();
|
||||
updateAdapter();
|
||||
|
@ -835,6 +835,7 @@ public class TimelineFragment extends SFragment implements
|
|||
}
|
||||
|
||||
private void onFetchTimelineFailure(Exception exception, FetchEnd fetchEnd, int position) {
|
||||
if(isAdded()) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
|
||||
if (fetchEnd == FetchEnd.MIDDLE && !statuses.get(position).isRight()) {
|
||||
|
@ -852,6 +853,7 @@ public class TimelineFragment extends SFragment implements
|
|||
fulfillAnyQueuedFetches(fetchEnd);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void fulfillAnyQueuedFetches(FetchEnd fetchEnd) {
|
||||
switch (fetchEnd) {
|
||||
|
@ -1055,12 +1057,14 @@ public class TimelineFragment extends SFragment implements
|
|||
private final ListUpdateCallback listUpdateCallback = new ListUpdateCallback() {
|
||||
@Override
|
||||
public void onInserted(int position, int count) {
|
||||
if(isAdded()) {
|
||||
adapter.notifyItemRangeInserted(position, count);
|
||||
Context context = getContext();
|
||||
if (position == 0 && context != null) {
|
||||
recyclerView.scrollBy(0, Utils.dpToPx(context, -30));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved(int position, int count) {
|
||||
|
|
Loading…
Reference in a new issue