mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-15 06:14:04 -08:00
Add Swipe-to-refresh for Modules, Code Cleanup, Stylizations
Moar updates. Modules now swipe to refresh and indicate properly-ish. Cleanup minor code stuff. Colorize icons to match, set global color variable so it can be changed...
This commit is contained in:
@@ -9,6 +9,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.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
@@ -23,6 +24,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.module.RepoHelper;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.utils.WebWindow;
|
||||
@@ -34,13 +36,18 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public abstract class BaseModuleFragment extends Fragment {
|
||||
|
||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||
|
||||
|
||||
private RepoHelper.TaskDelegate mDelegate;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
public BaseModuleFragment SetDelegate(RepoHelper.TaskDelegate delegate) {
|
||||
mDelegate = delegate;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@@ -48,15 +55,18 @@ public abstract class BaseModuleFragment extends Fragment {
|
||||
|
||||
|
||||
ButterKnife.bind(this, viewMain);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
prefs.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
||||
if (s.contains("updated")) {
|
||||
viewMain.invalidate();
|
||||
viewMain.requestLayout();
|
||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||
Log.d("Magisk","ModulesFragment: SWIPE");
|
||||
mDelegate.taskCompletionResult("OK");
|
||||
});
|
||||
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
prefs.registerOnSharedPreferenceChangeListener((sharedPreferences, s) -> {
|
||||
if (s.contains("updated")) {
|
||||
viewMain.invalidate();
|
||||
viewMain.requestLayout();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
if (listModules().size() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user