Search in sources :

Example 81 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project SightRemote by TebbeUbben.

the class SightActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getRootLayout());
    setupToolbar();
    drawerLayout = findViewById(R.id.drawer_layout);
    navigationView = findViewById(R.id.navigation_view);
    contentFrame = findViewById(R.id.content_frame);
    if (useNavigationDrawer() && drawerLayout != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_navigation, R.string.close_navigation);
        drawerLayout.addDrawerListener(actionBarDrawerToggle);
        navigationView.setNavigationItemSelectedListener(this);
        if (getSelectedNavItemID() != 0)
            navigationView.getMenu().findItem(getSelectedNavItemID()).setChecked(true);
    } else if (drawerLayout != null)
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    hideOverlay();
    sightServiceConnector = new SightServiceConnector(this);
    sightServiceConnector.setConnectionCallback(connectionCallback);
    sightServiceConnector.addStatusCallback(statusCallback);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) SightServiceConnector(sugar.free.sightparser.handling.SightServiceConnector)

Example 82 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Auto.js by hyb1996.

the class MainActivity method setUpToolbar.

private void setUpToolbar() {
    Toolbar toolbar = $(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(R.string._app_name);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_drawer_open, R.string.text_drawer_close);
    drawerToggle.syncState();
    mDrawerLayout.addDrawerListener(drawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Toolbar(android.support.v7.widget.Toolbar)

Example 83 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project cuddly-octo-fortnight by prpr894.

the class MainActivity method initView.

private void initView() {
    mToolbar = findViewById(R.id.toolbar_main);
    mToolbar.setTitle("直播");
    mCustomDrawerLayout = findViewById(R.id.drawer);
    // 注意此段顺序
    setSupportActionBar(mToolbar);
    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
    // 不能挪走,应在上面两行的下面
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mCustomDrawerLayout, mToolbar, 0, 0);
    mCustomDrawerLayout.addDrawerListener(drawerToggle);
    drawerToggle.syncState();
    mNavigationView = findViewById(R.id.navigation);
    mNavigationView.setNavigationItemSelectedListener(this);
    // 开启彩色图标
    mNavigationView.setItemIconTintList(null);
    // 初始化一些东西
    mNavigationView.setCheckedItem(R.id.s_live);
    switchPage(0);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch(item.getItemId()) {
                case R.id.action_settings:
                    AlertDialog.Builder builder;
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
                        builder = new AlertDialog.Builder(MainActivity.this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert);
                    } else {
                        builder = new AlertDialog.Builder(MainActivity.this);
                    }
                    builder.setCancelable(false);
                    builder.setTitle("警告");
                    builder.setMessage("清空数据不可恢复,确定清空收藏吗?");
                    builder.setPositiveButton("清空", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            LiveRoomItemDataBeanDao beanDao = MyApp.getInstance().getDaoSession().getLiveRoomItemDataBeanDao();
                            beanDao.deleteAll();
                            MyToast.successBig("清除成功");
                        }
                    });
                    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    builder.create().show();
                    break;
            }
            return true;
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MenuItem(android.view.MenuItem) LiveRoomItemDataBeanDao(com.prpr894.cplayer.greendao.gen.LiveRoomItemDataBeanDao) Toolbar(android.support.v7.widget.Toolbar)

Example 84 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project malp by gateship-one.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // restore drag state
    if (savedInstanceState != null) {
        mSavedNowPlayingDragStatus = DRAG_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_DRAG_STATUS)];
        mSavedNowPlayingViewSwitcherStatus = VIEW_SWITCHER_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_VIEW_SWITCHER_CURRENT_VIEW)];
    }
    setContentView(R.layout.activity_main);
    // restore elevation behaviour as pre 24 support lib
    AppBarLayout layout = findViewById(R.id.appbar);
    layout.setStateListAnimator(null);
    ViewCompat.setElevation(layout, 0);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // enable back navigation
    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    if (drawer != null) {
        mDrawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(mDrawerToggle);
        mDrawerToggle.syncState();
    }
    int navId = getDefaultViewID();
    NavigationView navigationView = findViewById(R.id.nav_view);
    if (navigationView != null) {
        navigationView.setNavigationItemSelectedListener(this);
        navigationView.setCheckedItem(navId);
    }
    mFAB = findViewById(R.id.andrompd_play_button);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    mUseArtistSort = sharedPref.getBoolean(getString(R.string.pref_use_artist_sort_key), getResources().getBoolean(R.bool.pref_use_artist_sort_default));
    registerForContextMenu(findViewById(R.id.main_listview));
    if (MPDProfileManager.getInstance(this).getProfiles().size() == 0) {
        navId = R.id.nav_profiles;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getResources().getString(R.string.welcome_dialog_title));
        builder.setMessage(getResources().getString(R.string.welcome_dialog_text));
        builder.setPositiveButton(R.string.dialog_action_ok, (dialog, id) -> {
        });
        AlertDialog dialog = builder.create();
        dialog.show();
    }
    if (findViewById(R.id.fragment_container) != null) {
        if (savedInstanceState != null) {
            return;
        }
        Fragment fragment = null;
        if (navId == R.id.nav_library) {
            fragment = new MyMusicTabsFragment();
            MyMusicTabsFragment.DEFAULTTAB defaultTab = getDefaultTab();
            Bundle args = new Bundle();
            args.putInt(MyMusicTabsFragment.MY_MUSIC_REQUESTED_TAB, defaultTab.ordinal());
            fragment.setArguments(args);
        } else if (navId == R.id.nav_saved_playlists) {
            fragment = new SavedPlaylistsFragment();
        } else if (navId == R.id.nav_files) {
            fragment = new FilesFragment();
        } else if (navId == R.id.nav_profiles) {
            fragment = new ProfilesFragment();
        }
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment_container, fragment);
        transaction.commit();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NavigationView(android.support.design.widget.NavigationView) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) AlbumTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumTracksFragment) ArtworkSettingsFragment(org.gateshipone.malp.application.fragments.ArtworkSettingsFragment) ServerPropertiesFragment(org.gateshipone.malp.application.fragments.serverfragments.ServerPropertiesFragment) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) Fragment(android.support.v4.app.Fragment) ArtistsFragment(org.gateshipone.malp.application.fragments.serverfragments.ArtistsFragment) SettingsFragment(org.gateshipone.malp.application.fragments.SettingsFragment) InformationSettingsFragment(org.gateshipone.malp.application.fragments.InformationSettingsFragment) AlbumsFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumsFragment) SearchFragment(org.gateshipone.malp.application.fragments.serverfragments.SearchFragment) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) EditProfileFragment(org.gateshipone.malp.application.fragments.EditProfileFragment) PlaylistTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) AppBarLayout(android.support.design.widget.AppBarLayout) DrawerLayout(android.support.v4.widget.DrawerLayout) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment) Toolbar(android.support.v7.widget.Toolbar)

Example 85 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project androidApp by InspectorIncognito.

the class NavigationDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    currentDrawerPosition = getStartPosition();
    setContentView(R.layout.navigation_drawer);
    ViewStub stub = findViewById(R.id.layout_stub);
    stub.setLayoutResource(getLayoutResourceId());
    stub.inflate();
    drawerLayout = findViewById(R.id.drawer_layout);
    drawerToggle = new ActionBarDrawerToggle(// host Activity
    this, // DrawerLayout object
    drawerLayout, // "open drawer" description
    R.string.drawer_open, // "close drawer" description
    R.string.drawer_close) {

        public void onDrawerOpened(View drawerView) {
            checkIfSessionChanged();
            super.onDrawerOpened(drawerView);
        }
    };
    navigationView = findViewById(R.id.nav_view);
    if (!TranSappApplication.isDev()) {
        MenuItem item = navigationView.getMenu().findItem(R.id.navigation_item_dev_settings);
        item.setVisible(false);
    }
    assert navigationView != null;
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            menuItem.setChecked(true);
            switch(menuItem.getItemId()) {
                case R.id.navigation_item_account:
                    if (0 != currentDrawerPosition) {
                        openActivity(AccountActivity.class);
                    }
                    return true;
                case R.id.navigation_item_map:
                    if (1 != currentDrawerPosition) {
                        openActivity(MainActivity.class);
                    }
                    return true;
                case R.id.navigation_item_favourite:
                    openActivity(FavouriteActivity.class);
                    return true;
                case R.id.navigation_item_router:
                    openActivity(RouterActivity.class);
                    return true;
                case R.id.navigation_item_search:
                    openActivity(SearchActivity.class);
                    return true;
                case R.id.navigation_item_dev_settings:
                    openActivity(SettingsActivity.class);
                    return true;
                case R.id.navigation_item_onboarding:
                    openActivity(OnboardingActivity.class);
                    return true;
                case R.id.navigation_item_rate:
                    goToUrl("https://play.google.com/store/apps/details?id=cl.smartcities.isci.transportinspector&hl=es");
                    return true;
                default:
                    return true;
            }
        }
    });
    drawerLayout.addDrawerListener(drawerToggle);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    boolean isFirstTime = TranSappApplication.getAppSharedPreferences().getBoolean(getString(R.string.is_first_time), true);
    boolean isFirstTimeLogging = TranSappApplication.getAppSharedPreferences().getBoolean(getString(R.string.first_time_logging_in), true);
    if (isFirstTimeLogging) {
        TranSappApplication.getAppSharedPreferences().edit().putBoolean(getString(R.string.first_time_logging_in), false).apply();
        showLoginDialog();
    }
    if (isFirstTime) {
        TranSappApplication.getAppSharedPreferences().edit().putBoolean(getString(R.string.is_first_time), false).apply();
        if (!isFirstTimeLogging) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    }
    this.loggedIn = TranSappAccountManager.isLoggedIn();
    hideFeaturesIfNotDEV();
    handleLoginStatus();
}
Also used : NavigationView(android.support.design.widget.NavigationView) FavouriteActivity(cl.smartcities.isci.transportinspector.favourites.FavouriteActivity) OnboardingActivity(cl.smartcities.isci.transportinspector.onboarding.OnboardingActivity) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MenuItem(android.view.MenuItem) MainActivity(cl.smartcities.isci.transportinspector.MainActivity) SearchActivity(cl.smartcities.isci.transportinspector.search.SearchActivity) NavigationView(android.support.design.widget.NavigationView) AvatarView(agency.tango.android.avatarview.views.AvatarView) View(android.view.View) TextView(android.widget.TextView) ViewStub(android.view.ViewStub) AccountActivity(cl.smartcities.isci.transportinspector.gamification.ui.AccountActivity) RouterActivity(cl.smartcities.isci.transportinspector.router.RouterActivity) SettingsActivity(cl.smartcities.isci.transportinspector.preferences.SettingsActivity)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)218 View (android.view.View)153 NavigationView (android.support.design.widget.NavigationView)118 Toolbar (android.support.v7.widget.Toolbar)98 DrawerLayout (android.support.v4.widget.DrawerLayout)96 TextView (android.widget.TextView)85 AdapterView (android.widget.AdapterView)51 ImageView (android.widget.ImageView)48 ListView (android.widget.ListView)48 Intent (android.content.Intent)45 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)35 ActionBar (android.support.v7.app.ActionBar)31 SharedPreferences (android.content.SharedPreferences)30 RecyclerView (android.support.v7.widget.RecyclerView)23 Bundle (android.os.Bundle)20 FloatingActionButton (android.support.design.widget.FloatingActionButton)20 LinearLayout (android.widget.LinearLayout)19 MenuItem (android.view.MenuItem)17 BindView (butterknife.BindView)15 ArrayList (java.util.ArrayList)15