use of androidx.drawerlayout.widget.DrawerLayout in project Slide by ccrama.
the class MultiredditOverview method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
try {
onBackPressed();
} catch (Exception ignored) {
}
return true;
case R.id.action_edit:
{
if (profile.isEmpty() && (UserSubscriptions.multireddits != null) && !UserSubscriptions.multireddits.isEmpty()) {
Intent i = new Intent(MultiredditOverview.this, CreateMulti.class);
i.putExtra(CreateMulti.EXTRA_MULTI, UserSubscriptions.multireddits.get(pager.getCurrentItem()).getDisplayName());
startActivity(i);
}
}
return true;
case R.id.search:
{
UserSubscriptions.MultiCallback m = new UserSubscriptions.MultiCallback() {
@Override
public void onComplete(List<MultiReddit> multireddits) {
if ((multireddits != null) && !multireddits.isEmpty()) {
searchMulti = multireddits.get(pager.getCurrentItem());
MaterialDialog.Builder builder = new MaterialDialog.Builder(MultiredditOverview.this).title(R.string.search_title).alwaysCallInputCallback().input(getString(R.string.search_msg), "", new MaterialDialog.InputCallback() {
@Override
public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
term = charSequence.toString();
}
});
// Add "search current sub" if it is not frontpage/all/random
builder.positiveText(getString(R.string.search_subreddit, "/m/" + searchMulti.getDisplayName())).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
Intent i = new Intent(MultiredditOverview.this, Search.class);
i.putExtra(Search.EXTRA_TERM, term);
i.putExtra(Search.EXTRA_MULTIREDDIT, searchMulti.getDisplayName());
startActivity(i);
}
});
builder.show();
}
}
};
if (profile.isEmpty()) {
UserSubscriptions.getMultireddits(m);
} else {
UserSubscriptions.getPublicMultireddits(m, profile);
}
}
return true;
case R.id.create:
if (profile.isEmpty()) {
Intent i2 = new Intent(MultiredditOverview.this, CreateMulti.class);
startActivity(i2);
}
return true;
case R.id.action_sort:
openPopup();
return true;
case R.id.subs:
((DrawerLayout) findViewById(R.id.drawer_layout)).openDrawer(Gravity.RIGHT);
return true;
case R.id.gallery:
if (SettingValues.isPro) {
List<Submission> posts = ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
if (posts != null && !posts.isEmpty()) {
Intent i2 = new Intent(this, Gallery.class);
i2.putExtra(Gallery.EXTRA_PROFILE, profile);
i2.putExtra(Gallery.EXTRA_MULTIREDDIT, ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
startActivity(i2);
}
} else {
final AlertDialog.Builder b = ProUtil.proUpgradeMsg(this, R.string.general_gallerymode_ispro).setNegativeButton(R.string.btn_no_thanks, (dialog, whichButton) -> dialog.dismiss());
if (SettingValues.previews > 0) {
b.setNeutralButton(getString(R.string.pro_previews, SettingValues.previews), (dialog, which) -> {
SettingValues.prefs.edit().putInt(SettingValues.PREVIEWS_LEFT, SettingValues.previews - 1).apply();
SettingValues.previews = SettingValues.prefs.getInt(SettingValues.PREVIEWS_LEFT, 10);
List<Submission> posts = ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
if (posts != null && !posts.isEmpty()) {
Intent i2 = new Intent(MultiredditOverview.this, Gallery.class);
i2.putExtra(Gallery.EXTRA_PROFILE, profile);
i2.putExtra(Gallery.EXTRA_MULTIREDDIT, ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
startActivity(i2);
}
});
}
b.show();
}
return true;
case R.id.action_shadowbox:
if (SettingValues.isPro) {
List<Submission> posts = ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
if (posts != null && !posts.isEmpty()) {
Intent i = new Intent(this, Shadowbox.class);
i.putExtra(Shadowbox.EXTRA_PAGE, getCurrentPage());
i.putExtra(Shadowbox.EXTRA_PROFILE, profile);
i.putExtra(Shadowbox.EXTRA_MULTIREDDIT, ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
startActivity(i);
}
} else {
final AlertDialog.Builder b = ProUtil.proUpgradeMsg(this, R.string.general_shadowbox_ispro).setNegativeButton(R.string.btn_no_thanks, (dialog, whichButton) -> dialog.dismiss());
if (SettingValues.previews > 0 && adapter != null && ((MultiredditView) adapter.getCurrentFragment()).posts != null && ((MultiredditView) adapter.getCurrentFragment()).posts.posts != null && !((MultiredditView) adapter.getCurrentFragment()).posts.posts.isEmpty()) {
b.setNeutralButton(getString(R.string.pro_previews, SettingValues.previews), (dialog, which) -> {
SettingValues.prefs.edit().putInt(SettingValues.PREVIEWS_LEFT, SettingValues.previews - 1).apply();
SettingValues.previews = SettingValues.prefs.getInt(SettingValues.PREVIEWS_LEFT, 10);
List<Submission> posts = ((MultiredditView) adapter.getCurrentFragment()).posts.posts;
if (posts != null && !posts.isEmpty()) {
Intent i = new Intent(MultiredditOverview.this, Shadowbox.class);
i.putExtra(Shadowbox.EXTRA_PAGE, getCurrentPage());
i.putExtra(Shadowbox.EXTRA_PROFILE, profile);
i.putExtra(Shadowbox.EXTRA_MULTIREDDIT, ((MultiredditView) adapter.getCurrentFragment()).posts.multiReddit.getDisplayName());
startActivity(i);
}
});
}
b.show();
}
return true;
default:
return false;
}
}
use of androidx.drawerlayout.widget.DrawerLayout in project SwipeRecyclerView by yanzhenjie.
the class DrawerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mRecyclerView.setSwipeMenuCreator(mSwipeMenuCreator);
mRecyclerView.setOnItemMenuClickListener(mItemMenuClickListener);
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, mToolbar, R.string.app_name, R.string.app_name);
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
mRecyclerView.setAdapter(mAdapter);
mAdapter.notifyDataSetChanged(mDataList);
}
use of androidx.drawerlayout.widget.DrawerLayout in project RxBinding by JakeWharton.
the class RxDrawerLayoutTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawerLayout = new DrawerLayout(this);
drawerLayout.setId(android.R.id.primary);
FrameLayout main = new FrameLayout(this);
LayoutParams mainParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
drawerLayout.addView(main, mainParams);
FrameLayout drawer = new FrameLayout(this);
drawer.setBackgroundColor(Color.WHITE);
LayoutParams drawerParams = new LayoutParams(300, MATCH_PARENT, RIGHT);
drawerLayout.addView(drawer, drawerParams);
setContentView(drawerLayout);
}
use of androidx.drawerlayout.widget.DrawerLayout in project AntennaPod by AntennaPod.
the class MainActivity method setupToolbarToggle.
public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) {
if (drawerLayout != null) {
// Tablet layout does not have a drawer
if (drawerToggle != null) {
drawerLayout.removeDrawerListener(drawerToggle);
}
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
drawerToggle.setDrawerIndicatorEnabled(!displayUpArrow);
drawerToggle.setToolbarNavigationClickListener(v -> getSupportFragmentManager().popBackStack());
} else if (!displayUpArrow) {
toolbar.setNavigationIcon(null);
} else {
toolbar.setNavigationIcon(ThemeUtils.getDrawableFromAttr(this, R.attr.homeAsUpIndicator));
toolbar.setNavigationOnClickListener(v -> getSupportFragmentManager().popBackStack());
}
}
use of androidx.drawerlayout.widget.DrawerLayout in project IITB-App by wncc.
the class MainActivity method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
switch(id) {
case R.id.nav_feed:
feedFragment = new FeedFragment();
updateFragment(feedFragment);
break;
case R.id.nav_explore:
updateFragment(ExploreFragment.newInstance());
break;
case R.id.nav_news:
updateFragment(new NewsFragment());
break;
case R.id.nav_placement_blog:
openPlacementBlog();
break;
case R.id.nav_training_blog:
openTrainingBlog();
break;
case R.id.nav_mess_menu:
MessMenuFragment messMenuFragment = new MessMenuFragment();
updateFragment(messMenuFragment);
break;
case R.id.nav_calendar:
CalendarFragment calendarFragment = new CalendarFragment();
updateFragment(calendarFragment);
break;
case R.id.nav_qlinks:
QuickLinksFragment quickLinksFragment = new QuickLinksFragment();
updateFragment(quickLinksFragment);
break;
case R.id.nav_map:
MapFragment mapFragment = new MapFragment();
updateFragment(mapFragment);
break;
case R.id.nav_achievements:
WebViewFragment webViewFragment = new WebViewFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_ACHIEVEMENTS);
webViewFragment.setArguments(bundle);
updateFragment(webViewFragment);
break;
case R.id.nav_complaint:
if (session.isLoggedIn()) {
ComplaintsFragment complaintsFragment = new ComplaintsFragment();
updateFragment(complaintsFragment);
} else {
Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show();
}
break;
case R.id.nav_settings:
SettingsFragment settingsFragment = new SettingsFragment();
updateFragment(settingsFragment);
break;
default:
break;
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
Aggregations