From 989d8181dd07b1b75f3b5c245b6aaed9516e5bf7 Mon Sep 17 00:00:00 2001 From: tonymanou Date: Sun, 8 Jan 2017 14:47:56 +0100 Subject: [PATCH] Do not store context in magisk hide adapter, remove unused code --- .../com/topjohnwu/magisk/MagiskHideFragment.java | 6 +++--- .../magisk/adapters/ApplicationAdapter.java | 14 +++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java index 30e21e3e6..70275a841 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java @@ -40,8 +40,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even ); public static CallbackHandler.Event packageLoadDone = new CallbackHandler.Event(); - private PackageManager packageManager; - private ApplicationAdapter appAdapter = new ApplicationAdapter(); + private ApplicationAdapter appAdapter; private SearchView.OnQueryTextListener searchListener; @@ -51,7 +50,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even View view = inflater.inflate(R.layout.magisk_hide_fragment, container, false); ButterKnife.bind(this, view); - packageManager = getActivity().getPackageManager(); + PackageManager packageManager = getActivity().getPackageManager(); mSwipeRefreshLayout.setRefreshing(true); mSwipeRefreshLayout.setOnRefreshListener(() -> { @@ -59,6 +58,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even new Async.LoadApps(packageManager).exec(); }); + appAdapter = new ApplicationAdapter(packageManager); recyclerView.setAdapter(appAdapter); searchListener = new SearchView.OnQueryTextListener() { diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java index c47709fad..ec62f78af 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java @@ -1,14 +1,11 @@ package com.topjohnwu.magisk.adapters; -import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.support.v7.widget.RecyclerView; -import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.widget.CheckBox; import android.widget.Filter; import android.widget.ImageView; @@ -29,13 +26,13 @@ public class ApplicationAdapter extends RecyclerView.Adapter mOriginalList, mList; private List mHideList; - private Context context; private PackageManager packageManager; private ApplicationFilter filter; - public ApplicationAdapter() { + public ApplicationAdapter(PackageManager packageManager) { mOriginalList = mList = Collections.emptyList(); mHideList = Collections.emptyList(); + this.packageManager = packageManager; } public void setLists(List listApps, List hideList) { @@ -47,8 +44,6 @@ public class ApplicationAdapter extends RecyclerView.Adapter