use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class DonationFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
TitleView title = new TitleView();
title.setText(getString(R.string.donation_title));
items.add(title);
DescriptionView desc = new DescriptionView();
desc.setDrawable(getResources().getDrawable(R.drawable.logo));
desc.setSummary(getString(R.string.donation_summary));
desc.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
Utils.launchUrl("https://www.paypal.me/morogoku", getActivity());
}
});
items.add(desc);
String leng = Locale.getDefault().getLanguage();
ImageView img = new ImageView();
if (leng.contains("es")) {
img.setDrawable(getResources().getDrawable(R.drawable.ic_donar_paypal));
} else {
img.setDrawable(getResources().getDrawable(R.drawable.ic_donate_paypal));
}
img.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
Utils.launchUrl("https://www.paypal.me/morogoku", getActivity());
}
});
items.add(img);
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class InputsFragment method addItems.
@Override
protected void addItems(List<RecyclerViewItem> items) {
List<Device.Input.Item> inputs = Device.Input.getItems();
for (Device.Input.Item input : inputs) {
String name;
if ((name = input.getName()) != null) {
String[][] list = { { getString(R.string.bus), input.getBus() }, { getString(R.string.vendor), input.getVendor() }, { getString(R.string.product), input.getProduct() }, { getString(R.string.version), input.getVersion() }, { getString(R.string.sysfs), input.getSysfs() }, { getString(R.string.handlers), input.getHandlers() } };
List<RecyclerViewItem> inputItems = new ArrayList<>();
for (String[] inputsList : list) {
if (inputsList[1] != null) {
DescriptionView inputView = new DescriptionView();
inputView.setTitle(inputsList[0]);
inputView.setSummary(inputsList[1]);
inputItems.add(inputView);
}
}
if (inputItems.size() > 0) {
TitleView inputTile = new TitleView();
inputTile.setText(name);
items.add(inputTile);
items.addAll(inputItems);
}
}
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class BackupFragment 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 BuildpropFragment method load.
private void load(final List<RecyclerViewItem> items) {
if (mProps == null)
return;
String[] titles = mProps.keySet().toArray(new String[mProps.size()]);
for (int i = 0; i < mProps.size(); i++) {
final String title = titles[i];
final String value = mProps.values().toArray(new String[mProps.size()])[i];
if ((mKeyText != null && !title.contains(mKeyText) || (mValueText != null && !value.contains(mValueText)))) {
continue;
}
int color = ViewUtils.getThemeAccentColor(getActivity());
String colorCode = "#" + Integer.toHexString(Color.red(color)) + Integer.toHexString(Color.green(color)) + Integer.toHexString(Color.blue(color));
DescriptionView descriptionView = new DescriptionView();
if (mKeyText != null && !mKeyText.isEmpty()) {
descriptionView.setTitle(Utils.htmlFrom(title.replace(mKeyText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
} else {
descriptionView.setTitle(title);
}
if (mValueText != null && !mValueText.isEmpty()) {
descriptionView.setSummary(Utils.htmlFrom(value.replace(mValueText, "<b><font color=\"" + colorCode + "\">" + mKeyText + "</font></b>")));
} else {
descriptionView.setSummary(value);
}
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
mItemOptionsDialog = new Dialog(getActivity()).setItems(getResources().getStringArray(R.array.build_prop_item_options), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch(i) {
case 0:
modify(title, value);
break;
case 1:
delete(title, value);
break;
}
}
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mItemOptionsDialog = null;
}
});
mItemOptionsDialog.show();
}
});
items.add(descriptionView);
}
Activity activity;
if (mSearchFragment != null && (activity = getActivity()) != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (isAdded()) {
mSearchFragment.setCount(items.size());
}
}
});
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class InitdFragment method load.
private void load(List<RecyclerViewItem> items) {
for (final String initd : Initd.list()) {
CardView cardView = new CardView(getActivity());
cardView.setOnMenuListener(new CardView.OnMenuListener() {
@Override
public void onMenuReady(CardView cardView, PopupMenu popupMenu) {
Menu menu = popupMenu.getMenu();
menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.edit));
menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.delete));
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case 0:
mEditInitd = initd;
Intent intent = new Intent(getActivity(), EditorActivity.class);
intent.putExtra(EditorActivity.TITLE_INTENT, initd);
intent.putExtra(EditorActivity.TEXT_INTENT, Initd.read(initd));
startActivityForResult(intent, 0);
break;
case 1:
mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Initd.delete(initd);
reload();
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mDeleteDialog = null;
}
}, getActivity());
mDeleteDialog.show();
break;
}
return false;
}
});
}
});
DescriptionView descriptionView = new DescriptionView();
descriptionView.setSummary(initd);
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
mExecuteDialog = ViewUtils.dialogBuilder(getString(R.string.exceute_question, initd), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
execute(initd);
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mExecuteDialog = null;
}
}, getActivity());
mExecuteDialog.show();
}
});
cardView.addItem(descriptionView);
items.add(cardView);
}
}
Aggregations