Fixed issue whereby when reading in feedReading, older pages would deleted due to passed parameter

This commit is contained in:
RyanBateman 2012-10-03 10:35:11 -04:00
parent 28f55ed04d
commit bebeef24cf
2 changed files with 27 additions and 43 deletions

View file

@ -26,6 +26,7 @@ public class AllStoriesReading extends Reading {
private int currentPage;
private ArrayList<String> feedIds;
private boolean stopLoading = false;
private boolean requestedPage = false;
@Override
protected void onCreate(Bundle savedInstanceBundle) {
@ -82,27 +83,12 @@ public class AllStoriesReading extends Reading {
@Override
public void checkStoryCount(int position) {
if (position == stories.getCount() - 1) {
boolean loadMore = false;
switch (currentState) {
case AppConstants.STATE_ALL:
loadMore = positiveCount + neutralCount + negativeCount > stories.getCount();
break;
case AppConstants.STATE_BEST:
loadMore = positiveCount > stories.getCount();
break;
case AppConstants.STATE_SOME:
loadMore = positiveCount + neutralCount > stories.getCount();
break;
}
if (loadMore) {
currentPage += 1;
triggerRefresh(currentPage);
} else {
Log.d(TAG, "No need");
}
if (position == stories.getCount() - 1 && !stopLoading && !requestedPage) {
requestedPage = true;
currentPage += 1;
triggerRefresh(currentPage);
} else {
Log.d(TAG, "No need");
}
}
@ -129,6 +115,7 @@ public class AllStoriesReading extends Reading {
public void updateAfterSync() {
setSupportProgressBarIndeterminateVisibility(false);
stories.requery();
requestedPage = false;
readingAdapter.notifyDataSetChanged();
checkStoryCount(pager.getCurrentItem());
}

View file

@ -28,6 +28,7 @@ public class FeedReading extends Reading {
private Feed feed;
private int currentPage;
private boolean stopLoading = false;
private boolean requestedPage = false;
@Override
protected void onCreate(Bundle savedInstanceBundle) {
@ -77,30 +78,24 @@ public class FeedReading extends Reading {
checkStoryCount(position);
}
}
@Override
public void updateAfterSync() {
setSupportProgressBarIndeterminateVisibility(false);
stories.requery();
requestedPage = false;
readingAdapter.notifyDataSetChanged();
checkStoryCount(pager.getCurrentItem());
}
@Override
public void checkStoryCount(int position) {
if (position == stories.getCount() - 1) {
boolean loadMore = false;
switch (currentState) {
case AppConstants.STATE_ALL:
loadMore = feed.positiveCount + feed.neutralCount + feed.negativeCount > stories.getCount();
break;
case AppConstants.STATE_BEST:
loadMore = feed.positiveCount > stories.getCount();
break;
case AppConstants.STATE_SOME:
loadMore = feed.positiveCount + feed.neutralCount > stories.getCount();
break;
}
if (loadMore) {
currentPage += 1;
triggerRefresh(currentPage);
} else {
Log.d(TAG, "No need");
}
if (position == stories.getCount() - 1 && !stopLoading && !requestedPage) {
requestedPage = true;
currentPage += 1;
triggerRefresh(currentPage);
} else {
Log.d(TAG, "No need");
}
}
@ -124,8 +119,10 @@ public class FeedReading extends Reading {
final Intent intent = new Intent(Intent.ACTION_SYNC, null, this, SyncService.class);
intent.putExtra(SyncService.EXTRA_STATUS_RECEIVER, syncFragment.receiver);
intent.putExtra(SyncService.SYNCSERVICE_TASK, SyncService.EXTRA_TASK_FEED_UPDATE);
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
intent.putExtra(SyncService.EXTRA_TASK_FEED_ID, feedId);
if (page > 1) {
intent.putExtra(SyncService.EXTRA_TASK_PAGE_NUMBER, Integer.toString(page));
}
startService(intent);
}
}