Removed FeedManager
DBReader, DBTasks and DBWriter should be used instead from now on
This commit is contained in:
parent
6d1a8535f5
commit
ca795a3fdc
|
@ -17,8 +17,7 @@ import de.danoeh.antennapod.storage.DBReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays completed and failed downloads in a list. The data comes from the
|
* Displays completed and failed downloads in a list.
|
||||||
* FeedManager.
|
|
||||||
*/
|
*/
|
||||||
public class DownloadLogActivity extends SherlockListActivity {
|
public class DownloadLogActivity extends SherlockListActivity {
|
||||||
private static final String TAG = "DownloadLogActivity";
|
private static final String TAG = "DownloadLogActivity";
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class EventDistributor extends Observable {
|
||||||
super.addObserver(observer);
|
super.addObserver(observer);
|
||||||
if (!(observer instanceof EventListener)) {
|
if (!(observer instanceof EventListener)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Observer must be instance of FeedManager.EventListener");
|
"Observer must be instance of EventListener");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,6 @@ package de.danoeh.antennapod.storage;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.feed.Feed;
|
|
||||||
import de.danoeh.antennapod.feed.FeedItem;
|
import de.danoeh.antennapod.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.feed.SearchResult;
|
import de.danoeh.antennapod.feed.SearchResult;
|
||||||
import de.danoeh.antennapod.util.comparator.SearchResultValueComparator;
|
import de.danoeh.antennapod.util.comparator.SearchResultValueComparator;
|
||||||
|
@ -55,227 +54,4 @@ public class FeedSearcher {
|
||||||
Collections.sort(result, new SearchResultValueComparator());
|
Collections.sort(result, new SearchResultValueComparator());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
*//** Performs a search in all feeds or one specific feed. *//*
|
|
||||||
public static ArrayList<SearchResult> performSearch(final Context context,
|
|
||||||
final String query, final Feed selectedFeed) {
|
|
||||||
final String lcQuery = query.toLowerCase();
|
|
||||||
final ArrayList<SearchResult> result = new ArrayList<SearchResult>();
|
|
||||||
if (selectedFeed == null) {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Performing global search");
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Searching Feed titles");
|
|
||||||
searchFeedtitles(lcQuery, result);
|
|
||||||
} else if (AppConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "Performing search on specific feed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Searching Feeditem titles");
|
|
||||||
searchFeedItemTitles(lcQuery, result, selectedFeed);
|
|
||||||
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Searching item-chaptertitles");
|
|
||||||
searchFeedItemChapters(lcQuery, result, selectedFeed);
|
|
||||||
|
|
||||||
Looper.prepare();
|
|
||||||
DBTasks.searchFeedItemDescription(context, selectedFeed, lcQuery,
|
|
||||||
new DBTasks.QueryTaskCallback() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleResult(Cursor cResult) {
|
|
||||||
searchFeedItemContentEncodedCursor(context, lcQuery, result,
|
|
||||||
selectedFeed, cResult);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCompletion() {
|
|
||||||
DBTasks.searchFeedItemContentEncoded(context,
|
|
||||||
selectedFeed, lcQuery,
|
|
||||||
new DBTasks.QueryTaskCallback() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleResult(Cursor cResult) {
|
|
||||||
searchFeedItemDescriptionCursor(context,
|
|
||||||
lcQuery, result, selectedFeed,
|
|
||||||
cResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCompletion() {
|
|
||||||
Looper.myLooper().quit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Looper.loop();
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Sorting results");
|
|
||||||
Collections.sort(result, new SearchResultValueComparator());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedtitles(String query,
|
|
||||||
ArrayList<SearchResult> destination) {
|
|
||||||
FeedManager manager = FeedManager.getInstance();
|
|
||||||
for (Feed feed : manager.getFeeds()) {
|
|
||||||
SearchResult result = createSearchResult(feed, query, feed
|
|
||||||
.getTitle().toLowerCase(), VALUE_FEED_TITLE);
|
|
||||||
if (result != null) {
|
|
||||||
destination.add(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemTitles(String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed selectedFeed) {
|
|
||||||
FeedManager manager = FeedManager.getInstance();
|
|
||||||
if (selectedFeed == null) {
|
|
||||||
for (Feed feed : manager.getFeeds()) {
|
|
||||||
searchFeedItemTitlesSingleFeed(query, destination, feed);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
searchFeedItemTitlesSingleFeed(query, destination, selectedFeed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemTitlesSingleFeed(String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed feed) {
|
|
||||||
for (FeedItem item : feed.getItems()) {
|
|
||||||
SearchResult result = createSearchResult(item, query, item
|
|
||||||
.getTitle().toLowerCase(), VALUE_ITEM_TITLE);
|
|
||||||
if (result != null) {
|
|
||||||
result.setSubtitle(PodcastApp.getInstance().getString(
|
|
||||||
R.string.found_in_title_label));
|
|
||||||
destination.add(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemChapters(String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed selectedFeed) {
|
|
||||||
if (selectedFeed == null) {
|
|
||||||
for (Feed feed : manager.getFeeds()) {
|
|
||||||
searchFeedItemChaptersSingleFeed(query, destination, feed);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
searchFeedItemChaptersSingleFeed(query, destination, selectedFeed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemChaptersSingleFeed(String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed feed) {
|
|
||||||
for (FeedItem item : feed.getItems()) {
|
|
||||||
if (item.getChapters() != null) {
|
|
||||||
for (Chapter sc : item.getChapters()) {
|
|
||||||
SearchResult result = createSearchResult(item, query, sc
|
|
||||||
.getTitle().toLowerCase(), VALUE_ITEM_CHAPTER);
|
|
||||||
if (result != null) {
|
|
||||||
result.setSubtitle(PodcastApp.getInstance().getString(
|
|
||||||
R.string.found_in_chapters_label));
|
|
||||||
destination.add(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemDescriptionCursor(Context context, String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed feed, Cursor cursor) {
|
|
||||||
FeedManager manager = FeedManager.getInstance();
|
|
||||||
List<FeedItem> items = DBReader.extractItemlistFromCursor(cursor);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
final long itemId = cursor
|
|
||||||
.getLong(PodDBAdapter.IDX_FI_EXTRA_ID);
|
|
||||||
String content = cursor
|
|
||||||
.getString(PodDBAdapter.IDX_FI_EXTRA_DESCRIPTION);
|
|
||||||
if (content != null) {
|
|
||||||
content = content.toLowerCase();
|
|
||||||
final long feedId = cursor
|
|
||||||
.getLong(PodDBAdapter.IDX_FI_EXTRA_FEED);
|
|
||||||
FeedItem item = null;
|
|
||||||
if (feed == null) {
|
|
||||||
item = manager.getFeedItem(itemId, feedId);
|
|
||||||
} else {
|
|
||||||
item = manager.getFeedItem(itemId, feed);
|
|
||||||
}
|
|
||||||
if (item != null) {
|
|
||||||
SearchResult searchResult = createSearchResult(item,
|
|
||||||
query, content, VALUE_ITEM_DESCRIPTION);
|
|
||||||
if (searchResult != null) {
|
|
||||||
searchResult.setSubtitle(PodcastApp.getInstance()
|
|
||||||
.getString(
|
|
||||||
R.string.found_in_shownotes_label));
|
|
||||||
destination.add(searchResult);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void searchFeedItemContentEncodedCursor(Context context, String query,
|
|
||||||
ArrayList<SearchResult> destination, Feed feed, Cursor cursor) {
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
final long itemId = cursor
|
|
||||||
.getLong(PodDBAdapter.IDX_FI_EXTRA_ID);
|
|
||||||
String content = cursor
|
|
||||||
.getString(PodDBAdapter.IDX_FI_EXTRA_CONTENT_ENCODED);
|
|
||||||
if (content != null) {
|
|
||||||
content = content.toLowerCase();
|
|
||||||
|
|
||||||
final long feedId = cursor
|
|
||||||
.getLong(PodDBAdapter.IDX_FI_EXTRA_FEED);
|
|
||||||
FeedItem item = null;
|
|
||||||
if (feed == null) {
|
|
||||||
item = manager.getFeedItem(itemId, feedId);
|
|
||||||
} else {
|
|
||||||
item = manager.getFeedItem(itemId, feed);
|
|
||||||
}
|
|
||||||
if (item != null) {
|
|
||||||
SearchResult searchResult = createSearchResult(item,
|
|
||||||
query, content, VALUE_ITEM_DESCRIPTION);
|
|
||||||
if (searchResult != null) {
|
|
||||||
searchResult.setSubtitle(PodcastApp.getInstance()
|
|
||||||
.getString(
|
|
||||||
R.string.found_in_shownotes_label));
|
|
||||||
destination.add(searchResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SearchResult createSearchResult(FeedComponent component,
|
|
||||||
String query, String text, int baseValue) {
|
|
||||||
int bonus = 0;
|
|
||||||
boolean found = false;
|
|
||||||
// try word search
|
|
||||||
Pattern word = Pattern.compile("\b" + query + "\b");
|
|
||||||
Matcher matcher = word.matcher(text);
|
|
||||||
found = matcher.find();
|
|
||||||
if (found) {
|
|
||||||
bonus = VALUE_WORD_MATCH;
|
|
||||||
} else {
|
|
||||||
// search for other occurence
|
|
||||||
found = text.contains(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
return new SearchResult(component, baseValue + bonus);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue