only restore if we're starting or resuming
This commit is contained in:
parent
c296f4acee
commit
b5a753c1cd
@ -100,7 +100,7 @@ public class QueueFragment extends Fragment {
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
if (queue != null) {
|
if (queue != null) {
|
||||||
onFragmentLoaded();
|
onFragmentLoaded(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class QueueFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
recyclerView.setAdapter(recyclerAdapter);
|
recyclerView.setAdapter(recyclerAdapter);
|
||||||
loadItems();
|
loadItems(true);
|
||||||
EventDistributor.getInstance().register(contentUpdate);
|
EventDistributor.getInstance().register(contentUpdate);
|
||||||
EventBus.getDefault().registerSticky(this);
|
EventBus.getDefault().registerSticky(this);
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ public class QueueFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveScrollPosition();
|
saveScrollPosition();
|
||||||
onFragmentLoaded();
|
onFragmentLoaded(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEventMainThread(FeedItemEvent event) {
|
public void onEventMainThread(FeedItemEvent event) {
|
||||||
@ -450,7 +450,7 @@ public class QueueFragment extends Fragment {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFragmentLoaded() {
|
private void onFragmentLoaded(final boolean restoreScrollPosition) {
|
||||||
if (recyclerAdapter == null) {
|
if (recyclerAdapter == null) {
|
||||||
MainActivity activity = (MainActivity) getActivity();
|
MainActivity activity = (MainActivity) getActivity();
|
||||||
recyclerAdapter = new QueueRecyclerAdapter(activity, itemAccess,
|
recyclerAdapter = new QueueRecyclerAdapter(activity, itemAccess,
|
||||||
@ -465,7 +465,9 @@ public class QueueFragment extends Fragment {
|
|||||||
recyclerView.setVisibility(View.VISIBLE);
|
recyclerView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreScrollPosition();
|
if (restoreScrollPosition) {
|
||||||
|
restoreScrollPosition();
|
||||||
|
}
|
||||||
|
|
||||||
// we need to refresh the options menu because it sometimes
|
// we need to refresh the options menu because it sometimes
|
||||||
// needs data that may have just been loaded.
|
// needs data that may have just been loaded.
|
||||||
@ -554,7 +556,7 @@ public class QueueFragment extends Fragment {
|
|||||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||||
if ((arg & EVENTS) != 0) {
|
if ((arg & EVENTS) != 0) {
|
||||||
Log.d(TAG, "arg: " + arg);
|
Log.d(TAG, "arg: " + arg);
|
||||||
loadItems();
|
loadItems(false);
|
||||||
if (isUpdatingFeeds != updateRefreshMenuItemChecker.isRefreshing()) {
|
if (isUpdatingFeeds != updateRefreshMenuItemChecker.isRefreshing()) {
|
||||||
getActivity().supportInvalidateOptionsMenu();
|
getActivity().supportInvalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
@ -562,7 +564,7 @@ public class QueueFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void loadItems() {
|
private void loadItems(final boolean restoreScrollPosition) {
|
||||||
Log.d(TAG, "loadItems()");
|
Log.d(TAG, "loadItems()");
|
||||||
if(subscription != null) {
|
if(subscription != null) {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
@ -579,7 +581,7 @@ public class QueueFragment extends Fragment {
|
|||||||
if(items != null) {
|
if(items != null) {
|
||||||
progLoading.setVisibility(View.GONE);
|
progLoading.setVisibility(View.GONE);
|
||||||
queue = items;
|
queue = items;
|
||||||
onFragmentLoaded();
|
onFragmentLoaded(restoreScrollPosition);
|
||||||
if(recyclerAdapter != null) {
|
if(recyclerAdapter != null) {
|
||||||
recyclerAdapter.notifyDataSetChanged();
|
recyclerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user