From 1ee50e81ae8a86bcf2348d956f23c84fbce21b14 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Mon, 19 May 2014 01:05:48 +0200 Subject: Removed unused resources, reduced number of lint warnings --- .../danoeh/antennapod/activity/SearchActivity.java | 198 --------------------- 1 file changed, 198 deletions(-) delete mode 100644 src/de/danoeh/antennapod/activity/SearchActivity.java (limited to 'src/de/danoeh/antennapod/activity/SearchActivity.java') diff --git a/src/de/danoeh/antennapod/activity/SearchActivity.java b/src/de/danoeh/antennapod/activity/SearchActivity.java deleted file mode 100644 index 02c0838b3..000000000 --- a/src/de/danoeh/antennapod/activity/SearchActivity.java +++ /dev/null @@ -1,198 +0,0 @@ -package de.danoeh.antennapod.activity; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.app.SearchManager; -import android.content.Intent; -import android.os.Bundle; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.app.ActionBarActivity; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.TextView; -import de.danoeh.antennapod.BuildConfig; -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.SearchResult; -import de.danoeh.antennapod.fragment.FeedlistFragment; -import de.danoeh.antennapod.fragment.ItemlistFragment; -import de.danoeh.antennapod.preferences.UserPreferences; -import de.danoeh.antennapod.storage.FeedSearcher; - -import java.util.ArrayList; -import java.util.List; - -/** - * Displays the results when the user searches for FeedItems or Feeds. - */ -public class SearchActivity extends ActionBarActivity implements AdapterView.OnItemClickListener { - private static final String TAG = "SearchActivity"; - - public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.searchactivity.extra.feedId"; - - private SearchlistAdapter searchAdapter; - - /** - * ID of the feed that is being searched or null if the search is global. - */ - private long feedID; - - private ListView listView; - private TextView txtvStatus; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - setTheme(UserPreferences.getTheme()); - super.onCreate(savedInstanceState); - - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setContentView(R.layout.searchlist); - listView = (ListView) findViewById(android.R.id.list); - txtvStatus = (TextView) findViewById(android.R.id.empty); - - listView.setOnItemClickListener(this); - //searchAdapter = new SearchlistAdapter(this, 0, new ArrayList()); - listView.setAdapter(searchAdapter); - listView.setEmptyView(txtvStatus); - } - - @Override - protected void onNewIntent(Intent intent) { - setIntent(intent); - } - - @Override - protected void onResume() { - super.onResume(); - Intent intent = getIntent(); - if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - if (intent.hasExtra(SearchActivity.EXTRA_FEED_ID)) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Found bundle extra"); - feedID = intent.getLongExtra(SearchActivity.EXTRA_FEED_ID, 0); - } - if (BuildConfig.DEBUG) - Log.d(TAG, "Starting search"); - String query = intent.getStringExtra(SearchManager.QUERY); - getSupportActionBar() - .setSubtitle( - getString(R.string.search_term_label) + "\"" - + query + "\""); - handleSearchRequest(query); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label) - .setIcon( - obtainStyledAttributes( - new int[]{R.attr.action_search}) - .getDrawable(0)), - (MenuItem.SHOW_AS_ACTION_IF_ROOM)); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - Intent intent = new Intent(this, MainActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - return true; - case R.id.search_item: - onSearchRequested(); - return true; - default: - return false; - } - } - - @Override - public boolean onSearchRequested() { - Bundle extra = null; - if (feedID != 0) { - extra = new Bundle(); - extra.putLong(EXTRA_FEED_ID, feedID); - } - startSearch(null, false, extra, false); - return true; - } - - @SuppressLint({"NewApi", "NewApi"}) - private void handleSearchRequest(final String query) { - if (searchAdapter != null) { - // searchAdapter.clear(); - searchAdapter.notifyDataSetChanged(); - } - txtvStatus.setText(R.string.search_status_searching); - - Thread thread = new Thread() { - - @Override - public void run() { - Log.d(TAG, "Starting background work"); - final Activity activity = SearchActivity.this; - final List result = FeedSearcher - .performSearch(activity, query, feedID); - activity.runOnUiThread(new Runnable() { - - @Override - public void run() { - if (BuildConfig.DEBUG) - Log.d(TAG, "Background work finished"); - if (BuildConfig.DEBUG) - Log.d(TAG, "Found " + result.size() - + " results"); - - // searchAdapter.clear(); - for (SearchResult s : result) { - // searchAdapter.add(s); - } - searchAdapter.notifyDataSetChanged(); - txtvStatus - .setText(R.string.search_status_no_results); - if (!searchAdapter.isEmpty()) { - txtvStatus.setVisibility(View.GONE); - } else { - txtvStatus.setVisibility(View.VISIBLE); - } - } - }); - - } - }; - thread.start(); - - } - - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long l) { - SearchResult selection = searchAdapter.getItem(position); - if (selection.getComponent().getClass() == Feed.class) { - Feed feed = (Feed) selection.getComponent(); - Intent launchIntent = new Intent(this, FeedItemlistActivity.class); - launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED, - feed.getId()); - startActivity(launchIntent); - - } else if (selection.getComponent().getClass() == FeedItem.class) { - FeedItem item = (FeedItem) selection.getComponent(); - Intent launchIntent = new Intent(this, ItemviewActivity.class); - launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED, item - .getFeed().getId()); - launchIntent.putExtra(ItemlistFragment.EXTRA_SELECTED_FEEDITEM, - item.getId()); - startActivity(launchIntent); - } - } -} -- cgit v1.2.3