hacky fix to prevent key list from scrolling to top when opening nav drawer
This commit is contained in:
@@ -365,6 +365,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||||
// Get the searchview
|
// Get the searchview
|
||||||
MenuItem searchItem = menu.findItem(R.id.menu_key_list_search);
|
MenuItem searchItem = menu.findItem(R.id.menu_key_list_search);
|
||||||
|
|
||||||
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||||
|
|
||||||
// Execute this when searching
|
// Execute this when searching
|
||||||
@@ -383,7 +384,6 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||||
mQuery = null;
|
mQuery = null;
|
||||||
mSearchView.setQuery("", true);
|
|
||||||
getLoaderManager().restartLoader(0, null, KeyListFragment.this);
|
getLoaderManager().restartLoader(0, null, KeyListFragment.this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -399,11 +399,18 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String s) {
|
public boolean onQueryTextChange(String s) {
|
||||||
|
Log.d(Constants.TAG, "onQueryTextChange s:" + s);
|
||||||
// Called when the action bar search text has changed. Update
|
// Called when the action bar search text has changed. Update
|
||||||
// the search filter, and restart the loader to do a new query
|
// the search filter, and restart the loader to do a new query
|
||||||
// with this filter.
|
// 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);
|
getLoaderManager().restartLoader(0, null, this);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,6 +528,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
|
|
||||||
return mCursor.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
return mCursor.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMasterKeyId(int id) {
|
public long getMasterKeyId(int id) {
|
||||||
if (!mCursor.moveToPosition(id)) {
|
if (!mCursor.moveToPosition(id)) {
|
||||||
throw new IllegalStateException("couldn't move cursor to position " + id);
|
throw new IllegalStateException("couldn't move cursor to position " + id);
|
||||||
|
|||||||
Reference in New Issue
Block a user