Search in sources :

Example 41 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project UltimateAndroid by cymcsg.

the class NavigationDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fading_actionbar_activity_navigation_drawer);
    mTitle = mDrawerTitle = getTitle();
    mCityNames = getResources().getStringArray(R.array.drawer_items);
    TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images);
    mCityImages = new int[typedArray.length()];
    for (int i = 0; i < typedArray.length(); ++i) {
        mCityImages[i] = typedArray.getResourceId(i, 0);
    }
    typedArray.recycle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.fading_actionbar_drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.fading_actionbar_drawer_list_item, mCityNames));
    mDrawerList.setOnItemClickListener(this);
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.fading_actionbar_ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        selectItem(0);
    }
}
Also used : TypedArray(android.content.res.TypedArray) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 42 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Android-Image-Cropper by ArthurHub.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.main_drawer_open, R.string.main_drawer_close);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        setMainFragmentByPreset(CropDemoPreset.RECT);
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 43 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project AntennaPod by AntennaPod.

the class MediaplayerInfoActivity method setupGUI.

@Override
protected void setupGUI() {
    super.setupGUI();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        findViewById(R.id.shadow).setVisibility(View.GONE);
        AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBar);
        float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        appBarLayout.setElevation(px);
    }
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navList = (ListView) findViewById(R.id.nav_list);
    navDrawer = findViewById(R.id.nav_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
    drawerToggle.setDrawerIndicatorEnabled(false);
    drawerLayout.setDrawerListener(drawerToggle);
    navAdapter = new NavListAdapter(itemAccess, this);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener((parent, view, position, id) -> {
        int viewType = parent.getAdapter().getItemViewType(position);
        if (viewType != NavListAdapter.VIEW_TYPE_SECTION_DIVIDER) {
            Intent intent = new Intent(MediaplayerInfoActivity.this, MainActivity.class);
            intent.putExtra(MainActivity.EXTRA_NAV_TYPE, viewType);
            intent.putExtra(MainActivity.EXTRA_NAV_INDEX, position);
            startActivity(intent);
        }
        drawerLayout.closeDrawer(navDrawer);
    });
    navList.setOnItemLongClickListener((parent, view, position, id) -> {
        if (position < navAdapter.getTags().size()) {
            showDrawerPreferencesDialog();
            return true;
        } else {
            mPosition = position;
            return false;
        }
    });
    registerForContextMenu(navList);
    drawerToggle.syncState();
    findViewById(R.id.nav_settings).setOnClickListener(v -> {
        drawerLayout.closeDrawer(navDrawer);
        startActivity(new Intent(MediaplayerInfoActivity.this, PreferenceController.getPreferenceActivity()));
    });
    butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed);
    butCastDisconnect = (ImageButton) findViewById(R.id.butCastDisconnect);
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new MediaplayerInfoPagerAdapter(getSupportFragmentManager(), media);
    pagerAdapter.setController(controller);
    pager.setAdapter(pagerAdapter);
    CirclePageIndicator pageIndicator = (CirclePageIndicator) findViewById(R.id.page_indicator);
    pageIndicator.setViewPager(pager);
    loadLastFragment();
    pager.onSaveInstanceState();
}
Also used : NavListAdapter(de.danoeh.antennapod.adapter.NavListAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) AppBarLayout(android.support.design.widget.AppBarLayout) CirclePageIndicator(com.viewpagerindicator.CirclePageIndicator) Toolbar(android.support.v7.widget.Toolbar)

Example 44 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project kdeconnect-android by KDE.

the class MaterialActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_drawer);
    View mDrawerHeader = mNavigationView.getHeaderView(0);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.string.open, /* "open drawer" description */
    R.string.close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    actionBar.setDisplayHomeAsUpEnabled(true);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerToggle.syncState();
    String deviceName = DeviceHelper.getDeviceName(this);
    TextView nameView = (TextView) mDrawerHeader.findViewById(R.id.device_name);
    nameView.setText(deviceName);
    View.OnClickListener renameListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            renameDevice();
        }
    };
    mDrawerHeader.findViewById(R.id.kdeconnect_label).setOnClickListener(renameListener);
    mDrawerHeader.findViewById(R.id.device_name).setOnClickListener(renameListener);
    mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            String deviceId = mMapMenuToDeviceId.get(menuItem);
            onDeviceSelected(deviceId);
            mDrawerLayout.closeDrawer(mNavigationView);
            return true;
        }
    });
    preferences = getSharedPreferences(STATE_SELECTED_DEVICE, Context.MODE_PRIVATE);
    String savedDevice;
    String pairStatus = "";
    if (getIntent().hasExtra("forceOverview")) {
        Log.i("MaterialActivity", "Requested to start main overview");
        savedDevice = null;
    } else if (getIntent().hasExtra("deviceId")) {
        Log.i("MaterialActivity", "Loading selected device from parameter");
        savedDevice = getIntent().getStringExtra("deviceId");
        if (getIntent().hasExtra(PAIR_REQUEST_STATUS)) {
            pairStatus = getIntent().getStringExtra(PAIR_REQUEST_STATUS);
        }
    } else if (savedInstanceState != null) {
        Log.i("MaterialActivity", "Loading selected device from saved activity state");
        savedDevice = savedInstanceState.getString(STATE_SELECTED_DEVICE);
    } else {
        Log.i("MaterialActivity", "Loading selected device from persistent storage");
        savedDevice = preferences.getString(STATE_SELECTED_DEVICE, null);
    }
    //if pairStatus is not empty, then the decision has been made...
    if (!pairStatus.equals("")) {
        Log.i("MaterialActivity", "pair status is " + pairStatus);
        onNewDeviceSelected(savedDevice, pairStatus);
    }
    onDeviceSelected(savedDevice);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) TextView(android.widget.TextView) MenuItem(android.view.MenuItem) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 45 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project AdMoney by ErnestoGonAr.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    bd = new BDHandlerAM(this);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    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 : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)91 View (android.view.View)81 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)10 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