Search in sources :

Example 16 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project JamsMusicPlayer by psaravan.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    //Context and Common object(s).
    mContext = getApplicationContext();
    mApp = (Common) getApplicationContext();
    //Set the theme and inflate the layout.
    setTheme();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //Init the UI elements.
    mDrawerParentLayout = (FrameLayout) findViewById(R.id.main_activity_root);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_root);
    mNavDrawerLayout = (RelativeLayout) findViewById(R.id.nav_drawer_container);
    mCurrentQueueDrawerLayout = (RelativeLayout) findViewById(R.id.current_queue_drawer_container);
    //Load the drawer fragments.
    loadDrawerFragments();
    //KitKat specific translucency.
    applyKitKatTranslucency();
    //Load the fragment.
    loadFragment(savedInstanceState);
    /**
    	 * Navigation drawer toggle.
    	 */
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer, 0, 0) {

        @Override
        public void onDrawerClosed(View view) {
            if (mQueueDrawerFragment != null && view == mCurrentQueueDrawerLayout)
                mQueueDrawerFragment.setIsDrawerOpen(false);
        }

        @Override
        public void onDrawerOpened(View view) {
            if (mQueueDrawerFragment != null && view == mCurrentQueueDrawerLayout)
                mQueueDrawerFragment.setIsDrawerOpen(true);
        }
    };
    //Apply the drawer toggle to the DrawerLayout.
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayShowHomeEnabled(true);
    //Check if this is the first time the app is being started.
    if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) {
        showAlbumArtScanningDialog();
        mApp.getSharedPreferences().edit().putBoolean(Common.FIRST_RUN, false).commit();
    }
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) TextView(android.widget.TextView)

Example 17 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project robolectric by robolectric.

the class ShadowDrawerLayoutTest method canGetAndSetDrawerListener.

@Test
public void canGetAndSetDrawerListener() throws Exception {
    DrawerLayout drawerLayout = new DrawerLayout(Robolectric.buildActivity(Activity.class).create().get());
    DrawerLayout.DrawerListener mockDrawerListener = mock(DrawerLayout.DrawerListener.class);
    drawerLayout.setDrawerListener(mockDrawerListener);
    assertThat(shadowOf(drawerLayout).getDrawerListener()).isSameAs(mockDrawerListener);
}
Also used : Activity(android.app.Activity) ShadowDrawerLayout(org.robolectric.shadows.support.v4.ShadowDrawerLayout) DrawerLayout(android.support.v4.widget.DrawerLayout) Test(org.junit.Test)

Example 18 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (getFragmentManager().findFragmentById(R.id.content) == null) {
        showLorem();
    }
    ListView drawer = (ListView) findViewById(R.id.drawer);
    drawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_row, getResources().getStringArray(R.array.drawer_rows)));
    drawer.setOnItemClickListener(this);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
    drawerLayout.setDrawerListener(toggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
}
Also used : ListView(android.widget.ListView) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle)

Example 19 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project cheesesquare by chrisbanes.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 20 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project AndroidChangeSkin by hongyangAndroid.

the class MainActivity method initView.

private void initView() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerLayout);
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.id_left_menu_container);
    if (fragment == null) {
        fm.beginTransaction().add(R.id.id_left_menu_container, new MenuLeftFragment()).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)63 View (android.view.View)59 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 AdapterView (android.widget.AdapterView)22 NavigationView (android.support.design.widget.NavigationView)21 ListView (android.widget.ListView)21 Intent (android.content.Intent)19 Toolbar (android.support.v7.widget.Toolbar)19 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)12 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 SuppressLint (android.annotation.SuppressLint)5 TabLayout (android.support.design.widget.TabLayout)5 ArrayList (java.util.ArrayList)5 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4