use of com.mxt.anitrend.adapter.pager.index.FeedPageAdapter in project anitrend-app by AniTrend.
the class MainActivity method onNavigate.
private void onNavigate(@IdRes int menu) {
Intent intent;
switch(menu) {
case R.id.nav_home_feed:
mToolbar.setTitle(getString(R.string.drawer_title_home));
selectedItem = menu;
mViewPager.setAdapter(new FeedPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
break;
case R.id.nav_anime:
mToolbar.setTitle(getString(R.string.drawer_title_anime));
selectedItem = menu;
mViewPager.setAdapter(new SeasonPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
mViewPager.setCurrentItem(mPageIndex, false);
break;
case R.id.nav_manga:
mToolbar.setTitle(getString(R.string.drawer_title_manga));
selectedItem = menu;
mViewPager.setAdapter(new MangaPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
break;
case R.id.nav_trending:
mToolbar.setTitle(getString(R.string.drawer_title_trending));
selectedItem = menu;
mViewPager.setAdapter(new TrendingPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
break;
case R.id.nav_airing:
mToolbar.setTitle(getString(R.string.drawer_title_airing));
mViewPager.setAdapter(new AiringPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
selectedItem = menu;
break;
case R.id.nav_myanime:
intent = new Intent(this, MediaListActivity.class);
intent.putExtra(KeyUtil.arg_mediaType, KeyUtil.ANIME);
intent.putExtra(KeyUtil.arg_userName, getPresenter().getDatabase().getCurrentUser().getName());
intent.putExtra(KeyUtil.arg_id, getPresenter().getDatabase().getCurrentUser().getId());
startActivity(intent);
break;
case R.id.nav_mymanga:
intent = new Intent(this, MediaListActivity.class);
intent.putExtra(KeyUtil.arg_mediaType, KeyUtil.MANGA);
intent.putExtra(KeyUtil.arg_userName, getPresenter().getDatabase().getCurrentUser().getName());
intent.putExtra(KeyUtil.arg_id, getPresenter().getDatabase().getCurrentUser().getId());
startActivity(intent);
break;
case R.id.nav_hub:
mToolbar.setTitle(getString(R.string.drawer_title_hub));
mViewPager.setAdapter(new HubPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
selectedItem = menu;
break;
case R.id.nav_reviews:
mToolbar.setTitle(getString(R.string.drawer_title_reviews));
selectedItem = menu;
mViewPager.setAdapter(new ReviewPageAdapter(getSupportFragmentManager(), getApplicationContext()));
mNavigationTabStrip.setViewPager(mViewPager);
break;
case R.id.nav_sign_in:
startActivity(new Intent(MainActivity.this, LoginActivity.class));
break;
case R.id.nav_sign_out:
mBottomSheet = new BottomSheetMessage.Builder().setText(R.string.drawer_signout_text).setTitle(R.string.drawer_signout_title).setPositiveText(R.string.Yes).setNegativeText(R.string.No).buildWithCallback(new BottomSheetChoice() {
@Override
public void onPositiveButton() {
WebTokenRequest.invalidateInstance(getApplicationContext());
Intent intent = new Intent(MainActivity.this, SplashActivity.class);
finish();
startActivity(intent);
}
@Override
public void onNegativeButton() {
}
});
showBottomSheet();
break;
case R.id.nav_check_update:
switch(ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
case PERMISSION_GRANTED:
mBottomSheet = new BottomSheetMessage.Builder().setText(R.string.drawer_update_text).setTitle(R.string.drawer_update_title).setPositiveText(R.string.Yes).setNegativeText(R.string.No).buildWithCallback(new BottomSheetChoice() {
@Override
public void onPositiveButton() {
Version version = getPresenter().getDatabase().getRemoteVersion();
if (version != null && version.isNewerVersion())
DownloaderService.downloadNewVersion(MainActivity.this, version);
else
NotifyUtil.createAlerter(MainActivity.this, getString(R.string.title_update_infodadat), getString(R.string.app_no_date), R.drawable.ic_cloud_done_white_24dp, R.color.colorStateGreen);
}
@Override
public void onNegativeButton() {
}
});
showBottomSheet();
break;
case PERMISSION_DENIED:
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE))
DialogUtil.createMessage(MainActivity.this, R.string.title_permission_write, R.string.text_permission_write, (dialog, which) -> {
switch(which) {
case POSITIVE:
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_PERMISSION);
break;
case NEGATIVE:
NotifyUtil.makeText(MainActivity.this, R.string.canceled_by_user, Toast.LENGTH_SHORT).show();
break;
}
});
else
hasPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
break;
}
break;
case R.id.nav_light_theme:
getPresenter().getApplicationPref().toggleTheme();
recreate();
break;
default:
break;
}
}
Aggregations