blob: a30777fb1890df23161787109f97afad34eb61f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
package de.danoeh.antennapod.activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.fragment.MiroGuideChannellistFragment;
import de.danoeh.antennapod.preferences.UserPreferences;
/**
* Displays results when a search for miroguide channels has been performed. It
* uses a MiroGuideChannelListFragment to display the results.
*/
public class MiroGuideSearchActivity extends SherlockFragmentActivity {
private static final String TAG = "MiroGuideSearchActivity";
private MiroGuideChannellistFragment listFragment;
@Override
protected void onCreate(Bundle arg0) {
setTheme(UserPreferences.getTheme());
super.onCreate(arg0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.miroguidesearch);
}
@Override
protected void onResume() {
super.onResume();
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
getSupportActionBar()
.setSubtitle(
getString(R.string.search_term_label) + "\""
+ query + "\"");
handleSearchRequest(query);
}
}
private void handleSearchRequest(String query) {
if (AppConfig.DEBUG)
Log.d(TAG, "Performing search");
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
listFragment = MiroGuideChannellistFragment.newInstance("name", query,
"name");
ft.replace(R.id.channellistFragment, listFragment);
ft.commit();
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
.setIcon(
obtainStyledAttributes(
new int[] { R.attr.action_search })
.getDrawable(0))
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.search_item:
onSearchRequested();
return true;
default:
return false;
}
}
}
|