Search in sources :

Example 41 with ActionBarDrawerToggle

use of android.support.v4.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 42 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project android_frameworks_base by AOSPA.

the class DrawerController method create.

/**
     * Returns a controller suitable for {@code Layout}.
     */
static DrawerController create(Activity activity) {
    DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    if (layout == null) {
        return new DummyDrawerController();
    }
    View drawer = activity.findViewById(R.id.drawer_roots);
    Toolbar toolbar = (Toolbar) activity.findViewById(R.id.roots_toolbar);
    drawer.getLayoutParams().width = calculateDrawerWidth(activity);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(activity, layout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close);
    return new RuntimeDrawerController(layout, drawer, toggle, toolbar);
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) View(android.view.View) Toolbar(android.widget.Toolbar)

Example 43 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project easy by MehdiBenmesa.

the class DrawerActivity method onStart.

@Override
protected void onStart() {
    super.onStart();
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
    mDrawer.setDrawerListener(mDrawerToggle);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setHomeButtonEnabled(true);
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ActionBar(android.support.v7.app.ActionBar)

Example 44 with ActionBarDrawerToggle

use of android.support.v4.app.ActionBarDrawerToggle in project YourAppIdea by Michenux.

the class NavigationDrawerFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Activity activity = getActivity();
    mDrawerLayoutView = (DrawerLayout) activity.findViewById(mNavConf.getDrawerLayoutViewId());
    mDrawerToggle = new ActionBarDrawerToggle(this.getActivity(), mDrawerLayoutView, (Toolbar) activity.findViewById(mNavConf.getToolbarId()), mNavConf.getDrawerOpenDesc(), mNavConf.getDrawerCloseDesc()) {

        public void onDrawerClosed(View view) {
            ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(mTitle);
            if (NavigationDrawerFragment.this.mSelectItemOnClosed != null) {
                NavigationDrawerFragment.this.deferedOnNavItemSelected();
            }
        }

        public void onDrawerOpened(View drawerView) {
            getActivity().setTitle(mDrawerTitle);
        }
    };
    mDrawerLayoutView.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    setTitle(mTitle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) AppCompatActivity(android.support.v7.app.AppCompatActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 45 with ActionBarDrawerToggle

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

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