use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class ProfileFragment method reload.
private void reload() {
if (mLoader == null) {
getHandler().postDelayed(new Runnable() {
@Override
public void run() {
clearItems();
mLoader = new AsyncTask<Void, Void, List<RecyclerViewItem>>() {
@Override
protected void onPreExecute() {
super.onPreExecute();
showProgress();
}
@Override
protected List<RecyclerViewItem> doInBackground(Void... voids) {
List<RecyclerViewItem> items = new ArrayList<>();
load(items);
return items;
}
@Override
protected void onPostExecute(List<RecyclerViewItem> items) {
super.onPostExecute(items);
for (RecyclerViewItem item : items) {
addItem(item);
}
hideProgress();
mLoader = null;
}
};
mLoader.execute();
}
}, 250);
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class DownloadsFragment method postInit.
@Override
protected void postInit() {
super.postInit();
if (mWebpageReader == null && mSupport != null) {
showProgress();
mWebpageReader = new WebpageReader(getActivity(), new WebpageReader.WebpageListener() {
private int mKernelCount;
@Override
public void onSuccess(String url, String raw, CharSequence html) {
if (!isAdded())
return;
hideProgress();
final SupportedDownloads.Kernels kernels = new SupportedDownloads.Kernels(raw);
mKernelWebpageReader.clear();
final List<SupportedDownloads.KernelContent> contents = new ArrayList<>();
if (kernels.readable()) {
for (int i = 0; i < kernels.length(); i++) {
WebpageReader reader = new WebpageReader(getActivity(), new WebpageReader.WebpageListener() {
@Override
public void onSuccess(String url, String raw, CharSequence html) {
if (!isAdded())
return;
mKernelCount++;
SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent(raw);
if (content.readable()) {
contents.add(content);
}
if (mKernelCount == kernels.length()) {
addViews(contents);
}
}
@Override
public void onFailure(String url) {
}
});
reader.get(kernels.getLink(i));
mKernelWebpageReader.add(reader);
}
} else {
error();
}
}
@Override
public void onFailure(String url) {
error();
}
private void addViews(List<SupportedDownloads.KernelContent> contents) {
if (contents.size() > 0) {
for (final SupportedDownloads.KernelContent content : contents) {
String n = content.getName();
if (n != null && content.getLogo() != null && content.getShortDescription() != null && content.getLongDescription() != null) {
KernelItemView kernelItemView = new KernelItemView(content);
kernelItemView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
mKernelContent = content;
requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
});
addItem(kernelItemView);
}
}
hideProgress();
} else {
error();
}
}
});
mWebpageReader.get(mSupport.getLink());
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class RecyclerViewFragment method onDestroy.
@Override
public void onDestroy() {
super.onDestroy();
mItems.clear();
mRecyclerViewAdapter = null;
setAppBarLayoutAlpha(255);
if (mAppBarLayout != null && !isForeground()) {
mAppBarLayout.setTranslationY(0);
ViewCompat.setElevation(mAppBarLayout, 0);
}
if (mLoader != null) {
mLoader.cancel(true);
mLoader = null;
}
if (mHandler != null) {
mHandler.removeCallbacks(mRefresh);
}
mAdView = null;
for (RecyclerViewItem item : mItems) {
item.onDestroy();
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class RecyclerViewFragment method onResume.
@Override
public void onResume() {
super.onResume();
mHandler.post(mRefresh);
for (RecyclerViewItem item : mItems) {
item.onResume();
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class CPUFragment method cpuQuietInit.
private void cpuQuietInit(List<RecyclerViewItem> items) {
List<RecyclerViewItem> views = new ArrayList<>();
CardView cpuQuietCard = new CardView(getActivity());
cpuQuietCard.setTitle(getString(R.string.cpu_quiet));
if (Misc.hasCpuQuietEnable()) {
SwitchView cpuQuietEnable = new SwitchView();
cpuQuietEnable.setSummary(getString(R.string.cpu_quiet));
cpuQuietEnable.setChecked(Misc.isCpuQuietEnabled());
cpuQuietEnable.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Misc.enableCpuQuiet(isChecked, getActivity());
}
});
views.add(cpuQuietEnable);
}
if (Misc.hasCpuQuietGovernors()) {
SelectView cpuQuietGovernors = new SelectView();
cpuQuietGovernors.setSummary(getString(R.string.cpu_quiet_governor));
cpuQuietGovernors.setItems(Misc.getCpuQuietAvailableGovernors());
cpuQuietGovernors.setItem(Misc.getCpuQuietCurGovernor());
cpuQuietGovernors.setOnItemSelected(new SelectView.OnItemSelected() {
@Override
public void onItemSelected(SelectView selectView, int position, String item) {
Misc.setCpuQuietGovernor(item, getActivity());
}
});
views.add(cpuQuietGovernors);
}
if (views.size() > 0) {
DescriptionView descriptionView = new DescriptionView();
descriptionView.setSummary(getString(R.string.cpu_quiet_summary));
cpuQuietCard.addItem(descriptionView);
for (RecyclerViewItem item : views) {
cpuQuietCard.addItem(item);
}
items.add(cpuQuietCard);
}
}
Aggregations