Reapply filter when reloading app list

This commit is contained in:
tonymanou 2017-01-08 16:17:01 +01:00 committed by topjohnwu
parent cc262d6595
commit c1e7d74b96

View File

@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -43,6 +44,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
private ApplicationAdapter appAdapter; private ApplicationAdapter appAdapter;
private SearchView.OnQueryTextListener searchListener; private SearchView.OnQueryTextListener searchListener;
private String lastFilter;
@Nullable @Nullable
@Override @Override
@ -64,12 +66,14 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
searchListener = new SearchView.OnQueryTextListener() { searchListener = new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {
lastFilter = query;
appAdapter.filter(query); appAdapter.filter(query);
return false; return false;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
lastFilter = newText;
appAdapter.filter(newText); appAdapter.filter(newText);
return false; return false;
} }
@ -109,5 +113,8 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
appAdapter.setLists(result.listApps, result.hideList); appAdapter.setLists(result.listApps, result.hideList);
recyclerView.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE);
mSwipeRefreshLayout.setRefreshing(false); mSwipeRefreshLayout.setRefreshing(false);
if (!TextUtils.isEmpty(lastFilter)) {
appAdapter.filter(lastFilter);
}
} }
} }