Do not store context in magisk hide adapter, remove unused code
This commit is contained in:
parent
cffc157d98
commit
989d8181dd
@ -40,8 +40,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
|
|||||||
);
|
);
|
||||||
public static CallbackHandler.Event packageLoadDone = new CallbackHandler.Event();
|
public static CallbackHandler.Event packageLoadDone = new CallbackHandler.Event();
|
||||||
|
|
||||||
private PackageManager packageManager;
|
private ApplicationAdapter appAdapter;
|
||||||
private ApplicationAdapter appAdapter = new ApplicationAdapter();
|
|
||||||
|
|
||||||
private SearchView.OnQueryTextListener searchListener;
|
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);
|
View view = inflater.inflate(R.layout.magisk_hide_fragment, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
packageManager = getActivity().getPackageManager();
|
PackageManager packageManager = getActivity().getPackageManager();
|
||||||
|
|
||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
@ -59,6 +58,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
|
|||||||
new Async.LoadApps(packageManager).exec();
|
new Async.LoadApps(packageManager).exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
appAdapter = new ApplicationAdapter(packageManager);
|
||||||
recyclerView.setAdapter(appAdapter);
|
recyclerView.setAdapter(appAdapter);
|
||||||
|
|
||||||
searchListener = new SearchView.OnQueryTextListener() {
|
searchListener = new SearchView.OnQueryTextListener() {
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package com.topjohnwu.magisk.adapters;
|
package com.topjohnwu.magisk.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -29,13 +26,13 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
|
|
||||||
private List<ApplicationInfo> mOriginalList, mList;
|
private List<ApplicationInfo> mOriginalList, mList;
|
||||||
private List<String> mHideList;
|
private List<String> mHideList;
|
||||||
private Context context;
|
|
||||||
private PackageManager packageManager;
|
private PackageManager packageManager;
|
||||||
private ApplicationFilter filter;
|
private ApplicationFilter filter;
|
||||||
|
|
||||||
public ApplicationAdapter() {
|
public ApplicationAdapter(PackageManager packageManager) {
|
||||||
mOriginalList = mList = Collections.emptyList();
|
mOriginalList = mList = Collections.emptyList();
|
||||||
mHideList = Collections.emptyList();
|
mHideList = Collections.emptyList();
|
||||||
|
this.packageManager = packageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLists(List<ApplicationInfo> listApps, List<String> hideList) {
|
public void setLists(List<ApplicationInfo> listApps, List<String> hideList) {
|
||||||
@ -47,8 +44,6 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_app, parent, false);
|
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_app, parent, false);
|
||||||
context = parent.getContext();
|
|
||||||
packageManager = context.getPackageManager();
|
|
||||||
ButterKnife.bind(this, mView);
|
ButterKnife.bind(this, mView);
|
||||||
return new ViewHolder(mView);
|
return new ViewHolder(mView);
|
||||||
}
|
}
|
||||||
@ -101,12 +96,9 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
@BindView(R.id.app_package) TextView appPackage;
|
@BindView(R.id.app_package) TextView appPackage;
|
||||||
@BindView(R.id.checkbox) CheckBox checkBox;
|
@BindView(R.id.checkbox) CheckBox checkBox;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
DisplayMetrics dimension = new DisplayMetrics();
|
|
||||||
windowmanager.getDefaultDisplay().getMetrics(dimension);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user