Search in sources :

Example 1 with RecyclerViewFragment

use of com.moro.mtweaks.fragments.RecyclerViewFragment in project MTweaks-KernelAdiutorMOD by morogoku.

the class NavigationActivity method onItemSelected.

private void onItemSelected(final int res, boolean delay, boolean saveOpened) {
    mDrawer.closeDrawer(GravityCompat.START);
    getSupportActionBar().setTitle(getString(res));
    mNavigationView.setCheckedItem(res);
    mSelection = res;
    Fragment fragment = getFragment(res);
    if (fragment instanceof RecyclerViewFragment) {
        ((RecyclerViewFragment) fragment).mDelay = delay;
    } else if (fragment instanceof SettingsFragment) {
        ((SettingsFragment) fragment).mDelay = delay;
    }
    if (mAllowCommit) {
        getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, res + "_key").commit();
    }
    if (saveOpened) {
        String openedName = fragment.getClass().getSimpleName() + "_opened";
        Prefs.saveInt(openedName, Prefs.getInt(openedName, 0, this) + 1, this);
    }
    setShortcuts();
}
Also used : SettingsFragment(com.moro.mtweaks.fragments.other.SettingsFragment) RecyclerViewFragment(com.moro.mtweaks.fragments.RecyclerViewFragment) LMKFragment(com.moro.mtweaks.fragments.kernel.LMKFragment) BackupFragment(com.moro.mtweaks.fragments.tools.BackupFragment) BuildpropFragment(com.moro.mtweaks.fragments.tools.BuildpropFragment) RecyclerViewFragment(com.moro.mtweaks.fragments.RecyclerViewFragment) Fragment(android.support.v4.app.Fragment) ThermalFragment(com.moro.mtweaks.fragments.kernel.ThermalFragment) EntropyFragment(com.moro.mtweaks.fragments.kernel.EntropyFragment) OverallFragment(com.moro.mtweaks.fragments.statistics.OverallFragment) CPUVoltageCl0Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl0Fragment) ScreenFragment(com.moro.mtweaks.fragments.kernel.ScreenFragment) LEDFragment(com.moro.mtweaks.fragments.kernel.LEDFragment) CPUFragment(com.moro.mtweaks.fragments.kernel.CPUFragment) DeviceFragment(com.moro.mtweaks.fragments.statistics.DeviceFragment) MemoryFragment(com.moro.mtweaks.fragments.statistics.MemoryFragment) AboutFragment(com.moro.mtweaks.fragments.other.AboutFragment) InitdFragment(com.moro.mtweaks.fragments.tools.InitdFragment) RecoveryFragment(com.moro.mtweaks.fragments.tools.RecoveryFragment) WakelockFragment(com.moro.mtweaks.fragments.kernel.WakelockFragment) CPUVoltageCl1Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl1Fragment) SoundFragment(com.moro.mtweaks.fragments.kernel.SoundFragment) IOFragment(com.moro.mtweaks.fragments.kernel.IOFragment) DvfsFragment(com.moro.mtweaks.fragments.kernel.DvfsFragment) SpectrumFragment(com.moro.mtweaks.fragments.kernel.SpectrumFragment) MiscFragment(com.moro.mtweaks.fragments.kernel.MiscFragment) SettingsFragment(com.moro.mtweaks.fragments.other.SettingsFragment) CustomControlsFragment(com.moro.mtweaks.fragments.tools.customcontrols.CustomControlsFragment) BoefflaWakelockFragment(com.moro.mtweaks.fragments.kernel.BoefflaWakelockFragment) ContributorsFragment(com.moro.mtweaks.fragments.other.ContributorsFragment) ProfileFragment(com.moro.mtweaks.fragments.tools.ProfileFragment) GPUFragment(com.moro.mtweaks.fragments.kernel.GPUFragment) VMFragment(com.moro.mtweaks.fragments.kernel.VMFragment) DownloadsFragment(com.moro.mtweaks.fragments.tools.downloads.DownloadsFragment) DonationFragment(com.moro.mtweaks.fragments.other.DonationFragment) BaseFragment(com.moro.mtweaks.fragments.BaseFragment) KSMFragment(com.moro.mtweaks.fragments.kernel.KSMFragment) BatteryFragment(com.moro.mtweaks.fragments.kernel.BatteryFragment) InputsFragment(com.moro.mtweaks.fragments.statistics.InputsFragment) HmpFragment(com.moro.mtweaks.fragments.kernel.HmpFragment) OnBootFragment(com.moro.mtweaks.fragments.tools.OnBootFragment) CPUHotplugFragment(com.moro.mtweaks.fragments.kernel.CPUHotplugFragment)

Example 2 with RecyclerViewFragment

use of com.moro.mtweaks.fragments.RecyclerViewFragment in project MTweaks-KernelAdiutorMOD by morogoku.

the class NavigationActivity method init.

private void init(Bundle savedInstanceState) {
    int result = Prefs.getInt("license", -1, this);
    int intentResult = getIntent().getIntExtra("result", -1);
    if ((result == intentResult && (result == 1 || result == 2)) && mLicenseDialog) {
        ViewUtils.dialogBuilder(getString(R.string.license_invalid), null, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }, new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                mLicenseDialog = false;
                Prefs.saveInt("license", -1, NavigationActivity.this);
            }
        }, this).show();
    } else if ((result != intentResult || result == 3) && mLicenseDialog) {
        ViewUtils.dialogBuilder(getString(R.string.pirated), null, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }, new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                mLicenseDialog = false;
                Prefs.saveInt("license", -1, NavigationActivity.this);
            }
        }, this).show();
    } else {
        mLicenseDialog = false;
        if (result == 0) {
            Utils.DONATED = true;
        }
    }
    sCallback = new Callback() {

        @Override
        public void onBannerResize() {
            Fragment fragment = sActualFragments.get(mSelection);
            if (fragment instanceof RecyclerViewFragment) {
                ((RecyclerViewFragment) fragment).resizeBanner();
            }
        }
    };
    setContentView(R.layout.activity_navigation);
    Toolbar toolbar = getToolBar();
    setSupportActionBar(toolbar);
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, 0, 0);
    mDrawer.addDrawerListener(toggle);
    toggle.syncState();
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    mNavigationView.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                v.clearFocus();
            }
        }
    });
    appendFragments(false);
    if (savedInstanceState != null) {
        mSelection = savedInstanceState.getInt("selection");
        mLicenseDialog = savedInstanceState.getBoolean("license");
        mFetchingAds = savedInstanceState.getBoolean("fetching_ads");
    }
    String section = getIntent().getStringExtra("section");
    if (section != null) {
        for (int id : sActualFragments.keySet()) {
            if (sActualFragments.get(id) != null && sActualFragments.get(id).getClass().getCanonicalName().equals(section)) {
                mSelection = id;
                break;
            }
        }
        getIntent().removeExtra("section");
    }
    if (mSelection == 0 || !sActualFragments.containsKey(mSelection)) {
        mSelection = firstTab();
    }
    onItemSelected(mSelection, false, false);
    if (Prefs.getBoolean("data_sharing", true, this)) {
        startService(new Intent(this, Monitor.class));
    }
    if (!mFetchingAds && !Utils.DONATED) {
        mFetchingAds = true;
        mAdsFetcher = new WebpageReader(this, new WebpageReader.WebpageListener() {

            @Override
            public void onSuccess(String url, String raw, CharSequence html) {
                AdNativeExpress.GHAds ghAds = new AdNativeExpress.GHAds(raw);
                if (ghAds.readable()) {
                    ghAds.cache(NavigationActivity.this);
                    for (int id : sActualFragments.keySet()) {
                        Fragment fragment = sActualFragments.get(id);
                        if (fragment instanceof RecyclerViewFragment) {
                            ((RecyclerViewFragment) fragment).ghAdReady();
                        }
                    }
                }
            }

            @Override
            public void onFailure(String url) {
            }
        });
        mAdsFetcher.get(AdNativeExpress.ADS_FETCH);
    }
}
Also used : DialogInterface(android.content.DialogInterface) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) RecyclerViewFragment(com.moro.mtweaks.fragments.RecyclerViewFragment) LMKFragment(com.moro.mtweaks.fragments.kernel.LMKFragment) BackupFragment(com.moro.mtweaks.fragments.tools.BackupFragment) BuildpropFragment(com.moro.mtweaks.fragments.tools.BuildpropFragment) RecyclerViewFragment(com.moro.mtweaks.fragments.RecyclerViewFragment) Fragment(android.support.v4.app.Fragment) ThermalFragment(com.moro.mtweaks.fragments.kernel.ThermalFragment) EntropyFragment(com.moro.mtweaks.fragments.kernel.EntropyFragment) OverallFragment(com.moro.mtweaks.fragments.statistics.OverallFragment) CPUVoltageCl0Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl0Fragment) ScreenFragment(com.moro.mtweaks.fragments.kernel.ScreenFragment) LEDFragment(com.moro.mtweaks.fragments.kernel.LEDFragment) CPUFragment(com.moro.mtweaks.fragments.kernel.CPUFragment) DeviceFragment(com.moro.mtweaks.fragments.statistics.DeviceFragment) MemoryFragment(com.moro.mtweaks.fragments.statistics.MemoryFragment) AboutFragment(com.moro.mtweaks.fragments.other.AboutFragment) InitdFragment(com.moro.mtweaks.fragments.tools.InitdFragment) RecoveryFragment(com.moro.mtweaks.fragments.tools.RecoveryFragment) WakelockFragment(com.moro.mtweaks.fragments.kernel.WakelockFragment) CPUVoltageCl1Fragment(com.moro.mtweaks.fragments.kernel.CPUVoltageCl1Fragment) SoundFragment(com.moro.mtweaks.fragments.kernel.SoundFragment) IOFragment(com.moro.mtweaks.fragments.kernel.IOFragment) DvfsFragment(com.moro.mtweaks.fragments.kernel.DvfsFragment) SpectrumFragment(com.moro.mtweaks.fragments.kernel.SpectrumFragment) MiscFragment(com.moro.mtweaks.fragments.kernel.MiscFragment) SettingsFragment(com.moro.mtweaks.fragments.other.SettingsFragment) CustomControlsFragment(com.moro.mtweaks.fragments.tools.customcontrols.CustomControlsFragment) BoefflaWakelockFragment(com.moro.mtweaks.fragments.kernel.BoefflaWakelockFragment) ContributorsFragment(com.moro.mtweaks.fragments.other.ContributorsFragment) ProfileFragment(com.moro.mtweaks.fragments.tools.ProfileFragment) GPUFragment(com.moro.mtweaks.fragments.kernel.GPUFragment) VMFragment(com.moro.mtweaks.fragments.kernel.VMFragment) DownloadsFragment(com.moro.mtweaks.fragments.tools.downloads.DownloadsFragment) DonationFragment(com.moro.mtweaks.fragments.other.DonationFragment) BaseFragment(com.moro.mtweaks.fragments.BaseFragment) KSMFragment(com.moro.mtweaks.fragments.kernel.KSMFragment) BatteryFragment(com.moro.mtweaks.fragments.kernel.BatteryFragment) InputsFragment(com.moro.mtweaks.fragments.statistics.InputsFragment) HmpFragment(com.moro.mtweaks.fragments.kernel.HmpFragment) OnBootFragment(com.moro.mtweaks.fragments.tools.OnBootFragment) CPUHotplugFragment(com.moro.mtweaks.fragments.kernel.CPUHotplugFragment) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Monitor(com.moro.mtweaks.services.monitor.Monitor) WebpageReader(com.moro.mtweaks.utils.WebpageReader) Toolbar(android.support.v7.widget.Toolbar) AdNativeExpress(com.moro.mtweaks.views.AdNativeExpress)

Aggregations

Fragment (android.support.v4.app.Fragment)2 BaseFragment (com.moro.mtweaks.fragments.BaseFragment)2 RecyclerViewFragment (com.moro.mtweaks.fragments.RecyclerViewFragment)2 BatteryFragment (com.moro.mtweaks.fragments.kernel.BatteryFragment)2 BoefflaWakelockFragment (com.moro.mtweaks.fragments.kernel.BoefflaWakelockFragment)2 CPUFragment (com.moro.mtweaks.fragments.kernel.CPUFragment)2 CPUHotplugFragment (com.moro.mtweaks.fragments.kernel.CPUHotplugFragment)2 CPUVoltageCl0Fragment (com.moro.mtweaks.fragments.kernel.CPUVoltageCl0Fragment)2 CPUVoltageCl1Fragment (com.moro.mtweaks.fragments.kernel.CPUVoltageCl1Fragment)2 DvfsFragment (com.moro.mtweaks.fragments.kernel.DvfsFragment)2 EntropyFragment (com.moro.mtweaks.fragments.kernel.EntropyFragment)2 GPUFragment (com.moro.mtweaks.fragments.kernel.GPUFragment)2 HmpFragment (com.moro.mtweaks.fragments.kernel.HmpFragment)2 IOFragment (com.moro.mtweaks.fragments.kernel.IOFragment)2 KSMFragment (com.moro.mtweaks.fragments.kernel.KSMFragment)2 LEDFragment (com.moro.mtweaks.fragments.kernel.LEDFragment)2 LMKFragment (com.moro.mtweaks.fragments.kernel.LMKFragment)2 MiscFragment (com.moro.mtweaks.fragments.kernel.MiscFragment)2 ScreenFragment (com.moro.mtweaks.fragments.kernel.ScreenFragment)2 SoundFragment (com.moro.mtweaks.fragments.kernel.SoundFragment)2