mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Added deleltion of older stories when viewing a socialfeed's stories and when viewing All Stories.
This commit is contained in:
parent
97a8064715
commit
7175361e33
2 changed files with 18 additions and 2 deletions
|
@ -107,6 +107,17 @@ public class FeedProvider extends ContentProvider {
|
|||
db.delete(DatabaseConstants.STORY_TABLE, null, null);
|
||||
return 1;
|
||||
|
||||
case SOCIALFEED_STORIES:
|
||||
StringBuilder socialDeleteBuilder = new StringBuilder();
|
||||
socialDeleteBuilder.append("DELETE FROM " + DatabaseConstants.STORY_TABLE);
|
||||
socialDeleteBuilder.append(" WHERE " + DatabaseConstants.STORY_ID + " IN (");
|
||||
socialDeleteBuilder.append(" SELECT " + DatabaseConstants.STORY_ID + " FROM ");
|
||||
socialDeleteBuilder.append(DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE + " WHERE ");
|
||||
socialDeleteBuilder.append(DatabaseConstants.SOCIALFEED_STORY_USER_ID + " = ? )");
|
||||
db.execSQL(socialDeleteBuilder.toString(), new String[] { uri.getLastPathSegment() });
|
||||
|
||||
return db.delete(DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE, DatabaseConstants.SOCIALFEED_STORY_USER_ID + " = ?", new String[] { uri.getLastPathSegment() } );
|
||||
|
||||
case INDIVIDUAL_FEED:
|
||||
db.delete(DatabaseConstants.FEED_TABLE, DatabaseConstants.FEED_ID + " = ?", new String[] { uri.getLastPathSegment() } );
|
||||
db.delete(DatabaseConstants.FEED_FOLDER_MAP_TABLE, DatabaseConstants.FEED_FOLDER_FEED_ID + " = ?", new String[] { uri.getLastPathSegment() } );
|
||||
|
|
|
@ -253,7 +253,7 @@ public class APIManager {
|
|||
|
||||
SocialFeedResponse storiesResponse = gson.fromJson(response.responseString, SocialFeedResponse.class);
|
||||
if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
|
||||
|
||||
// If we've successfully retrieved the latest stories for all shared feeds (the first page), delete all previous shared feeds
|
||||
if (TextUtils.equals(pageNumber,"1")) {
|
||||
for (String feedId : feedIds) {
|
||||
Uri storyUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
|
@ -297,13 +297,18 @@ public class APIManager {
|
|||
final APIResponse response = client.get(feedUri.toString(), values);
|
||||
SocialFeedResponse socialFeedResponse = gson.fromJson(response.responseString, SocialFeedResponse.class);
|
||||
if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) {
|
||||
|
||||
Uri storySocialUri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
if (TextUtils.equals(pageNumber, "1")) {
|
||||
contentResolver.delete(storySocialUri, null, null);
|
||||
}
|
||||
|
||||
for (Story story : socialFeedResponse.stories) {
|
||||
insertComments(story);
|
||||
|
||||
Uri storyUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(story.feedId).build();
|
||||
contentResolver.insert(storyUri, story.getValues());
|
||||
|
||||
Uri storySocialUri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
contentResolver.insert(storySocialUri, story.getValues());
|
||||
}
|
||||
if (socialFeedResponse != null && socialFeedResponse.feeds!= null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue