Wire everything together to load global shared stories

This commit is contained in:
Mark Anderson 2015-02-02 21:04:47 +00:00
parent 23da9f951c
commit 4a81d2963a
9 changed files with 43 additions and 8 deletions

View file

@ -77,6 +77,9 @@
<activity
android:name=".activity.AllSharedStoriesItemsList" />
<activity
android:name=".activity.GlobalSharedStoriesItemsList" />
<activity
android:name=".activity.FolderItemsList" />
@ -95,6 +98,9 @@
<activity
android:name=".activity.AllSharedStoriesReading"/>
<activity
android:name=".activity.GlobalSharedStoriesReading"/>
<activity
android:name=".activity.FolderReading"/>

View file

@ -67,27 +67,26 @@ public class GlobalSharedStoriesItemsList extends ItemsList {
}
}
// Note: the following four methods are required by our parent spec but are not
// relevant since saved stories have no read/unread status nor ordering.
// Story order and read filter are fixed for global shared stories
@Override
public StoryOrder getStoryOrder() {
return PrefsUtils.getStoryOrderForFolder(this, PrefConstants.GLOBAL_SHARED_STORIES_FOLDER_NAME);
return StoryOrder.NEWEST;
}
@Override
public void updateStoryOrderPreference(StoryOrder newValue) {
PrefsUtils.setStoryOrderForFolder(this, PrefConstants.GLOBAL_SHARED_STORIES_FOLDER_NAME, newValue);
// Not supported for global shared stories
}
@Override
protected void updateReadFilterPreference(ReadFilter newValue) {
PrefsUtils.setReadFilterForFolder(this, PrefConstants.GLOBAL_SHARED_STORIES_FOLDER_NAME, newValue);
// Not supported for global shared stories
}
@Override
protected ReadFilter getReadFilter() {
return PrefsUtils.getReadFilterForFolder(this, PrefConstants.GLOBAL_SHARED_STORIES_FOLDER_NAME);
return ReadFilter.UNREAD;
}

View file

@ -253,7 +253,8 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
* Query the DB for the current unreadcount for this view.
*/
private int getUnreadCount() {
if (fs.isAllSaved()) return 0; // saved stories doesn't have unreads
// saved stories and global shared stories don't have unreads
if (fs.isAllSaved() || fs.isGlobalShared()) return 0;
return FeedUtils.dbHelper.getUnreadCount(fs, currentState);
}

View file

@ -655,6 +655,7 @@ public class BlurDatabaseHelper {
q.append(" FROM " + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE);
q.append(DatabaseConstants.JOIN_STORIES_ON_SOCIALFEED_MAP);
q.append(DatabaseConstants.JOIN_FEEDS_ON_STORIES);
q.append(DatabaseConstants.JOIN_SOCIAL_FEEDS_ON_SOCIALFEED_MAP);
DatabaseConstants.appendStorySelectionGroupOrder(q, readFilter, order, stateFilter, DatabaseConstants.STORY_TABLE + "." + DatabaseConstants.STORY_ID);
return rawQuery(q.toString(), null, cancellationSignal);
@ -668,6 +669,14 @@ public class BlurDatabaseHelper {
q.append(" ORDER BY " + DatabaseConstants.STARRED_STORY_ORDER);
return rawQuery(q.toString(), null, cancellationSignal);
} else if (fs.isGlobalShared()) {
StringBuilder q = new StringBuilder(DatabaseConstants.MULTIFEED_STORIES_QUERY_BASE);
q.append(" FROM " + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE);
q.append(DatabaseConstants.JOIN_STORIES_ON_SOCIALFEED_MAP);
q.append(DatabaseConstants.JOIN_FEEDS_ON_STORIES);
q.append(" ORDER BY " + DatabaseConstants.STARRED_STORY_ORDER);
return rawQuery(q.toString(), null, cancellationSignal);
} else {
throw new IllegalStateException("Asked to get stories for FeedSet of unknown type.");
}

View file

@ -325,6 +325,9 @@ public class DatabaseConstants {
public static final String JOIN_STORIES_ON_SOCIALFEED_MAP =
" INNER JOIN " + STORY_TABLE + " ON " + STORY_TABLE + "." + STORY_ID + " = " + SOCIALFEED_STORY_MAP_TABLE + "." + SOCIALFEED_STORY_STORYID;
public static final String JOIN_SOCIAL_FEEDS_ON_SOCIALFEED_MAP =
" INNER JOIN " + SOCIALFEED_TABLE + " ON " + SOCIALFEED_TABLE + "." + SOCIAL_FEED_ID + " = " + SOCIALFEED_STORY_MAP_TABLE + "." + SOCIALFEED_STORY_USER_ID;
public static final String STARRED_STORY_ORDER = STORY_STARRED_DATE + " DESC";
/**

View file

@ -76,6 +76,7 @@ public class APIConstants {
public static final String PARAMETER_ORDER = "order";
public static final String PARAMETER_READ_FILTER = "read_filter";
public static final String PARAMETER_INCLUDE_TIMESTAMPS = "include_timestamps";
public static final String PARAMETER_GLOBAL_FEED = "global_feed";
public static final String VALUE_PREFIX_SOCIAL = "social:";
public static final String VALUE_ALLSOCIAL = "river:blurblogs"; // the magic value passed to the mark-read API for all social feeds

View file

@ -294,6 +294,9 @@ public class APIManager {
uri = Uri.parse(APIConstants.URL_SHARED_RIVER_STORIES);
} else if (fs.isAllSaved()) {
uri = Uri.parse(APIConstants.URL_STARRED_STORIES);
} else if (fs.isGlobalShared()) {
uri = Uri.parse(APIConstants.URL_SHARED_RIVER_STORIES);
values.put(APIConstants.PARAMETER_GLOBAL_FEED, Boolean.TRUE.toString());
} else {
throw new IllegalStateException("Asked to get stories for FeedSet of unknown type.");
}

View file

@ -216,12 +216,14 @@ public class FeedSet implements Serializable {
s.append("|");
}
s.append(isAllSaved);
s.append("|");
s.append(isGlobalShared);
return s.toString();
}
public static FeedSet fromCompactSerial(String s) {
String[] fields = TextUtils.split(s, "\\|");
if ((fields.length != 4) || (!fields[0].equals("FS"))) throw new IllegalArgumentException("invalid compact form");
if ((fields.length != 5) || (!fields[0].equals("FS"))) throw new IllegalArgumentException("invalid compact form");
if (! fields[1].equals(COM_SER_NUL)) {
HashSet<String> feeds = new HashSet<String>();
for (String id : TextUtils.split(fields[1], ",")) feeds.add(id);
@ -239,6 +241,9 @@ public class FeedSet implements Serializable {
if (fields[3].equals(Boolean.TRUE.toString())) {
return new FeedSet(null, null, true, false);
}
if (fields[4].equals(Boolean.TRUE.toString())) {
return new FeedSet(null, null, false, true);
}
throw new IllegalArgumentException("invalid compact form");
}

View file

@ -373,6 +373,10 @@ public class PrefsUtils {
return getStoryOrderForFolder(context, PrefConstants.SAVED_STORIES_FOLDER_NAME);
}
if (fs.isGlobalShared()) {
return StoryOrder.NEWEST;
}
throw new IllegalArgumentException( "unknown type of feed set" );
}
@ -401,6 +405,10 @@ public class PrefsUtils {
return getReadFilterForFolder(context, PrefConstants.SAVED_STORIES_FOLDER_NAME);
}
if (fs.isGlobalShared()) {
return ReadFilter.UNREAD;
}
throw new IllegalArgumentException( "unknown type of feed set" );
}