diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-08-04 21:35:44 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-08-04 21:35:44 +0200 |
commit | 24c50f7840ffd6af0ff16aa1e73f43613696d637 (patch) | |
tree | 0930228f0048ddd713e41299d7441dcf4052b3d1 /src/de/danoeh/antennapod/activity | |
parent | 355fc8114f61ed2ecde8f118c4d30d209ceb6198 (diff) | |
download | AntennaPod-24c50f7840ffd6af0ff16aa1e73f43613696d637.zip |
Ported search components to DB*-classes
Diffstat (limited to 'src/de/danoeh/antennapod/activity')
-rw-r--r-- | src/de/danoeh/antennapod/activity/MainActivity.java | 12 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/SearchActivity.java | 22 |
2 files changed, 14 insertions, 20 deletions
diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java index 410617b23..b42990224 100644 --- a/src/de/danoeh/antennapod/activity/MainActivity.java +++ b/src/de/danoeh/antennapod/activity/MainActivity.java @@ -22,13 +22,14 @@ import com.actionbarsherlock.view.Window; import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.feed.EventDistributor; -import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.fragment.EpisodesFragment; import de.danoeh.antennapod.fragment.ExternalPlayerFragment; import de.danoeh.antennapod.fragment.FeedlistFragment; import de.danoeh.antennapod.preferences.UserPreferences; import de.danoeh.antennapod.service.PlaybackService; import de.danoeh.antennapod.service.download.DownloadService; +import de.danoeh.antennapod.storage.DBReader; +import de.danoeh.antennapod.storage.DBTasks; import de.danoeh.antennapod.storage.DownloadRequester; import de.danoeh.antennapod.util.StorageUtils; @@ -39,7 +40,6 @@ public class MainActivity extends SherlockFragmentActivity { private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED | EventDistributor.DOWNLOAD_QUEUED; - private FeedManager manager; private ViewPager viewpager; private TabsAdapter pagerAdapter; private ExternalPlayerFragment externalPlayerFragment; @@ -51,7 +51,6 @@ public class MainActivity extends SherlockFragmentActivity { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); StorageUtils.checkStorageAvailability(this); - manager = FeedManager.getInstance(); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.main); @@ -80,7 +79,7 @@ public class MainActivity extends SherlockFragmentActivity { if (!appLaunched && getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN)) { appLaunched = true; - if (manager.getUnreadItemsSize(true) > 0) { + if (DBReader.getNumberOfUnreadItems(this) > 0) { // select 'episodes' tab getSupportActionBar().setSelectedNavigationItem(1); } @@ -142,7 +141,7 @@ public class MainActivity extends SherlockFragmentActivity { startActivity(new Intent(this, AddFeedActivity.class)); return true; case R.id.all_feed_refresh: - manager.refreshAllFeeds(this); + DBTasks.refreshAllFeeds(this, null); return true; case R.id.show_downloads: startActivity(new Intent(this, DownloadActivity.class)); @@ -173,9 +172,6 @@ public class MainActivity extends SherlockFragmentActivity { } else { refreshAll.setVisible(true); } - - boolean hasFeeds = manager.getFeedsSize() > 0; - menu.findItem(R.id.all_feed_refresh).setVisible(hasFeeds); return true; } diff --git a/src/de/danoeh/antennapod/activity/SearchActivity.java b/src/de/danoeh/antennapod/activity/SearchActivity.java index 152710112..6a20ed765 100644 --- a/src/de/danoeh/antennapod/activity/SearchActivity.java +++ b/src/de/danoeh/antennapod/activity/SearchActivity.java @@ -1,6 +1,6 @@ package de.danoeh.antennapod.activity; -import java.util.ArrayList; +import java.util.List; import android.annotation.SuppressLint; import android.app.SearchManager; @@ -20,8 +20,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.SearchlistAdapter; import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.feed.FeedItem; -import de.danoeh.antennapod.feed.FeedManager; -import de.danoeh.antennapod.feed.FeedSearcher; +import de.danoeh.antennapod.storage.FeedSearcher; import de.danoeh.antennapod.feed.SearchResult; import de.danoeh.antennapod.fragment.FeedlistFragment; import de.danoeh.antennapod.fragment.ItemlistFragment; @@ -34,10 +33,10 @@ public class SearchActivity extends SherlockListActivity { public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.searchactivity.extra.feedId"; private SearchlistAdapter searchAdapter; - private ArrayList<SearchResult> content; + private List<SearchResult> content; - /** Feed that is being searched or null if the search is global. */ - private Feed selectedFeed; + /** ID of the feed that is being searched or null if the search is global. */ + private long feedID; private TextView txtvStatus; @@ -65,8 +64,7 @@ public class SearchActivity extends SherlockListActivity { if (extra != null) { if (AppConfig.DEBUG) Log.d(TAG, "Found bundle extra"); - long feedId = extra.getLong(EXTRA_FEED_ID); - selectedFeed = FeedManager.getInstance().getFeed(feedId); + feedID = extra.getLong(EXTRA_FEED_ID); } if (AppConfig.DEBUG) Log.d(TAG, "Starting search"); @@ -109,9 +107,9 @@ public class SearchActivity extends SherlockListActivity { @Override public boolean onSearchRequested() { Bundle extra = null; - if (selectedFeed != null) { + if (feedID != 0) { extra = new Bundle(); - extra.putLong(EXTRA_FEED_ID, selectedFeed.getId()); + extra.putLong(EXTRA_FEED_ID, feedID); } startSearch(null, false, extra, false); return true; @@ -152,8 +150,8 @@ public class SearchActivity extends SherlockListActivity { @Override public void run() { Log.d(TAG, "Starting background work"); - final ArrayList<SearchResult> result = FeedSearcher - .performSearch(SearchActivity.this, query, selectedFeed); + final List<SearchResult> result = FeedSearcher + .performSearch(SearchActivity.this, query, feedID); if (SearchActivity.this != null) { SearchActivity.this.runOnUiThread(new Runnable() { |