mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-13 21:36:58 -08:00
Break/Fix
Wheeeeee
This commit is contained in:
@@ -6,9 +6,7 @@ import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -19,26 +17,24 @@ import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public abstract class BaseModuleFragment extends Fragment {
|
||||
|
||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.empty_rv)
|
||||
TextView emptyTv;
|
||||
private View view;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.single_module_fragment, container, false);
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||
refreshItems();
|
||||
});
|
||||
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
@@ -59,16 +55,19 @@ public abstract class BaseModuleFragment extends Fragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
recyclerView.setAdapter(new ModulesAdapter(listModules(), (chk, position) -> {
|
||||
// On Checkbox change listener
|
||||
CheckBox chbox = (CheckBox) chk;
|
||||
recyclerView.setAdapter(new ModulesAdapter(listModules(), new Utils.ItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View chk, int position) {
|
||||
// On Checkbox change listener
|
||||
CheckBox chbox = (CheckBox) chk;
|
||||
|
||||
if (!chbox.isChecked()) {
|
||||
listModules().get(position).createDisableFile();
|
||||
Snackbar.make(chk, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
listModules().get(position).removeDisableFile();
|
||||
Snackbar.make(chk, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show();
|
||||
if (!chbox.isChecked()) {
|
||||
BaseModuleFragment.this.listModules().get(position).createDisableFile();
|
||||
Snackbar.make(chk, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
BaseModuleFragment.this.listModules().get(position).removeDisableFile();
|
||||
Snackbar.make(chk, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}, (deleteBtn, position) -> {
|
||||
// On delete button click listener
|
||||
@@ -84,22 +83,6 @@ public abstract class BaseModuleFragment extends Fragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
void refreshItems() {
|
||||
Log.d("Magisk", "Calling refreshitems for online");
|
||||
Utils.LoadModules utils = new Utils.LoadModules(getActivity(),true);
|
||||
utils.execute();
|
||||
onItemsLoadComplete();
|
||||
view.requestLayout();
|
||||
}
|
||||
|
||||
|
||||
void onItemsLoadComplete() {
|
||||
// Update the adapter and notify data set changed
|
||||
// ...
|
||||
|
||||
// Stop refresh animation
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
protected abstract List<Module> listModules();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user