Search in sources :

Example 31 with ActionBarDrawerToggle

use of android.support.v7.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 32 with ActionBarDrawerToggle

use of android.support.v7.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 33 with ActionBarDrawerToggle

use of android.support.v7.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 34 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project RSAndroidApp by RailwayStations.

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);
    BaseApplication baseApplication = (BaseApplication) getApplication();
    dbAdapter = baseApplication.getDbAdapter();
    firstAppStart = baseApplication.getFirstAppStart();
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.fab_email)));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.fab_subject));
            startActivity(Intent.createChooser(emailIntent, getString(R.string.fab_chooser_title)));
        }
    });
    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.addDrawerListener(toggle);
    toggle.syncState();
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    handleGalleryNavItem();
    View header = navigationView.getHeaderView(0);
    TextView tvUpdate = (TextView) header.findViewById(R.id.tvUpdate);
    if (firstAppStart == false) {
        Intent introSliderIntent = new Intent(MainActivity.this, IntroSliderActivity.class);
        startActivity(introSliderIntent);
        finish();
    }
    try {
        lastUpdateDate = loadUpdateDateFromFile("updatedate.txt");
    } catch (Exception e) {
        Log.e(TAG, "Cannot load last update", e);
    }
    if (!lastUpdateDate.equals("")) {
        tvUpdate.setText("Letzte Aktualisierung am: " + lastUpdateDate);
    } else {
        disableNavItem();
        tvUpdate.setText(R.string.no_stations_in_database);
    }
    cursor = dbAdapter.getStationsList(false);
    customAdapter = new CustomAdapter(this, cursor, 0);
    ListView listView = (ListView) findViewById(R.id.lstStations);
    assert listView != null;
    listView.setAdapter(customAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
            Bahnhof bahnhof = dbAdapter.fetchBahnhofByRowId(id);
            Class cls = DetailsActivity.class;
            Intent intentDetails = new Intent(MainActivity.this, cls);
            intentDetails.putExtra(DetailsActivity.EXTRA_BAHNHOF, bahnhof);
            startActivity(intentDetails);
            finish();
        }
    });
    // Initialize FirebaseAuth
    mFirebaseAuth = FirebaseAuth.getInstance();
    Intent searchIntent = getIntent();
    if (Intent.ACTION_SEARCH.equals(searchIntent.getAction())) {
        String query = searchIntent.getStringExtra(SearchManager.QUERY);
        Toast.makeText(MainActivity.this, query, Toast.LENGTH_SHORT).show();
    }
    bindToStatus();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ParseException(java.text.ParseException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) CustomAdapter(de.bahnhoefe.deutschlands.bahnhofsfotos.db.CustomAdapter) ListView(android.widget.ListView) Bahnhof(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Bahnhof) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 35 with ActionBarDrawerToggle

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

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