Search in sources :

Example 16 with RecyclerViewItem

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);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView) ImageView(com.moro.mtweaks.views.recyclerview.ImageView) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem)

Example 17 with RecyclerViewItem

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);
            }
        }
    }
}
Also used : Device(com.moro.mtweaks.utils.Device) ArrayList(java.util.ArrayList) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView)

Example 18 with RecyclerViewItem

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);
    }
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem)

Example 19 with RecyclerViewItem

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());
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) Dialog(com.moro.mtweaks.views.dialog.Dialog) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView)

Example 20 with RecyclerViewItem

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);
    }
}
Also used : DialogInterface(android.content.DialogInterface) CardView(com.moro.mtweaks.views.recyclerview.CardView) MenuItem(android.view.MenuItem) Intent(android.content.Intent) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)42 ArrayList (java.util.ArrayList)26 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)18 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)16 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)15 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)14 CardView (com.moro.mtweaks.views.recyclerview.CardView)9 List (java.util.List)9 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)8 AsyncTask (android.os.AsyncTask)6 DialogInterface (android.content.DialogInterface)5 Intent (android.content.Intent)3 Activity (android.app.Activity)2 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 PopupMenu (android.support.v7.widget.PopupMenu)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 Profiles (com.moro.mtweaks.database.tools.profiles.Profiles)2 Dialog (com.moro.mtweaks.views.dialog.Dialog)2 ProgressDialog (android.app.ProgressDialog)1