Search in sources :

Example 41 with RecyclerViewItem

use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.

the class HmpFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    CardView card = new CardView(getActivity());
    card.setTitle(getString(R.string.hmp_long));
    DescriptionView hmp = new DescriptionView();
    hmp.setSummary(getString(R.string.hmp_desc));
    card.addItem(hmp);
    if (Hmp.hasUpThreshold()) {
        mUpThreshold = new SeekBarView();
        mUpThreshold.setTitle(getString(R.string.hmp_up_threshold));
        mUpThreshold.setSummary(getString(R.string.hmp_up_threshold_summary));
        mUpThreshold.setMax(1024);
        mUpThreshold.setMin(1);
        mUpThreshold.setProgress(Utils.strToInt(Hmp.getUpThreshold()) - 1);
        mUpThreshold.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Hmp.setUpThreshold((position + 1), getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        card.addItem(mUpThreshold);
    }
    if (Hmp.hasDownThreshold()) {
        mDownThreshold = new SeekBarView();
        mDownThreshold.setTitle(getString(R.string.hmp_down_threshold));
        mDownThreshold.setSummary(getString(R.string.hmp_down_threshold_summary));
        mDownThreshold.setMax(1024);
        mDownThreshold.setMin(1);
        mDownThreshold.setProgress(Utils.strToInt(Hmp.getDownThreshold()) - 1);
        mDownThreshold.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                Hmp.setDownThreshold((position + 1), getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        card.addItem(mDownThreshold);
    }
    if (card.size() > 0) {
        items.add(card);
    }
    if (Hmp.hasUpThreshold() && Hmp.hasDownThreshold()) {
        TitleView profilesTitle = new TitleView();
        profilesTitle.setText(getString(R.string.profile));
        items.add(profilesTitle);
        for (int id : sProfiles.keySet()) {
            DescriptionView profile = new DescriptionView();
            profile.setTitle(getString(id));
            profile.setSummary(sProfiles.get(id));
            profile.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

                @Override
                public void onClick(RecyclerViewItem item) {
                    Hmp.setHmpProfile(((DescriptionView) item).getSummary().toString(), getActivity());
                    refreshHmpProfile();
                }
            });
            items.add(profile);
        }
    }
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView) TitleView(com.moro.mtweaks.views.recyclerview.TitleView) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView)

Example 42 with RecyclerViewItem

use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.

the class IOFragment method storageInit.

private void storageInit(final IO.Storage storage, List<RecyclerViewItem> items) {
    CardView io = new CardView(getActivity());
    io.setTitle(getString(storage == IO.Storage.Internal ? R.string.internal_storage : R.string.external_storage));
    if (IO.hasScheduler(storage)) {
        SelectView scheduler = new SelectView();
        scheduler.setTitle(getString(R.string.scheduler));
        scheduler.setSummary(getString(R.string.scheduler_summary));
        scheduler.setItems(IO.getSchedulers(storage));
        scheduler.setItem(IO.getScheduler(storage));
        scheduler.setOnItemSelected(new SelectView.OnItemSelected() {

            @Override
            public void onItemSelected(SelectView selectView, int position, String item) {
                IO.setScheduler(storage, item, getActivity());
            }
        });
        io.addItem(scheduler);
        DescriptionView tunable = new DescriptionView();
        tunable.setTitle(getString(R.string.scheduler_tunable));
        tunable.setSummary(getString(R.string.scheduler_tunable_summary));
        tunable.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

            @Override
            public void onClick(RecyclerViewItem item) {
                showTunables(IO.getScheduler(storage), IO.getIOSched(storage));
            }
        });
        io.addItem(tunable);
    }
    if (IO.hasReadahead(storage)) {
        SeekBarView readahead = new SeekBarView();
        readahead.setTitle(getString(R.string.read_ahead));
        readahead.setSummary(getString(R.string.read_ahead_summary));
        readahead.setUnit(getString(R.string.kb));
        readahead.setMax(8192);
        readahead.setMin(128);
        readahead.setOffset(128);
        readahead.setProgress(IO.getReadahead(storage) / 128 - 1);
        readahead.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setReadahead(storage, (position + 1) * 128, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(readahead);
    }
    if (IO.hasRotational(storage)) {
        SwitchView rotational = new SwitchView();
        rotational.setTitle(getString(R.string.rotational));
        rotational.setSummary(getString(R.string.rotational_summary));
        rotational.setChecked(IO.isRotationalEnabled(storage));
        rotational.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableRotational(storage, isChecked, getActivity());
            }
        });
        io.addItem(rotational);
    }
    if (IO.hasIOStats(storage)) {
        SwitchView iostats = new SwitchView();
        iostats.setTitle(getString(R.string.iostats));
        iostats.setSummary(getString(R.string.iostats_summary));
        iostats.setChecked(IO.isIOStatsEnabled(storage));
        iostats.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableIOstats(storage, isChecked, getActivity());
            }
        });
        io.addItem(iostats);
    }
    if (IO.hasAddRandom(storage)) {
        SwitchView addRandom = new SwitchView();
        addRandom.setTitle(getString(R.string.add_random));
        addRandom.setSummary(getString(R.string.add_random_summary));
        addRandom.setChecked(IO.isAddRandomEnabled(storage));
        addRandom.addOnSwitchListener(new SwitchView.OnSwitchListener() {

            @Override
            public void onChanged(SwitchView switchView, boolean isChecked) {
                IO.enableAddRandom(storage, isChecked, getActivity());
            }
        });
        io.addItem(addRandom);
    }
    if (IO.hasRqAffinity(storage)) {
        SeekBarView rqAffinity = new SeekBarView();
        rqAffinity.setTitle(getString(R.string.rq_affitiny));
        rqAffinity.setSummary(getString(R.string.rq_affinity_summary));
        rqAffinity.setMax(2);
        rqAffinity.setProgress(IO.getRqAffinity(storage));
        rqAffinity.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setRqAffinity(storage, position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(rqAffinity);
    }
    if (IO.hasNomerges(storage)) {
        SeekBarView Nomerges = new SeekBarView();
        Nomerges.setTitle(getString(R.string.nomerges));
        Nomerges.setSummary(getString(R.string.nomerges_summary));
        Nomerges.setMax(2);
        Nomerges.setProgress(IO.getNomerges(storage));
        Nomerges.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {

            @Override
            public void onStop(SeekBarView seekBarView, int position, String value) {
                IO.setNomerges(storage, position, getActivity());
            }

            @Override
            public void onMove(SeekBarView seekBarView, int position, String value) {
            }
        });
        io.addItem(Nomerges);
    }
    if (IO.hasNrRequests(storage)) {
        GenericSelectView2 NrRequests = new GenericSelectView2();
        NrRequests.setTitle(getString(R.string.nr_requests));
        NrRequests.setValue(IO.getNrRequests(storage));
        NrRequests.setValueRaw(NrRequests.getValue());
        NrRequests.setInputType(InputType.TYPE_CLASS_NUMBER);
        NrRequests.setOnGenericValueListener(new GenericSelectView2.OnGenericValueListener() {

            @Override
            public void onGenericValueSelected(GenericSelectView2 genericSelectView, String value) {
                IO.setNrRequests(storage, value, getActivity());
                genericSelectView.setValue(value);
            }
        });
        io.addItem(NrRequests);
    }
    if (io.size() > 0) {
        items.add(io);
    }
}
Also used : SwitchView(com.moro.mtweaks.views.recyclerview.SwitchView) CardView(com.moro.mtweaks.views.recyclerview.CardView) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) SeekBarView(com.moro.mtweaks.views.recyclerview.SeekBarView) GenericSelectView2(com.moro.mtweaks.views.recyclerview.GenericSelectView2) DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) SelectView(com.moro.mtweaks.views.recyclerview.SelectView)

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