Correctly handle folder heirarchies. (part 2, working)

This commit is contained in:
dosiecki 2015-03-30 12:24:20 -07:00
parent bbd9385a3f
commit 02909c12f0
5 changed files with 11 additions and 9 deletions

View file

@ -364,8 +364,8 @@ public class FolderListAdapter extends BaseExpandableListAdapter {
List<Feed> activeFeeds = new ArrayList<Feed>();
int neutCount = 0;
int posCount = 0;
for (Long feedId : folders.get(folderName).feedIds) {
Feed f = feeds.get(feedId.toString());
for (String feedId : folders.get(folderName).feedIds) {
Feed f = feeds.get(feedId);
if (f != null) {
if (((currentState == StateFilter.BEST) && (f.positiveCount > 0)) ||
((currentState == StateFilter.SOME) && ((f.positiveCount + f.neutralCount > 0))) ||

View file

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.List;
import com.newsblur.database.DatabaseConstants;
import com.newsblur.util.AppConstants;
public class Folder {
@ -18,7 +19,7 @@ public class Folder {
/** Set of any children folders contained in this folder. NOTE: this is a one-to-many set! */
public List<String> children;
/** Set of any feeds contained in this folder. */
public List<Long> feedIds;
public List<String> feedIds;
public static Folder fromCursor(Cursor c) {
if (c.isBeforeFirst()) {
@ -33,8 +34,8 @@ public class Folder {
folder.children = new ArrayList<String>();
for (String name : TextUtils.split(children, ",")) { folder.children.add(name);}
String feeds = c.getString(c.getColumnIndex(DatabaseConstants.FOLDER_FEED_IDS));
folder.feedIds = new ArrayList<Long>();
for (String id : TextUtils.split(feeds, ",")) { folder.feedIds.add(Long.valueOf(id));}
folder.feedIds = new ArrayList<String>();
for (String id : TextUtils.split(feeds, ",")) { folder.feedIds.add(id);}
return folder;
}
@ -50,6 +51,7 @@ public class Folder {
public String flatName() {
StringBuilder builder = new StringBuilder();
for (String parentName : parents) {
if (parentName.equals(AppConstants.ROOT_FOLDER)) continue;
builder.append(parentName);
builder.append(" - ");
}

View file

@ -105,11 +105,11 @@ public class FeedFolderResponse {
private void parseFolderArray(List<String> parentNames, String name, JsonArray arrayValue) {
if (name == null) name = AppConstants.ROOT_FOLDER;
List<String> children = new ArrayList<String>();
List<Long> feedIds = new ArrayList<Long>();
List<String> feedIds = new ArrayList<String>();
for (JsonElement jsonElement : arrayValue) {
// a folder array contains either feed IDs or nested folder objects
if(jsonElement.isJsonPrimitive()) {
feedIds.add(jsonElement.getAsLong());
feedIds.add(jsonElement.getAsString());
} else {
// if it wasn't a feed ID, it is a nested folder object
Set<Entry<String, JsonElement>> entrySet = ((JsonObject) jsonElement).entrySet();

View file

@ -387,7 +387,7 @@ public class NBSyncService extends Service {
NbActivity.updateAllActivities(false);
// there is a rare issue with feeds that have no folder. capture them for workarounds.
Set<Long> debugFeedIds = new HashSet<Long>();
Set<String> debugFeedIds = new HashSet<String>();
orphanFeedIds = new HashSet<String>();
try {

View file

@ -204,7 +204,7 @@ public class FeedUtils {
public static FeedSet feedSetFromFolderName(String folderName) {
Folder folder = dbHelper.getFolder(folderName);
Set<String> feedIds = new HashSet<String>(folder.feedIds.size());
for (Long id : folder.feedIds) feedIds.add(Long.toString(id));
for (String id : folder.feedIds) feedIds.add(id);
return FeedSet.folder(folderName, feedIds);
}