List of usage examples for android.view Gravity START
int START
To view the source code for android.view Gravity START.
Click Source Link
From source file:fr.outadev.twistoast.MainActivity.java
@Override public void onBackPressed() { if (frags[currentFragmentIndex] instanceof WebViewFragment && ((WebViewFragment) frags[currentFragmentIndex]).canGoBack()) { ((WebViewFragment) frags[currentFragmentIndex]).goBack(); } else if (currentFragmentIndex == 0) { super.onBackPressed(); } else if (!drawerLayout.isDrawerOpen(Gravity.START)) { drawerLayout.openDrawer(Gravity.START); } else {/* w w w. jav a 2 s . c om*/ loadFragmentFromDrawerPosition(0); } }
From source file:app.hanks.com.conquer.activity.MainActivity.java
/** * ?//from w w w .j a v a2s . c om */ private void initDrawerMenu() { drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);// drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerStateChanged(int arg0) { } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerOpened(View arg0) { // materialMenu.animatePressedState(MaterialMenuDrawable.IconState.X); } @Override public void onDrawerClosed(View arg0) { if (userDataFlag) { int[] location = new int[] { PixelUtil.dp2px(20), PixelUtil.dp2px(56) }; UserDataActivity.startUserProfileFromLocation(location, MainActivity.this); overridePendingTransition(0, 0); } userDataFlag = false; } }); // ?? menuFragment = new MenuFragment(); changeFramgnt(R.id.left_drawer, menuFragment); }
From source file:com.zzolta.android.gfrecipes.fragments.NavigationDrawerFragment.java
/** * 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. *//* w w w .j ava2s . co m*/ 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 this.drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); // set up the drawer's list view with items and click listener final 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. actionBarDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ NavigationDrawerFragment.this.drawerLayout, /* DrawerLayout object */ 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; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @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; final SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(getActivity()); sharedPreferences.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // 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() { actionBarDrawerToggle.syncState(); } }); this.drawerLayout.setDrawerListener(actionBarDrawerToggle); }
From source file:de.azapps.mirakel.new_ui.activities.MirakelActivity.java
@Override public boolean onPrepareOptionsMenu(final Menu menu) { if (mDrawerLayout.isPresent()) { // For phones final boolean drawerOpen = mDrawerLayout.get().isDrawerOpen(Gravity.START); if (drawerOpen) { // TODO list menu } else {// w w w . j a v a 2 s . com // TODO tasks menu } } else { // For Tablets } return super.onPrepareOptionsMenu(menu); }
From source file:com.android.fastinfusion.ui.fragment.NavigationDrawerFragment.java
/** * 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. *//* w w w . j av a 2 s.co m*/ public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.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. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* 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; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:com.github.pennyfive.cinemafinlando.ui.activity.generic.DrawerActivity.java
protected void closeDrawer() { drawer.closeDrawer(Gravity.START); }
From source file:com.poloure.simplerss.FragmentNavigationDrawer.java
void setUp(DrawerLayout drawerLayout) { final FeedsActivity activity = (FeedsActivity) getActivity(); // Set up the action bar. ActionBar actionBar = activity.getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); s_drawerToggle = new ActionBarDrawerToggle(getActivity(), drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override//from w w w . ja v a2 s . co m public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); activity.m_showMenuItems = 0.0F == slideOffset; activity.invalidateOptionsMenu(); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!m_userLearnedDrawer) { m_userLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).commit(); } } }; // Open the drawer if the user has never opened it manually before. if (!m_userLearnedDrawer) { drawerLayout.openDrawer(Gravity.START); } drawerLayout.post(new SyncPost()); drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); drawerLayout.setDrawerListener(s_drawerToggle); }
From source file:com.shahul3d.indiasatelliteweather.controllers.MainMapActivity.java
private void initDrawer() { final Context context = this; drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);// ww w. j av a2s .co m mDrawerLayout.setDrawerListener(drawerToggle); String[] values = new String[] { "Weather Maps", "Weather Animation", "Do you like this Work ?", "About" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values); mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mDrawerLayout.closeDrawer(Gravity.START); switch (position) { case 1: Toast.makeText(context, "Coming Soon..!", Toast.LENGTH_SHORT).show(); break; case 2: AppRater.setDontRemindButtonVisible(true); AppRater.showRateDialog(context); applicationContext.sendAnalyticsScreen(getString(R.string.rating_page)); break; case 3: new Libs.Builder().withFields(R.string.class.getFields()) .withActivityTitle(getString(R.string.about_heading)) .withLibraries("androidAnnotations").start(context); applicationContext.sendAnalyticsScreen(getString(R.string.about_page)); break; } } }); }
From source file:android.support.transition.SidePropagation.java
private int distance(View sceneRoot, int viewX, int viewY, int epicenterX, int epicenterY, int left, int top, int right, int bottom) { final int side; if (mSide == Gravity.START) { final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL; side = isRtl ? Gravity.RIGHT : Gravity.LEFT; } else if (mSide == Gravity.END) { final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL; side = isRtl ? Gravity.LEFT : Gravity.RIGHT; } else {/* w ww.j ava 2s .c o m*/ side = mSide; } int distance = 0; switch (side) { case Gravity.LEFT: distance = right - viewX + Math.abs(epicenterY - viewY); break; case Gravity.TOP: distance = bottom - viewY + Math.abs(epicenterX - viewX); break; case Gravity.RIGHT: distance = viewX - left + Math.abs(epicenterY - viewY); break; case Gravity.BOTTOM: distance = viewY - top + Math.abs(epicenterX - viewX); break; } return distance; }
From source file:com.mishiranu.dashchan.util.DrawerToggle.java
public boolean onOptionsItemSelected(MenuItem item) { if (item != null && item.getItemId() == android.R.id.home) { if (drawerLayout.getDrawerLockMode(Gravity.START) != DrawerLayout.LOCK_MODE_UNLOCKED) { return false; }//from www . ja v a 2 s . co m if (mode == MODE_DRAWER) { if (drawerLayout.isDrawerVisible(Gravity.START)) { drawerLayout.closeDrawer(Gravity.START); } else { drawerLayout.openDrawer(Gravity.START); } return true; } else if (mode == MODE_UP) { if (drawerLayout.isDrawerVisible(Gravity.START)) { drawerLayout.closeDrawer(Gravity.START); return true; } } } return false; }