Search in sources :

Example 96 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project PhotoNoter by yydcdut.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("");
    AppCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.ui_elevation));
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.setDrawerListener(toggle);
    toggle.syncState();
    mNavigationView.setNavigationItemSelectedListener(this);
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    PackageManager pm = getPackageManager();
    List<ResolveInfo> info = pm.queryIntentActivities(intent, 0);
    List<GalleryApp> galleryAppList = new ArrayList<>(info.size());
    for (int i = 0; i < info.size(); i++) {
        ActivityInfo activityInfo = info.get(i).activityInfo;
        galleryAppList.add(new GalleryApp(activityInfo.loadIcon(getPackageManager()), activityInfo.packageName, activityInfo.loadLabel(getPackageManager()) + ""));
    }
    for (int i = 0; i < mNavigationView.getChildCount(); i++) {
        View view = mNavigationView.getChildAt(i);
        if (view instanceof RecyclerView) {
            RecyclerView recyclerView = (RecyclerView) view;
            mNavigationAdapter = new NavigationAdapter(recyclerView.getAdapter(), galleryAppList, this);
            recyclerView.setAdapter(mNavigationAdapter);
        }
    }
    FragmentManager fragmentManager = getSupportFragmentManager();
    mMediaPhotoFragment = MediaPhotoFragment.newInstance();
    fragmentManager.beginTransaction().replace(R.id.layout_photo, mMediaPhotoFragment).commit();
}
Also used : NavigationAdapter(com.yydcdut.noteplugin.adapter.NavigationAdapter) ActivityInfo(android.content.pm.ActivityInfo) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) GalleryApp(com.yydcdut.noteplugin.bean.GalleryApp) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ResolveInfo(android.content.pm.ResolveInfo) FragmentManager(android.support.v4.app.FragmentManager) PackageManager(android.content.pm.PackageManager) RecyclerView(android.support.v7.widget.RecyclerView)

Example 97 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project LollipopDrawerToggle by 03lafaye.

the class ToolbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_toolbar);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close);
    toggle.setDrawerIndicatorEnabled(true);
    drawerLayout.setDrawerListener(toggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 98 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project android-bootstrap by AndroidBootstrap.

the class MainActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    BootstrapApplication.component().inject(this);
    if (isTablet()) {
        setContentView(R.layout.main_activity_tablet);
    } else {
        setContentView(R.layout.main_activity);
    }
    // View injection with Butterknife
    ButterKnife.bind(this);
    // Set up navigation drawer
    title = drawerTitle = getTitle();
    if (!isTablet()) {
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawerToggle = new ActionBarDrawerToggle(this, /* Host activity */
        drawerLayout, /* DrawerLayout object */
        R.string.navigation_drawer_open, /* "open drawer" description */
        R.string.navigation_drawer_close) {

            /* "close drawer" description */
            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                getSupportActionBar().setTitle(title);
                // creates call to onPrepareOptionsMenu()
                invalidateOptionsMenu();
                syncState();
            }

            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                getSupportActionBar().setTitle(drawerTitle);
                // creates call to onPrepareOptionsMenu()
                invalidateOptionsMenu();
                syncState();
            }
        };
        if (!isTablet()) {
            drawerToggle.syncState();
        }
        // Set the drawer toggle as the DrawerListener
        drawerLayout.setDrawerListener(drawerToggle);
        navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
        // Set up the drawer.
        navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    checkAuth();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View)

Example 99 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project android-bootstrap by AndroidBootstrap.

the class NavigationDrawerFragment method setUp.

/**
     * Users of this fragment must call this method to set up the navigation drawer interactions.
     *
     * @param fragmentId   The android:id of this fragment in its activity's layout.
     * @param drawerLayout The DrawerLayout containing this fragment's UI.
     */
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    fragmentContainerView = getActivity().findViewById(fragmentId);
    this.drawerLayout = drawerLayout;
    // set a custom shadow that overlays the main content when the drawer opens
    //drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    drawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
    NavigationDrawerFragment.this.drawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
    R.string.navigation_drawer_close) {

        /* "close drawer" description for accessibility */
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }
            // calls onPrepareOptionsMenu()
            getActivity().invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }
            if (!userLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                userLearnedDrawer = true;
                prefs.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }
            // calls onPrepareOptionsMenu()
            getActivity().invalidateOptionsMenu();
        }
    };
    // per the navigation drawer design guidelines.
    if (!userLearnedDrawer && !fromSavedInstanceState) {
        this.drawerLayout.openDrawer(fragmentContainerView);
    }
    // Defer code dependent on restoration of previous instance state.
    this.drawerLayout.post(new Runnable() {

        @Override
        public void run() {
            drawerToggle.syncState();
        }
    });
    this.drawerLayout.setDrawerListener(drawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ActionBar(android.support.v7.app.ActionBar)

Example 100 with ActionBarDrawerToggle

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

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(UserPreferences.getNoTitleTheme());
    super.onCreate(savedInstanceState);
    StorageUtils.checkStorageAvailability(this);
    setContentView(R.layout.main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        findViewById(R.id.shadow).setVisibility(View.GONE);
        int elevation = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        getSupportActionBar().setElevation(elevation);
    }
    currentTitle = getTitle();
    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);
    if (savedInstanceState != null) {
        int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0);
        drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0);
    }
    drawerLayout.setDrawerListener(drawerToggle);
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(() -> drawerToggle.setDrawerIndicatorEnabled(fm.getBackStackEntryCount() == 0));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    navAdapter = new NavListAdapter(itemAccess, this);
    navList.setAdapter(navAdapter);
    navList.setOnItemClickListener(navListClickListener);
    navList.setOnItemLongClickListener(newListLongClickListener);
    registerForContextMenu(navList);
    navAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            selectedNavListIndex = getSelectedNavListIndex();
        }
    });
    findViewById(R.id.nav_settings).setOnClickListener(v -> {
        drawerLayout.closeDrawer(navDrawer);
        startActivity(new Intent(MainActivity.this, PreferenceController.getPreferenceActivity()));
    });
    FragmentTransaction transaction = fm.beginTransaction();
    Fragment mainFragment = fm.findFragmentByTag("main");
    if (mainFragment != null) {
        transaction.replace(R.id.main_view, mainFragment);
    } else {
        String lastFragment = getLastNavFragment();
        if (ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
            loadFragment(lastFragment, null);
        } else {
            try {
                loadFeedFragmentById(Integer.parseInt(lastFragment), null);
            } catch (NumberFormatException e) {
                // it's not a number, this happens if we removed
                // a label from the NAV_DRAWER_TAGS
                // give them a nice default...
                loadFragment(QueueFragment.TAG, null);
            }
        }
    }
    externalPlayerFragment = new ExternalPlayerFragment();
    transaction.replace(R.id.playerFragment, externalPlayerFragment, ExternalPlayerFragment.TAG);
    transaction.commit();
    checkFirstLaunch();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) NavListAdapter(de.danoeh.antennapod.adapter.NavListAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ExternalPlayerFragment(de.danoeh.antennapod.fragment.ExternalPlayerFragment) Intent(android.content.Intent) DataSetObserver(android.database.DataSetObserver) QueueFragment(de.danoeh.antennapod.fragment.QueueFragment) Fragment(android.support.v4.app.Fragment) DownloadsFragment(de.danoeh.antennapod.fragment.DownloadsFragment) ItemlistFragment(de.danoeh.antennapod.fragment.ItemlistFragment) ExternalPlayerFragment(de.danoeh.antennapod.fragment.ExternalPlayerFragment) SubscriptionFragment(de.danoeh.antennapod.fragment.SubscriptionFragment) PlaybackHistoryFragment(de.danoeh.antennapod.fragment.PlaybackHistoryFragment) EpisodesFragment(de.danoeh.antennapod.fragment.EpisodesFragment) AddFeedFragment(de.danoeh.antennapod.fragment.AddFeedFragment)

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