mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-25 16:01:52 -05:00
hacky fix to prevent key list from scrolling to top when opening nav drawer
This commit is contained in:
parent
110f8c4d52
commit
65e76f6e44
@ -365,6 +365,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
// Get the searchview
|
||||
MenuItem searchItem = menu.findItem(R.id.menu_key_list_search);
|
||||
|
||||
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
|
||||
// Execute this when searching
|
||||
@ -383,7 +384,6 @@ public class KeyListFragment extends LoaderFragment
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
mQuery = null;
|
||||
mSearchView.setQuery("", true);
|
||||
getLoaderManager().restartLoader(0, null, KeyListFragment.this);
|
||||
return true;
|
||||
}
|
||||
@ -399,11 +399,18 @@ public class KeyListFragment extends LoaderFragment
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String s) {
|
||||
Log.d(Constants.TAG, "onQueryTextChange s:" + s);
|
||||
// Called when the action bar search text has changed. Update
|
||||
// the search filter, and restart the loader to do a new query
|
||||
// with this filter.
|
||||
mQuery = !TextUtils.isEmpty(s) ? s : null;
|
||||
// If the nav drawer is opened, onQueryTextChange("") is executed.
|
||||
// This hack prevents restarting the loader.
|
||||
// TODO: better way to fix this?
|
||||
String tmp = (mQuery == null) ? "" : mQuery;
|
||||
if (!s.equals(tmp)) {
|
||||
mQuery = s;
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -521,6 +528,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
|
||||
return mCursor.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||
}
|
||||
|
||||
public long getMasterKeyId(int id) {
|
||||
if (!mCursor.moveToPosition(id)) {
|
||||
throw new IllegalStateException("couldn't move cursor to position " + id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user