Search in sources :

Example 71 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project cardslib by gabrielemariotti.

the class LPreviewUtilsBase method setupDrawerToggle.

//----------------------------------------------------------------------------
// Navigation Drawer
//----------------------------------------------------------------------------
public ActionBarDrawerToggle setupDrawerToggle(DrawerLayout drawerLayout, final DrawerLayout.DrawerListener drawerListener) {
    mDrawerToggle = new ActionBarDrawerToggle(mActivity, /* host Activity */
    drawerLayout, /* DrawerLayout object */
    mActionBarToolbar, /* nav drawer icon to replace 'Up' caret */
    R.string.app_name, /* "open drawer" description */
    R.string.app_name);
    drawerLayout.setDrawerListener(mDrawerToggle);
    return mDrawerToggle;
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 72 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project android-UniversalMusicPlayer by googlesamples.

the class ActionBarCastActivity method initializeToolbar.

protected void initializeToolbar() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mToolbar == null) {
        throw new IllegalStateException("Layout is required to include a Toolbar with id " + "'toolbar'");
    }
    mToolbar.inflateMenu(R.menu.main);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout != null) {
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        if (navigationView == null) {
            throw new IllegalStateException("Layout requires a NavigationView " + "with id 'nav_view'");
        }
        // Create an ActionBarDrawerToggle that will handle opening/closing of the drawer:
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open_content_drawer, R.string.close_content_drawer);
        mDrawerLayout.setDrawerListener(mDrawerListener);
        populateDrawerItems(navigationView);
        setSupportActionBar(mToolbar);
        updateDrawerToggle();
    } else {
        setSupportActionBar(mToolbar);
    }
    mToolbarInitialized = true;
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 73 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project MaterialIntroView by iammert.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (savedInstanceState == null)
        getSupportFragmentManager().beginTransaction().add(R.id.container, new MainFragment()).commit();
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : MainFragment(co.mobiwise.sample.fragment.MainFragment) NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 74 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Klyph by jonathangerbaud.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*
		 * if (KlyphSession.getSessionUserName() != null)
		 * {
		 * loggedIn = true;
		 * setTitle(KlyphSession.getSessionUserName());
		 * }
		 * else
		 * {
		 * if (KlyphFlags.IS_PRO_VERSION == true)
		 * setTitle(R.string.app_pro_name);
		 * else
		 * setTitle(R.string.app_name);
		 * }
		 */
    setTitle("");
    if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) {
        getActionBar().hide();
        getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit();
    }
    // notificationsFragment.setHasOptionsMenu(false);
    adContainer = (ViewGroup) findViewById(R.id.ad);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) {

        @Override
        public void onDrawerOpened(View view) {
            Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: ");
            super.onDrawerOpened(view);
            Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
            if (drawer.isDrawerOpen(Gravity.RIGHT)) {
                if (notificationsFragment != null) {
                    notificationsFragment.setHasOptionsMenu(true);
                    notificationsFragment.onOpenPane();
                }
                if (fragment != null)
                    fragment.setHasOptionsMenu(false);
            } else if (drawer.isDrawerOpen(Gravity.LEFT)) {
                if (notificationsFragment != null) {
                    notificationsFragment.setHasOptionsMenu(false);
                }
                if (fragment != null)
                    fragment.setHasOptionsMenu(true);
            }
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            if (!drawer.isDrawerOpen(Gravity.RIGHT)) {
                if (notificationsFragment != null)
                    notificationsFragment.setHasOptionsMenu(false);
                Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
                if (fragment != null)
                    fragment.setHasOptionsMenu(true);
            }
            invalidateOptionsMenu();
        }
    };
    drawer.setDrawerListener(drawerToggle);
    final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels();
    classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses());
    classes.add("com.abewy.android.apps.klyph.fragment.UserTimeline");
    navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels);
    final ListView navList = (ListView) findViewById(R.id.drawer);
    // Setting drawers max width
    int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width);
    int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64);
    int finalWidth = Math.min(maxWidth, w);
    LayoutParams params = ((View) navList.getParent()).getLayoutParams();
    params.width = finalWidth;
    ((View) navList.getParent()).setLayoutParams(params);
    final View notificationContainer = findViewById(R.id.notifications_container);
    params = notificationContainer.getLayoutParams();
    params.width = finalWidth;
    notificationContainer.setLayoutParams(params);
    // End max width
    navList.setFadingEdgeLength(0);
    navList.setVerticalFadingEdgeEnabled(false);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) {
            updateContent(pos);
            drawer.closeDrawer(Gravity.LEFT);
        }
    });
    // Facebook HashKey
    if (KlyphFlags.LOG_FACEBOOK_HASH)
        FacebookUtil.logHash(this);
    // Hierarchy View Connector
    if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR)
        HierachyViewUtil.connectHierarchyView(this);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) UserCoverImageView(com.abewy.android.apps.klyph.widget.coverImage.UserCoverImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) Fragment(android.app.Fragment) IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment) ListView(android.widget.ListView)

Example 75 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project StatusBarUtil by laobie.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    contentLayout = (ViewGroup) findViewById(R.id.main);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mChbTranslucent = (CheckBox) findViewById(R.id.chb_translucent);
    mBtnSetColor = (Button) findViewById(R.id.btn_set_color);
    mBtnSetTransparent = (Button) findViewById(R.id.btn_set_transparent);
    mBtnSetTranslucent = (Button) findViewById(R.id.btn_set_translucent);
    mBtnSetForImageView = (Button) findViewById(R.id.btn_set_for_image_view);
    mBtnUseInFragment = (Button) findViewById(R.id.btn_use_in_fragment);
    mBtnSetColorForSwipeBack = (Button) findViewById(R.id.btn_set_color_for_swipe_back);
    mSbChangeAlpha = (SeekBar) findViewById(R.id.sb_change_alpha);
    mTvStatusAlpha = (TextView) findViewById(R.id.tv_status_alpha);
    setSupportActionBar(mToolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.setDrawerListener(toggle);
    toggle.syncState();
    mBtnSetColor.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ColorStatusBarActivity.class);
            startActivity(intent);
        }
    });
    mBtnSetTransparent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ImageStatusBarActivity.class);
            intent.putExtra(ImageStatusBarActivity.EXTRA_IS_TRANSPARENT, true);
            startActivity(intent);
        }
    });
    mBtnSetTranslucent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ImageStatusBarActivity.class);
            intent.putExtra(ImageStatusBarActivity.EXTRA_IS_TRANSPARENT, false);
            startActivity(intent);
        }
    });
    mBtnSetForImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ImageViewActivity.class);
            startActivity(intent);
        }
    });
    mBtnUseInFragment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, UseInFragmentActivity.class);
            startActivity(intent);
        }
    });
    mBtnSetColorForSwipeBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, SwipeBackActivity.class);
            startActivity(intent);
        }
    });
    mChbTranslucent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mChbTranslucent.isChecked()) {
                contentLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_monkey));
                StatusBarUtil.setTranslucentForDrawerLayout(MainActivity.this, mDrawerLayout, mAlpha);
                mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));
            } else {
                contentLayout.setBackgroundDrawable(null);
                mToolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
                StatusBarUtil.setColorForDrawerLayout(MainActivity.this, mDrawerLayout, getResources().getColor(R.color.colorPrimary), mAlpha);
            }
        }
    });
    mSbChangeAlpha.setMax(255);
    mSbChangeAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAlpha = progress;
            if (mChbTranslucent.isChecked()) {
                StatusBarUtil.setTranslucentForDrawerLayout(MainActivity.this, mDrawerLayout, mAlpha);
            } else {
                StatusBarUtil.setColorForDrawerLayout(MainActivity.this, mDrawerLayout, mStatusBarColor, mAlpha);
            }
            mTvStatusAlpha.setText(String.valueOf(mAlpha));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    mSbChangeAlpha.setProgress(StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
Also used : SeekBar(android.widget.SeekBar) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)80 View (android.view.View)76 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)34 TextView (android.widget.TextView)31 NavigationView (android.support.design.widget.NavigationView)30 AdapterView (android.widget.AdapterView)30 ListView (android.widget.ListView)29 Toolbar (android.support.v7.widget.Toolbar)25 DrawerLayout (android.support.v4.widget.DrawerLayout)23 ActionBar (android.support.v7.app.ActionBar)19 ImageView (android.widget.ImageView)16 SharedPreferences (android.content.SharedPreferences)14 Intent (android.content.Intent)12 RecyclerView (android.support.v7.widget.RecyclerView)8 SearchView (android.support.v7.widget.SearchView)8 Handler (android.os.Handler)6 PackageManager (android.content.pm.PackageManager)5 MenuItem (android.view.MenuItem)5 InjectView (butterknife.InjectView)5 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)5