Search in sources :

Example 26 with DescriptionView

use of com.moro.mtweaks.views.recyclerview.DescriptionView 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

DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)26 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)16 CardView (com.moro.mtweaks.views.recyclerview.CardView)12 TitleView (com.moro.mtweaks.views.recyclerview.TitleView)7 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 SelectView (com.moro.mtweaks.views.recyclerview.SelectView)5 SeekBarView (com.moro.mtweaks.views.recyclerview.SeekBarView)4 SwitchView (com.moro.mtweaks.views.recyclerview.SwitchView)4 PopupMenu (android.support.v7.widget.PopupMenu)3 MenuItem (android.view.MenuItem)3 Intent (android.content.Intent)2 Menu (android.view.Menu)2 Profiles (com.moro.mtweaks.database.tools.profiles.Profiles)2 RootFile (com.moro.mtweaks.utils.root.RootFile)2 Dialog (com.moro.mtweaks.views.dialog.Dialog)2 File (java.io.File)2 Activity (android.app.Activity)1 ProgressDialog (android.app.ProgressDialog)1 AppWidgetManager (android.appwidget.AppWidgetManager)1