Added search button to SearchActivity
This commit is contained in:
parent
80a9100b8f
commit
8bad211f68
|
@ -171,6 +171,9 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.searchable"
|
android:name="android.app.searchable"
|
||||||
android:resource="@xml/searchable" />
|
android:resource="@xml/searchable" />
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.default_searchable"
|
||||||
|
android:value=".activity.SearchActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,22 @@ public class SearchActivity extends SherlockListActivity {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
setContentView(R.layout.searchlist);
|
setContentView(R.layout.searchlist);
|
||||||
txtvStatus = (TextView) findViewById(android.R.id.empty);
|
txtvStatus = (TextView) findViewById(android.R.id.empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
setIntent(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||||
Bundle extra = intent.getBundleExtra(SearchManager.APP_DATA);
|
Bundle extra = intent.getBundleExtra(SearchManager.APP_DATA);
|
||||||
if (extra != null) {
|
if (extra != null) {
|
||||||
if (AppConfig.DEBUG) Log.d(TAG, "Found bundle extra");
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Found bundle extra");
|
||||||
long feedId = extra.getLong(EXTRA_FEED_ID);
|
long feedId = extra.getLong(EXTRA_FEED_ID);
|
||||||
selectedFeed = FeedManager.getInstance().getFeed(feedId);
|
selectedFeed = FeedManager.getInstance().getFeed(feedId);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +76,9 @@ public class SearchActivity extends SherlockListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
|
||||||
|
.setIcon(R.drawable.action_search)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +88,25 @@ public class SearchActivity extends SherlockListActivity {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
startActivity(new Intent(this, MainActivity.class));
|
startActivity(new Intent(this, MainActivity.class));
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.search_item:
|
||||||
|
onSearchRequested();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSearchRequested() {
|
||||||
|
Bundle extra = null;
|
||||||
|
if (selectedFeed != null) {
|
||||||
|
extra = new Bundle();
|
||||||
|
extra.putLong(EXTRA_FEED_ID, selectedFeed.getId());
|
||||||
|
}
|
||||||
|
startSearch(null, false, extra, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
|
@ -107,6 +135,10 @@ public class SearchActivity extends SherlockListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
|
if (searchAdapter != null) {
|
||||||
|
searchAdapter.clear();
|
||||||
|
searchAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
txtvStatus.setText(R.string.search_status_searching);
|
txtvStatus.setText(R.string.search_status_searching);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue