Build tags based on feed properties
This commit is contained in:
parent
3104232e5d
commit
1eb47a2d6b
|
@ -15,6 +15,7 @@ import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||||
public class FeedPreferences {
|
public class FeedPreferences {
|
||||||
|
|
||||||
public static final float SPEED_USE_GLOBAL = -1;
|
public static final float SPEED_USE_GLOBAL = -1;
|
||||||
|
public static final String TAG_ROOT = "#root";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private FeedFilter filter;
|
private FeedFilter filter;
|
||||||
|
@ -36,6 +37,7 @@ public class FeedPreferences {
|
||||||
private float feedPlaybackSpeed;
|
private float feedPlaybackSpeed;
|
||||||
private int feedSkipIntro;
|
private int feedSkipIntro;
|
||||||
private int feedSkipEnding;
|
private int feedSkipEnding;
|
||||||
|
private String[] tags = {TAG_ROOT, "Test 1", "Test 2"};
|
||||||
|
|
||||||
public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
|
public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
|
||||||
this(feedID, autoDownload, true, auto_delete_action, volumeAdaptionSetting,
|
this(feedID, autoDownload, true, auto_delete_action, volumeAdaptionSetting,
|
||||||
|
@ -240,4 +242,12 @@ public class FeedPreferences {
|
||||||
public int getFeedSkipEnding() {
|
public int getFeedSkipEnding() {
|
||||||
return feedSkipEnding;
|
return feedSkipEnding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(String[] tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -867,24 +868,27 @@ public final class DBReader {
|
||||||
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();
|
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();
|
||||||
|
|
||||||
List<NavDrawerData.DrawerItem> items = new ArrayList<>();
|
List<NavDrawerData.DrawerItem> items = new ArrayList<>();
|
||||||
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
|
Map<String, NavDrawerData.FolderDrawerItem> folders = new HashMap<>();
|
||||||
items.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), i, feedCounters.get(feeds.get(i).getId())));
|
for (Feed feed : feeds) {
|
||||||
|
for (String tag : feed.getPreferences().getTags()) {
|
||||||
|
NavDrawerData.FeedDrawerItem drawerItem = new NavDrawerData.FeedDrawerItem(feed, feed.getId(),
|
||||||
|
feedCounters.get(feed.getId()));
|
||||||
|
if (FeedPreferences.TAG_ROOT.equals(tag)) {
|
||||||
|
items.add(drawerItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NavDrawerData.FolderDrawerItem folder;
|
||||||
|
if (folders.containsKey(tag)) {
|
||||||
|
folder = folders.get(tag);
|
||||||
|
} else {
|
||||||
|
folder = new NavDrawerData.FolderDrawerItem(tag);
|
||||||
|
folders.put(tag, folder);
|
||||||
|
items.add(folder);
|
||||||
|
}
|
||||||
|
drawerItem.id |= folder.id;
|
||||||
|
folder.children.add(drawerItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NavDrawerData.DrawerItem> folderItems = new ArrayList<>();
|
|
||||||
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
|
|
||||||
folderItems.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 10001 + i,
|
|
||||||
feedCounters.get(feeds.get(i).getId())));
|
|
||||||
}
|
|
||||||
items.add(new NavDrawerData.FolderDrawerItem("Folder 1", folderItems, 10000));
|
|
||||||
|
|
||||||
List<NavDrawerData.DrawerItem> folderItems2 = new ArrayList<>();
|
|
||||||
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
|
|
||||||
folderItems2.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 20001 + i,
|
|
||||||
feedCounters.get(feeds.get(i).getId())));
|
|
||||||
}
|
|
||||||
items.add(new NavDrawerData.FolderDrawerItem("Folder 2", folderItems2, 20000));
|
|
||||||
|
|
||||||
NavDrawerData result = new NavDrawerData(items, queueSize, numNewItems, numDownloadedItems,
|
NavDrawerData result = new NavDrawerData(items, queueSize, numNewItems, numDownloadedItems,
|
||||||
feedCounters, UserPreferences.getEpisodeCleanupAlgorithm().getReclaimableItems());
|
feedCounters, UserPreferences.getEpisodeCleanupAlgorithm().getReclaimableItems());
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.storage;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NavDrawerData {
|
public class NavDrawerData {
|
||||||
|
@ -34,7 +35,7 @@ public class NavDrawerData {
|
||||||
|
|
||||||
public final Type type;
|
public final Type type;
|
||||||
private int layer;
|
private int layer;
|
||||||
public final long id;
|
public long id;
|
||||||
|
|
||||||
public DrawerItem(Type type, long id) {
|
public DrawerItem(Type type, long id) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -55,13 +56,12 @@ public class NavDrawerData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FolderDrawerItem extends DrawerItem {
|
public static class FolderDrawerItem extends DrawerItem {
|
||||||
public final List<DrawerItem> children;
|
public final List<DrawerItem> children = new ArrayList<>();
|
||||||
public final String name;
|
public final String name;
|
||||||
public boolean isOpen;
|
public boolean isOpen;
|
||||||
|
|
||||||
public FolderDrawerItem(String name, List<DrawerItem> children, long id) {
|
public FolderDrawerItem(String name) {
|
||||||
super(DrawerItem.Type.FOLDER, id);
|
super(DrawerItem.Type.FOLDER, name.hashCode() & ~0xFFF); // Drop lower 12 bits for item ids
|
||||||
this.children = children;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue