Goddammit...

Github likes to skip a file when I'm committing...
This commit is contained in:
d8ahazard 2016-09-13 07:31:43 -05:00
parent b3ba79a3ba
commit 145d4e4bd5

View File

@ -28,6 +28,7 @@ import com.nbsp.materialfilepicker.MaterialFilePicker;
import com.nbsp.materialfilepicker.ui.FilePickerActivity; import com.nbsp.materialfilepicker.ui.FilePickerActivity;
import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.module.Repo; import com.topjohnwu.magisk.module.Repo;
import com.topjohnwu.magisk.module.RepoHelper;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
@ -55,6 +56,7 @@ public class ModulesFragment extends Fragment {
ViewPager viewPager; ViewPager viewPager;
@BindView(R.id.tab_layout) @BindView(R.id.tab_layout)
TabLayout tabLayout; TabLayout tabLayout;
private RepoHelper.TaskDelegate mTaskDelegate;
@Nullable @Nullable
@Override @Override
@ -64,8 +66,14 @@ public class ModulesFragment extends Fragment {
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
new Utils.LoadModules(getActivity(), false).execute(); new Utils.LoadModules(getActivity(), false).execute();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
mTaskDelegate = result -> {
if (result.equals("OK")) {
Log.d("Magisk","ModulesFragment: We dun got the result, hur hur.");
RefreshUI();
}
};
new updateUI().execute(); new updateUI().execute();
setHasOptionsMenu(true);
return view; return view;
} }
@ -112,28 +120,21 @@ public class ModulesFragment extends Fragment {
} }
} }
private void RefreshUI() {
@Override viewPagePosition = tabLayout.getSelectedTabPosition();
public boolean onOptionsItemSelected(MenuItem item) { listModules.clear();
switch (item.getItemId()) { listModulesCache.clear();
case R.id.force_reload: progressBar.setVisibility(View.VISIBLE);
viewPagePosition = tabLayout.getSelectedTabPosition(); viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
listModules.clear(); tabLayout.setupWithViewPager(viewPager);
listModulesCache.clear(); viewPager.setCurrentItem(viewPagePosition);
progressBar.setVisibility(View.VISIBLE); new Utils.LoadModules(getActivity(), true).execute();
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager())); Collections.sort(listModules,new CustomComparator());
tabLayout.setupWithViewPager(viewPager); Collections.sort(listModulesCache,new CustomComparator());
viewPager.setCurrentItem(viewPagePosition); new updateUI().execute();
new Utils.LoadModules(getActivity(), true).execute();
Collections.sort(listModules,new CustomComparator());
Collections.sort(listModulesCache,new CustomComparator());
new updateUI().execute();
break;
}
return super.onOptionsItemSelected(item);
} }
void selectPage(int pageIndex) { void selectPage(int pageIndex) {
tabLayout.setScrollPosition(pageIndex, 0f, true); tabLayout.setScrollPosition(pageIndex, 0f, true);
viewPager.setCurrentItem(pageIndex); viewPager.setCurrentItem(pageIndex);
@ -168,7 +169,6 @@ public class ModulesFragment extends Fragment {
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
super.onPostExecute(v); super.onPostExecute(v);
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
viewPager.setAdapter(new TabsAdapter(getChildFragmentManager())); viewPager.setAdapter(new TabsAdapter(getChildFragmentManager()));
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
@ -200,9 +200,13 @@ public class ModulesFragment extends Fragment {
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
if (position == 0) { if (position == 0) {
return new NormalModuleFragment(); NormalModuleFragment nmf = new NormalModuleFragment();
nmf.SetDelegate(mTaskDelegate);
return nmf;
} else { } else {
return new CacheModuleFragment(); CacheModuleFragment cmf = new CacheModuleFragment();
cmf.SetDelegate(mTaskDelegate);
return cmf;
} }
} }
} }