use of android.support.v7.widget.SearchView in project Rocket.Chat.Android by RocketChat.
the class SidebarMainFragment method onSetupView.
@SuppressLint("RxLeakedSubscription")
@Override
protected void onSetupView() {
setupUserActionToggle();
setupUserStatusButtons();
setupLogoutButton();
setupVersionInfo();
adapter = new RoomListAdapter();
adapter.setOnItemClickListener(new RoomListAdapter.OnItemClickListener() {
@Override
public void onItemClick(Room room) {
searchView.clearFocus();
presenter.onRoomSelected(room);
}
@Override
public void onItemClick(SpotlightRoom spotlightRoom) {
searchView.setQuery(null, false);
searchView.clearFocus();
methodCallHelper.joinRoom(spotlightRoom.getId()).onSuccessTask(task -> {
presenter.onSpotlightRoomSelected(spotlightRoom);
return null;
});
}
});
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.room_list_container);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
searchView = (SearchView) rootView.findViewById(R.id.search);
RxSearchView.queryTextChanges(searchView).compose(bindToLifecycle()).debounce(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).switchMap(it -> {
if (it.length() == 0) {
adapter.setMode(RoomListAdapter.MODE_ROOM);
return Observable.just(Collections.<SpotlightRoom>emptyList());
}
adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT_ROOM);
final String queryString = it.toString();
methodCallHelper.searchSpotlightRooms(queryString);
return realmSpotlightRoomRepository.getSuggestionsFor(queryString, SortDirection.DESC, 10).toObservable();
}).subscribe(this::showSearchSuggestions, Logger::report);
}
use of android.support.v7.widget.SearchView in project RSAndroidApp by RailwayStations.
the class MainActivity method onCreateOptionsMenu.
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView search = (SearchView) menu.findItem(R.id.search).getActionView();
search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
Log.d(TAG, "onQueryTextSubmit ");
try {
cursor = dbAdapter.getBahnhofsListByKeyword(s, false);
if (cursor == null) {
Toast.makeText(MainActivity.this, "No records found!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this, cursor.getCount() + " records found!", Toast.LENGTH_LONG).show();
}
customAdapter.swapCursor(cursor);
} catch (Exception e) {
Log.e(TAG, "Unhandled Exception in onQueryTextSubmit", e);
}
return false;
}
@Override
public boolean onQueryTextChange(String s) {
Log.d(TAG, "onQueryTextChange ");
try {
cursor = dbAdapter.getBahnhofsListByKeyword(s, false);
if (cursor != null) {
customAdapter.swapCursor(cursor);
}
} catch (Exception e) {
Log.e(TAG, "Unhandled Exception in onQueryTextSubmit", e);
}
return false;
}
});
return true;
}
use of android.support.v7.widget.SearchView in project AndroidChromium by JackyAndroid.
the class UsbChooserPreferences method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.website_preferences_menu, menu);
MenuItem searchItem = menu.findItem(R.id.search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String query) {
// Make search case-insensitive.
query = query.toLowerCase();
if (query.equals(mSearch))
return true;
mSearch = query;
getInfo();
return true;
}
};
mSearchView.setOnQueryTextListener(queryTextListener);
MenuItem help = menu.add(Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
help.setIcon(R.drawable.ic_help_and_feedback);
}
use of android.support.v7.widget.SearchView in project AndroidChromium by JackyAndroid.
the class UsbDevicePreferences method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.website_preferences_menu, menu);
MenuItem searchItem = menu.findItem(R.id.search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String query) {
// Make search case-insensitive.
query = query.toLowerCase();
if (query.equals(mSearch))
return true;
mSearch = query;
getInfo();
return true;
}
};
mSearchView.setOnQueryTextListener(queryTextListener);
MenuItem help = menu.add(Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
help.setIcon(R.drawable.ic_help_and_feedback);
}
use of android.support.v7.widget.SearchView in project UltimateAndroid by cymcsg.
the class DemoOfUiActivity method onCreateOptionsMenu.
// @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu_layout, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
ToastUtil.show(DemoOfUiActivity.this, "test~", Toast.LENGTH_SHORT);
return false;
}
@Override
public boolean onQueryTextChange(String s) {
return false;
}
});
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// ToastUtil.show(MainActivity.this,"show~", Toast.LENGTH_SHORT);
}
});
// }
return super.onCreateOptionsMenu(menu);
}
Aggregations