Search in sources :

Example 46 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Rocket.Chat.Android by RocketChat.

the class MainActivity method setupSidebar.

private void setupSidebar() {
    SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
    if (pane == null) {
        return;
    }
    final SlidingPaneLayout subPane = (SlidingPaneLayout) findViewById(R.id.sub_sliding_pane);
    pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {

        @Override
        public void onPanelClosed(View panel) {
            super.onPanelClosed(panel);
            if (subPane != null) {
                subPane.closePane();
            }
        }
    });
    final DrawerArrowDrawable drawerArrowDrawable = new DrawerArrowDrawable(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
    toolbar.setNavigationIcon(drawerArrowDrawable);
    toolbar.setNavigationOnClickListener(view -> {
        if (pane.isSlideable() && !pane.isOpen()) {
            pane.openPane();
        }
    });
    //ref: ActionBarDrawerToggle#setProgress
    pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            drawerArrowDrawable.setProgress(slideOffset);
        }

        @Override
        public void onPanelOpened(View panel) {
            drawerArrowDrawable.setVerticalMirror(true);
        }

        @Override
        public void onPanelClosed(View panel) {
            drawerArrowDrawable.setVerticalMirror(false);
        }
    });
}
Also used : DrawerArrowDrawable(android.support.v7.graphics.drawable.DrawerArrowDrawable) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) View(android.view.View) RoomToolbar(chat.rocket.android.widget.RoomToolbar) Toolbar(android.support.v7.widget.Toolbar)

Example 47 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project NoteText by ViWu.

the class MainActivity method setUpDrawer.

public void setUpDrawer(Toolbar toolbar) {
    //set up drawer
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer != null) {
        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);
    assert navigationView != null;
    navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 48 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project wh-app-android by WhiteHouse.

the class MainActivity method createDrawerToggle.

private void createDrawerToggle() {
    mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, 0, 0) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mDrawerVisible = true;
            if (mDrawerLayoutCallbacks != null) {
                mDrawerLayoutCallbacks.onDrawerOpened();
            }
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            mDrawerVisible = false;
            if (mDrawerLayoutCallbacks != null) {
                mDrawerLayoutCallbacks.onDrawerClosed();
            }
        }
    };
    mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) SearchView(android.support.v7.widget.SearchView) InjectView(butterknife.InjectView) View(android.view.View) TextView(android.widget.TextView)

Example 49 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project Aegis by Decad3nce.

the class AegisActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final SharedPreferences preferences = getSharedPreferences(PREFERENCES_AEGIS, MODE_PRIVATE);
    mVersion = preferences.getString(PREFERENCES_AEGIS_VERSION, "35");
    FragmentManager fragmentManager = getFragmentManager();
    setContentView(R.layout.drawer_layout);
    final ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(true);
    bar.setHomeButtonEnabled(true);
    bar.setDisplayHomeAsUpEnabled(true);
    Fragment fragment = new SMSAlarmFragment();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
    mTitle = mDrawerTitle = getTitle();
    mMenuTitles = getMenuTitles();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
            ((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
            invalidateOptionsMenu();
            getActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle("Menu");
            ((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged();
            Utils.hideItem(R.id.alarm_menu_settings, thisMenu);
            Utils.hideItem(R.id.lock_menu_settings, thisMenu);
            Utils.hideItem(R.id.locate_menu_settings, thisMenu);
            Utils.hideItem(R.id.wipe_menu_settings, thisMenu);
            Utils.hideItem(R.id.data_menu_settings, thisMenu);
            Utils.showItem(R.id.action_help, thisMenu);
        }
    };
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    mDrawerList.setAdapter(new DrawerLayoutAdapter(this, R.layout.drawer_list_item, new ArrayList(Arrays.asList(mMenuTitles))));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    int versionCode = 0;
    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        versionCode = packageInfo.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
    //shwat
    }
    if (savedInstanceState == null) {
        if (versionCode > Integer.parseInt(mVersion)) {
            mVersion = String.valueOf(versionCode);
            WebView webView = new WebView(this);
            webView.loadUrl("file:///android_asset/changelog.html");
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setView(webView);
            dialog.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor editor = preferences.edit();
                    // value to store
                    editor.putString(PREFERENCES_AEGIS_VERSION, mVersion);
                    editor.commit();
                    dialog.dismiss();
                }
            });
            dialog.show();
        } else {
            selectItem(0);
        }
    } else {
        selectItem(mIndex);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) WebView(android.webkit.WebView) PackageManager(android.content.pm.PackageManager) WebView(android.webkit.WebView)

Example 50 with ActionBarDrawerToggle

use of android.support.v4.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)

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