Search in sources :

Example 6 with DrawerLayout

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;
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Submission(net.dean.jraw.models.Submission) Intent(android.content.Intent) MultiReddit(net.dean.jraw.models.MultiReddit) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) MultiredditView(me.ccrama.redditslide.Fragments.MultiredditView) UserSubscriptions(me.ccrama.redditslide.UserSubscriptions)

Example 7 with DrawerLayout

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);
}
Also used : ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout)

Example 8 with DrawerLayout

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);
}
Also used : LayoutParams(androidx.drawerlayout.widget.DrawerLayout.LayoutParams) FrameLayout(android.widget.FrameLayout) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout)

Example 9 with 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());
    }
}
Also used : Bundle(android.os.Bundle) SearchFragment(de.danoeh.antennapod.fragment.SearchFragment) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Handler(android.os.Handler) Looper(android.os.Looper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) TargetApi(android.annotation.TargetApi) Log(android.util.Log) QueueFragment(de.danoeh.antennapod.fragment.QueueFragment) PlaybackService(de.danoeh.antennapod.core.service.playback.PlaybackService) ThemeUtils(de.danoeh.antennapod.ui.common.ThemeUtils) MediaButtonReceiver(de.danoeh.antennapod.core.receiver.MediaButtonReceiver) TransitionEffect(de.danoeh.antennapod.fragment.TransitionEffect) FragmentTransaction(androidx.fragment.app.FragmentTransaction) ThreadMode(org.greenrobot.eventbus.ThreadMode) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) Nullable(androidx.annotation.Nullable) DownloadsFragment(de.danoeh.antennapod.fragment.DownloadsFragment) MessageEvent(de.danoeh.antennapod.event.MessageEvent) Toolbar(androidx.appcompat.widget.Toolbar) Snackbar(com.google.android.material.snackbar.Snackbar) MainActivityStarter(de.danoeh.antennapod.ui.appstartintent.MainActivityStarter) NavDrawerFragment(de.danoeh.antennapod.fragment.NavDrawerFragment) Context(android.content.Context) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) AutoUpdateManager(de.danoeh.antennapod.core.util.download.AutoUpdateManager) FeedItemlistFragment(de.danoeh.antennapod.fragment.FeedItemlistFragment) Intent(android.content.Intent) ArrayUtils(org.apache.commons.lang3.ArrayUtils) AudioManager(android.media.AudioManager) MenuItem(android.view.MenuItem) Toast(android.widget.Toast) EventBus(org.greenrobot.eventbus.EventBus) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) Build(android.os.Build) FragmentManager(androidx.fragment.app.FragmentManager) SubscriptionFragment(de.danoeh.antennapod.fragment.SubscriptionFragment) R(de.danoeh.antennapod.R) LockableBottomSheetBehavior(de.danoeh.antennapod.view.LockableBottomSheetBehavior) CastEnabledActivity(de.danoeh.antennapod.playback.cast.CastEnabledActivity) AudioPlayerFragment(de.danoeh.antennapod.fragment.AudioPlayerFragment) RatingDialog(de.danoeh.antennapod.dialog.RatingDialog) PreferenceUpgrader(de.danoeh.antennapod.preferences.PreferenceUpgrader) Glide(com.bumptech.glide.Glide) Validate(org.apache.commons.lang3.Validate) Subscribe(org.greenrobot.eventbus.Subscribe) SharedPreferences(android.content.SharedPreferences) PlaybackHistoryFragment(de.danoeh.antennapod.fragment.PlaybackHistoryFragment) Configuration(android.content.res.Configuration) EpisodesFragment(de.danoeh.antennapod.fragment.EpisodesFragment) EditText(android.widget.EditText) AddFeedFragment(de.danoeh.antennapod.fragment.AddFeedFragment) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle)

Example 10 with DrawerLayout

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;
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) ComplaintsFragment(app.insti.fragment.ComplaintsFragment) WebViewFragment(app.insti.fragment.WebViewFragment) CalendarFragment(app.insti.fragment.CalendarFragment) Bundle(android.os.Bundle) MapFragment(app.insti.fragment.MapFragment) NewsFragment(app.insti.fragment.NewsFragment) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) MessMenuFragment(app.insti.fragment.MessMenuFragment) QuickLinksFragment(app.insti.fragment.QuickLinksFragment) SuppressLint(android.annotation.SuppressLint) FeedFragment(app.insti.fragment.FeedFragment)

Aggregations

DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)14 Intent (android.content.Intent)7 View (android.view.View)7 ActionBarDrawerToggle (androidx.appcompat.app.ActionBarDrawerToggle)6 Toolbar (androidx.appcompat.widget.Toolbar)5 Bundle (android.os.Bundle)4 ViewGroup (android.view.ViewGroup)4 NonNull (androidx.annotation.NonNull)4 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 Configuration (android.content.res.Configuration)3 Uri (android.net.Uri)3 Handler (android.os.Handler)3 MenuItem (android.view.MenuItem)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 Fragment (androidx.fragment.app.Fragment)3 NavigationView (com.google.android.material.navigation.NavigationView)3 SuppressLint (android.annotation.SuppressLint)2 SharedPreferences (android.content.SharedPreferences)2 Menu (android.view.Menu)2