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();
}
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);
}
}
Aggregations