androidx.drawerlayout.widget.DrawerLayout Java Examples
The following examples show how to use
androidx.drawerlayout.widget.DrawerLayout.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverScrollDemoActivity.java From overscroll-decor with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_overscroll_demo); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.recycler_view_demo_title); setSupportActionBar(toolbar); 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 = (NavigationView) findViewById(R.id.drawer_nav); navigationView.setNavigationItemSelectedListener(this); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.fragment_placeholder, new RecyclerViewDemoFragment()) .commit(); } }
Example #2
Source File: StatusBarUtil.java From AndroidAnimationExercise with Apache License 2.0 | 6 votes |
/** * 为 DrawerLayout 布局设置状态栏透明 * * @param activity 需要设置的activity * @param drawerLayout DrawerLayout */ public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); // 内容布局不是 LinearLayout 时,设置padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // 设置属性 ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); }
Example #3
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 6 votes |
/** * set up the drawer */ private void setupDrawer() { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerLayout.addDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); }
Example #4
Source File: Service.java From Twire with GNU General Public License v3.0 | 6 votes |
/** * Method for increasing a Navigation Drawer's edge size. */ public static void increaseNavigationDrawerEdge(DrawerLayout aDrawerLayout, Context context) { // Increase the area from which you can open the navigation drawer. try { Field mDragger = aDrawerLayout.getClass().getDeclaredField("mLeftDragger"); mDragger.setAccessible(true); ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(aDrawerLayout); Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize"); mEdgeSize.setAccessible(true); int edgeSize = mEdgeSize.getInt(draggerObj) * 3; mEdgeSize.setInt(draggerObj, edgeSize); //optimal value as for me, you may set any constant in dp } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: MainActivity.java From ssj with GNU General Public License v3.0 | 6 votes |
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); // if (itemId == R.id.action_graph) // { // Intent intent = new Intent(getApplicationContext(), GraphActivity.class); // startActivity(intent); // } // else if (itemId == R.id.action_train_model) { Intent intent = new Intent(getApplicationContext(), TrainActivity.class); startActivity(intent); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return false; }
Example #6
Source File: LockableDrawerLayout.java From revolution-irc with GNU General Public License v3.0 | 6 votes |
private void updateLockState() { if (isCurrentlyLocked()) { if (getDrawerLockMode(Gravity.START) == DrawerLayout.LOCK_MODE_LOCKED_OPEN) return; openDrawer(Gravity.START, false); setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, GravityCompat.START); setScrimColor(Color.TRANSPARENT); } else { if (getDrawerLockMode(Gravity.START) == DrawerLayout.LOCK_MODE_UNLOCKED) return; closeDrawer(Gravity.START, false); setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.START); setScrimColor(0x99000000); } requestLayout(); Iterator<WeakReference<LockableStateListener>> iterator = mLockableListener.iterator(); while (iterator.hasNext()) { LockableStateListener listener = iterator.next().get(); if (listener != null) listener.onLockableStateChanged(isCurrentlyLocked()); else iterator.remove(); } }
Example #7
Source File: MainActivity.java From VoIpUSSD with Apache License 2.0 | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); Fragment newFragment = null; String tittle = null; if (id == R.id.op1) { newFragment = new MainFragment(); tittle = getResources().getString(R.string.title_activity_cp1); } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); getSupportActionBar().setTitle(tittle); ft.replace(R.id.fragment_layout, newFragment); // f1_container is your FrameLayout container ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #8
Source File: MainActivity.java From ui with Apache License 2.0 | 6 votes |
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_support) { fragmentManager.beginTransaction().replace(R.id.container, new SupportDialogFragment()).commit(); } else if (id == R.id.nav_custom) { if (myCustomFragment == null) myCustomFragment = new CustomFragment(); fragmentManager.beginTransaction().replace(R.id.container, myCustomFragment).commit(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #9
Source File: DrawerLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Opens the drawer at the specified edge gravity. */ public static ViewAction openDrawer(final int drawerEdgeGravity) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(DrawerLayout.class); } @Override public String getDescription() { return "Opens the drawer"; } @Override public void perform(UiController uiController, View view) { uiController.loopMainThreadUntilIdle(); DrawerLayout drawerLayout = (DrawerLayout) view; drawerLayout.openDrawer(drawerEdgeGravity); // Wait for a full second to let the inner ViewDragHelper complete the operation uiController.loopMainThreadForAtLeast(1000); } }; }
Example #10
Source File: Service.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 6 votes |
/** * Method for increasing a Navigation Drawer's edge size. */ public static void increaseNavigationDrawerEdge(DrawerLayout aDrawerLayout, Context context) { // Increase the area from which you can open the navigation drawer. try { Field mDragger = aDrawerLayout.getClass().getDeclaredField("mLeftDragger"); mDragger.setAccessible(true); ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(aDrawerLayout); Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize"); mEdgeSize.setAccessible(true); int edgeSize = mEdgeSize.getInt(draggerObj) * 3; mEdgeSize.setInt(draggerObj, edgeSize); //optimal value as for me, you may set any constant in dp } catch (Exception e) { e.printStackTrace(); } }
Example #11
Source File: MainActivity.java From android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ButterKnife.bind(this); DrawerLayout drawer = 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); }
Example #12
Source File: MainActivity.java From busybox with GNU General Public License v2.0 | 6 votes |
@Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: Intent intentSettings = new Intent(this, SettingsActivity.class); startActivity(intentSettings); break; case R.id.action_help: new ExecScript(this, "info").start(); break; case R.id.action_zip: requestWritePermissions(); break; case R.id.action_about: Intent intentAbout = new Intent(this, AboutActivity.class); startActivity(intentAbout); break; } DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #13
Source File: ViewUtils.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 获取 View Layout Gravity * @param view {@link View} * @return Layout Gravity */ public static int getLayoutGravity(final View view) { if (view != null) { try { if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) { return ((LinearLayout.LayoutParams) view.getLayoutParams()).gravity; } else if (view.getLayoutParams() instanceof FrameLayout.LayoutParams) { return ((FrameLayout.LayoutParams) view.getLayoutParams()).gravity; } else if (view.getLayoutParams() instanceof ViewPager.LayoutParams) { return ((ViewPager.LayoutParams) view.getLayoutParams()).gravity; } else if (view.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) { return ((CoordinatorLayout.LayoutParams) view.getLayoutParams()).gravity; } else if (view.getLayoutParams() instanceof DrawerLayout.LayoutParams) { return ((DrawerLayout.LayoutParams) view.getLayoutParams()).gravity; } else { // 抛出不支持的类型 throw new Exception("layoutParams:" + view.getLayoutParams().toString()); } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getLayoutGravity"); } } return 0; }
Example #14
Source File: DrawerNavigationTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 6 votes |
@Before public void setUp() { when(mainActivity.findViewById(R.id.drawer_layout)).thenReturn(drawerLayout); fixture = new DrawerNavigation(mainActivity, toolbar) { @Override ActionBarDrawerToggle create( @NonNull MainActivity mainActivityInput, @NonNull Toolbar toolbarInput, @NonNull DrawerLayout drawerLayoutInput, int openDrawerContentDescRes, int closeDrawerContentDescRes) { Assert.assertEquals(mainActivity, mainActivityInput); Assert.assertEquals(toolbar, toolbarInput); Assert.assertEquals(drawerLayout, drawerLayoutInput); Assert.assertEquals(R.string.navigation_drawer_open, openDrawerContentDescRes); Assert.assertEquals(R.string.navigation_drawer_close, closeDrawerContentDescRes); return actionBarDrawerToggle; } }; }
Example #15
Source File: MainActivity.java From Easer with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); localeDelegate.onCreate(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = 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); if (savedInstanceState == null){ navigationView.setCheckedItem(R.id.nav_outline); Fragment fragment = new OutlineFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_main, fragment, FRAGMENT_OUTLINE) .commit(); } Info.INSTANCE.welcome(this); Version.INSTANCE.dataVersionChange(this); Version.INSTANCE.nearFutureChange(this); }
Example #16
Source File: MainActivity.java From Intra with Apache License 2.0 | 5 votes |
private View chooseView(int id) { View home = findViewById(R.id.frame_main); View settings = findViewById(R.id.settings); View info = findViewById(R.id.info_page); home.setVisibility(View.GONE); settings.setVisibility(View.GONE); info.setVisibility(View.GONE); View selected = findViewById(id); selected.setVisibility(View.VISIBLE); ActionBar actionBar = getSupportActionBar(); switch (id) { case R.id.frame_main: actionBar.setTitle(R.string.app_name); break; case R.id.settings: actionBar.setTitle(R.string.settings); showSettings(); break; } // Close the drawer DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.activity_main); drawerLayout.closeDrawer(GravityCompat.START); // Show an arrow on non-home screens. See https://stackoverflow.com/questions/27742074 if (id == R.id.frame_main) { drawerToggle.setDrawerIndicatorEnabled(true); } else { actionBar.setDisplayHomeAsUpEnabled(false); drawerToggle.setDrawerIndicatorEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); } return selected; }
Example #17
Source File: MainActivity.java From Daedalus with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { if (Daedalus.isDarkTheme()) { setTheme(R.style.AppTheme_Dark_NoActionBar_TransparentStatusBar); } super.onCreate(savedInstanceState); instance = this; setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); //setSupportActionBar(toolbar); //causes toolbar issues DrawerLayout drawer = findViewById(R.id.main_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); ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_version)).setText(getString(R.string.nav_version) + " " + BuildConfig.VERSION_NAME); ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_git_commit)).setText(getString(R.string.nav_git_commit) + " " + BuildConfig.GIT_COMMIT); updateUserInterface(getIntent()); }
Example #18
Source File: DrawerAccountsService.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
@NonNull private AccountIdentifier createMenuItem(OnAccountSwitchedFromNavListener list, Menu menu, Context context, int id, String email, String name, String rootFolder, String accountType, DrawerLayout layout) { final AccountIdentifier accountIdentifier = new AccountIdentifier(email, rootFolder); final MenuItem accountEntry = menu.add(R.id.drawer_accounts, id, Menu.NONE, name); setIcon(context, accountType, accountEntry); accountEntry.setOnMenuItemClickListener(new AccountSwichtedACL(nav, layout, context, name, accountIdentifier, list)); if (!"local".equals(email) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { accountEntry.setTooltipText(email); } return accountIdentifier; }
Example #19
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // inflate navigation drawer mNavigationDrawerItemTitles = getResources().getStringArray(R.array.basemap_types); mDrawerList = (ListView) findViewById(R.id.navList); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // get app title mActivityTitle = getTitle().toString(); addDrawerItems(); setupDrawer(); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // set opening basemap title to Topographic getSupportActionBar().setTitle(mNavigationDrawerItemTitles[2]); } // inflate MapView from layout mMapView = (MapView) findViewById(R.id.mapView); // create a map with Topographic Basemap mMap = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 47.6047381, -122.3334255, 12); // set the map to be displayed in this view mMapView.setMap(mMap); }
Example #20
Source File: MainActivity.java From ssj with GNU General Public License v3.0 | 5 votes |
/** * Close drawer if open otherwise go to app home screen. */ @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { moveTaskToBack(true); } }
Example #21
Source File: MenuHelper.java From webTube with GNU General Public License v3.0 | 5 votes |
public void setUpMenu(final ActionMenuView actionMenu, final DrawerLayout drawerLayout, final View bookmarksPanel) { this.drawerLayout = drawerLayout; this.bookmarksPanel = bookmarksPanel; this.actionMenu = actionMenu; actionMenu.setOnMenuItemClickListener(this); // Enable special buttons Menu menu = actionMenu.getMenu(); PackageManager pm = context.getPackageManager(); menu.findItem(R.id.action_backgroundPlay).setChecked(sp.getBoolean(BackgroundPlayHelper.PREF_BACKGROUND_PLAY_ENABLED, true)); menu.findItem(R.id.action_accept_cookies).setChecked(sp.getBoolean(PREF_COOKIES_ENABLED, true)); // Tor button if (OrbotHelper.isOrbotInstalled(context.getApplicationContext())) { menu.findItem(R.id.action_tor) .setEnabled(true) .setChecked(sp.getBoolean(TorHelper.PREF_TOR_ENABLED, false)); } // Add Kodi button try { pm.getPackageInfo("org.xbmc.kore", PackageManager.GET_ACTIVITIES); menu.findItem(R.id.action_cast_to_kodi).setEnabled(true); } catch (PackageManager.NameNotFoundException e) { /* Kodi is not installed */ } }
Example #22
Source File: DrawerMatchers.java From android-test with Apache License 2.0 | 5 votes |
/** * Returns a matcher that verifies that the drawer with the specified gravity is open. Matches * only when the drawer is fully open. Use {@link #isClosed(int)} instead of {@code not(isOpen())} * when you wish to check that the drawer is fully closed. */ public static Matcher<View> isOpen(final int gravity) { return new BoundedMatcher<View, DrawerLayout>(DrawerLayout.class) { @Override public void describeTo(Description description) { description.appendText("is drawer open"); } @Override public boolean matchesSafely(DrawerLayout drawer) { return drawer.isDrawerOpen(gravity); } }; }
Example #23
Source File: WebTubeChromeClient.java From webTube with GNU General Public License v3.0 | 5 votes |
public WebTubeChromeClient(WebView webView, ProgressBar progress, FrameLayout customViewContainer, DrawerLayout drawerLayout, View decorView) { this.webView = webView; this.progress = progress; this.customViewContainer = customViewContainer; this.drawerLayout = drawerLayout; this.decorView = decorView; }
Example #24
Source File: MainActivity.java From habpanelviewer with GNU General Public License v3.0 | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else if (mWebView.canGoBack()) { mWebView.goBack(); } else { super.onBackPressed(); } }
Example #25
Source File: BaseActivity.java From privacy-friendly-interval-timer with GNU General Public License v3.0 | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example #26
Source File: DrawerActivity.java From materialistic with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.activity_drawer); mDrawer = findViewById(R.id.drawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerAccount = (TextView) findViewById(R.id.drawer_account); mDrawerLogout = findViewById(R.id.drawer_logout); mDrawerUser = findViewById(R.id.drawer_user); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open_drawer, R.string.close_drawer) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (drawerView.equals(mDrawer) && mPendingNavigation != null) { final Intent intent = new Intent(DrawerActivity.this, mPendingNavigation); if (mPendingNavigationExtras != null) { intent.putExtras(mPendingNavigationExtras); mPendingNavigationExtras = null; } // TODO M bug https://code.google.com/p/android/issues/detail?id=193822 intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); mPendingNavigation = null; } } }; mDrawerLayout.addDrawerListener(mDrawerToggle); PreferenceManager.getDefaultSharedPreferences(this) .registerOnSharedPreferenceChangeListener(mLoginListener); setUpDrawer(); setUsername(); }
Example #27
Source File: MainChatActivity.java From twiliochat-android with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_chat); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); 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.setDrawerListener(toggle); toggle.syncState(); refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refreshLayout); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); chatFragment = new MainChatFragment(); fragmentTransaction.add(R.id.fragment_container, chatFragment); fragmentTransaction.commit(); context = this; mainActivity = this; logoutButton = (Button) findViewById(R.id.buttonLogout); addChannelButton = (Button) findViewById(R.id.buttonAddChannel); usernameTextView = (TextView) findViewById(R.id.textViewUsername); channelsListView = (ListView) findViewById(R.id.listViewChannels); channelManager = ChannelManager.getInstance(); setUsernameTextView(); setUpListeners(); checkTwilioClient(); }
Example #28
Source File: DriverHome.java From UberClone with MIT License | 5 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id){ case R.id.nav_trip_history: showTripHistory(); break; case R.id.nav_car_type: showDialogUpdateCarType(); break; case R.id.nav_update_info: showDialogUpdateInfo(); break; case R.id.nav_change_pwd: if(account!=null) showDialogChangePwd(); break; case R.id.nav_sign_out: signOut(); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #29
Source File: DriverHome.java From UberClone with MIT License | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example #30
Source File: MainActivity.java From TwistyTimer with GNU General Public License v3.0 | 5 votes |
@Override public void onDrawerStateChanged(int newState) { super.onDrawerStateChanged(newState); if (runnable != null && newState == DrawerLayout.STATE_IDLE) { runnable.run(); runnable = null; } }