Search in sources :

Example 86 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project MaterialDrawer by mikepenz.

the class DrawerBuilder method handleDrawerNavigation.

/**
     * handles the different logics for the Drawer Navigation Listeners / Indications (ActionBarDrawertoggle)
     */
protected void handleDrawerNavigation(Activity activity, boolean recreateActionBarDrawerToggle) {
    //set the navigationOnClickListener
    final View.OnClickListener toolbarNavigationListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean handled = false;
            if (mOnDrawerNavigationListener != null && (mActionBarDrawerToggle != null && !mActionBarDrawerToggle.isDrawerIndicatorEnabled())) {
                handled = mOnDrawerNavigationListener.onNavigationClickListener(v);
            }
            if (!handled) {
                if (mDrawerLayout.isDrawerOpen(mDrawerGravity)) {
                    mDrawerLayout.closeDrawer(mDrawerGravity);
                } else {
                    mDrawerLayout.openDrawer(mDrawerGravity);
                }
            }
        }
    };
    if (recreateActionBarDrawerToggle) {
        mActionBarDrawerToggle = null;
    }
    // create the ActionBarDrawerToggle if not set and enabled and if we have a toolbar
    if (mActionBarDrawerToggleEnabled && mActionBarDrawerToggle == null && mToolbar != null) {
        this.mActionBarDrawerToggle = new ActionBarDrawerToggle(activity, mDrawerLayout, mToolbar, R.string.material_drawer_open, R.string.material_drawer_close) {

            @Override
            public void onDrawerOpened(View drawerView) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerOpened(drawerView);
                }
                super.onDrawerOpened(drawerView);
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerClosed(drawerView);
                }
                super.onDrawerClosed(drawerView);
            }

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerSlide(drawerView, slideOffset);
                }
                if (!mAnimateActionBarDrawerToggle) {
                    super.onDrawerSlide(drawerView, 0);
                } else {
                    super.onDrawerSlide(drawerView, slideOffset);
                }
            }
        };
        this.mActionBarDrawerToggle.syncState();
    }
    //we also have to do this after setting the ActionBarDrawerToggle as this will overwrite this
    if (mToolbar != null) {
        this.mToolbar.setNavigationOnClickListener(toolbarNavigationListener);
    }
    //handle the ActionBarDrawerToggle
    if (mActionBarDrawerToggle != null) {
        mActionBarDrawerToggle.setToolbarNavigationClickListener(toolbarNavigationListener);
        mDrawerLayout.addDrawerListener(mActionBarDrawerToggle);
    } else {
        mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerSlide(drawerView, slideOffset);
                }
            }

            @Override
            public void onDrawerOpened(View drawerView) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerOpened(drawerView);
                }
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                if (mOnDrawerListener != null) {
                    mOnDrawerListener.onDrawerClosed(drawerView);
                }
            }

            @Override
            public void onDrawerStateChanged(int newState) {
            }
        });
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 87 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project platform_frameworks_base by android.

the class DrawerController method create.

/**
     * Returns a controller suitable for {@code Layout}.
     */
static DrawerController create(Activity activity) {
    DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    if (layout == null) {
        return new DummyDrawerController();
    }
    View drawer = activity.findViewById(R.id.drawer_roots);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
    drawer.getLayoutParams().width = calculateDrawerWidth(activity);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
    return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Example 88 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project SimpleNews by liuling07.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close);
    mDrawerToggle.syncState();
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
    setupDrawerContent(mNavigationView);
    mMainPresenter = new MainPresenterImpl(this);
    switch2News();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MainPresenterImpl(com.lauren.simplenews.main.presenter.MainPresenterImpl)

Example 89 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project FloatingActionButton by Clans.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(navigationItemSelectedListener);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.fragment, new HomeFragment()).commit();
    }
    navigationView.setCheckedItem(R.id.home);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Toolbar(android.support.v7.widget.Toolbar)

Example 90 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    deviceFragment = new DeviceFragment();
    cellInfoFragment = new CellInfoFragment();
    atCommandFragment = new AtCommandFragment();
    dbViewerFragment = new DbViewerFragment();
    mapFragment = new MapFragment();
    mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build();
    mDrawerLayout = (DrawerLayout) findViewById(mNavConf.getDrawerLayoutId());
    mDrawerList = (ListView) findViewById(mNavConf.getLeftDrawerId());
    mActionBar = getSupportActionBar();
    mTitle = getTitle();
    mDrawerTitle = getTitle();
    mDrawerList.setAdapter(mNavConf.getBaseAdapter());
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.string.drawer_open, /* "open drawer" description */
    R.string.drawer_close) {

        /* "close drawer" description */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setTitle(mTitle);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mActionBar.setTitle(mDrawerTitle);
            invalidateOptionsMenu();
        }
    };
    // Set the drawer toggle as the DrawerListener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    prefs = getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
    /* Pref listener to enable sms detection on pref change   */
    prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {

        public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
            if (key.equals(getString(R.string.adv_user_root_pref_key))) {
                SmsDetection();
            }
        }
    };
    prefs.registerOnSharedPreferenceChangeListener(prefListener);
    mDisclaimerAccepted = getResources().getString(R.string.disclaimer_accepted);
    if (!prefs.getBoolean(mDisclaimerAccepted, false)) {
        final AlertDialog.Builder disclaimer = new AlertDialog.Builder(this).setTitle(R.string.disclaimer_title).setMessage(R.string.disclaimer).setPositiveButton(R.string.text_agree, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                prefsEditor = prefs.edit();
                prefsEditor.putBoolean(mDisclaimerAccepted, true);
                prefsEditor.apply();
                startService();
            }
        }).setNegativeButton(R.string.text_disagree, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                prefsEditor = prefs.edit();
                prefsEditor.putBoolean(mDisclaimerAccepted, false);
                prefsEditor.apply();
                Uri packageUri = Uri.parse("package:com.SecUpwN.AIMSICD");
                Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
                startActivity(uninstallIntent);
                finish();
                if (mAimsicdService != null) {
                    mAimsicdService.onDestroy();
                }
            }
        });
        AlertDialog disclaimerAlert = disclaimer.create();
        disclaimerAlert.show();
    } else {
        startService();
    }
}
Also used : AlertDialog(android.app.AlertDialog) AtCommandFragment(com.secupwn.aimsicd.ui.fragments.AtCommandFragment) SharedPreferences(android.content.SharedPreferences) DialogInterface(android.content.DialogInterface) MapFragment(com.secupwn.aimsicd.ui.fragments.MapFragment) DeviceFragment(com.secupwn.aimsicd.ui.fragments.DeviceFragment) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Uri(android.net.Uri) CellInfoFragment(com.secupwn.aimsicd.ui.fragments.CellInfoFragment) DbViewerFragment(com.secupwn.aimsicd.ui.fragments.DbViewerFragment)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)91 View (android.view.View)80 NavigationView (android.support.design.widget.NavigationView)34 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)32 Toolbar (android.support.v7.widget.Toolbar)31 AdapterView (android.widget.AdapterView)30 DrawerLayout (android.support.v4.widget.DrawerLayout)29 ListView (android.widget.ListView)29 ActionBar (android.support.v7.app.ActionBar)20 ImageView (android.widget.ImageView)18 Intent (android.content.Intent)15 SharedPreferences (android.content.SharedPreferences)15 RecyclerView (android.support.v7.widget.RecyclerView)9 SearchView (android.support.v7.widget.SearchView)8 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5