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:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
/** * Called by Constructor to provide fragment transitions. The default implementation assigns * transitions based on {@link #getUiStyle()}: * <ul>/*from w w w .j a v a 2 s.c o m*/ * <li> {@link #UI_STYLE_REPLACE} Slide from/to end(right) for enter transition, slide from/to * start(left) for exit transition, shared element enter transition is set to ChangeBounds. * <li> {@link #UI_STYLE_ENTRANCE} Enter transition is set to slide from both sides, exit * transition is same as {@link #UI_STYLE_REPLACE}, no shared element enter transition. * <li> {@link #UI_STYLE_ACTIVITY_ROOT} Enter transition is set to null and app should rely on * activity transition, exit transition is same as {@link #UI_STYLE_REPLACE}, no shared element * enter transition. * </ul> * <p/> * The default implementation heavily relies on {@link GuidedActionsStylist} and * {@link GuidanceStylist} layout, app may override this method when modifying the default * layout of {@link GuidedActionsStylist} or {@link GuidanceStylist}. * <p/> * TIP: because the fragment view is removed during fragment transition, in general app cannot * use two Visibility transition together. Workaround is to create your own Visibility * transition that controls multiple animators (e.g. slide and fade animation in one Transition * class). */ protected void onProvideFragmentTransitions() { if (Build.VERSION.SDK_INT >= 21) { final int uiStyle = getUiStyle(); if (uiStyle == UI_STYLE_REPLACE) { Object enterTransition = TransitionHelper.createFadeAndShortSlide(Gravity.END); TransitionHelper.exclude(enterTransition, android.support.v17.leanback.R.id.guidedstep_background, true); TransitionHelper.exclude(enterTransition, android.support.v17.leanback.R.id.guidedactions_sub_list_background, true); TransitionHelper.setEnterTransition(this, enterTransition); Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedactions_sub_list_background); Object changeBounds = TransitionHelper.createChangeBounds(false); Object sharedElementTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(sharedElementTransition, fade); TransitionHelper.addTransition(sharedElementTransition, changeBounds); TransitionHelper.setSharedElementEnterTransition(this, sharedElementTransition); } else if (uiStyle == UI_STYLE_ENTRANCE) { if (entranceTransitionType == SLIDE_FROM_SIDE) { Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedstep_background); Object slideFromSide = TransitionHelper.createFadeAndShortSlide(Gravity.END | Gravity.START); //TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.content_fragment); TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.action_fragment_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, fade); TransitionHelper.addTransition(enterTransition, slideFromSide); TransitionHelper.setEnterTransition(this, enterTransition); } else { Object slideFromBottom = TransitionHelper.createFadeAndShortSlide(Gravity.BOTTOM); TransitionHelper.include(slideFromBottom, android.support.v17.leanback.R.id.guidedstep_background_view_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, slideFromBottom); TransitionHelper.setEnterTransition(this, enterTransition); } // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } else if (uiStyle == UI_STYLE_ACTIVITY_ROOT) { // for Activity root, we don't need enter transition, use activity transition TransitionHelper.setEnterTransition(this, null); // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } // exitTransition is same for all style Object exitTransition = TransitionHelper.createFadeAndShortSlide(Gravity.START); TransitionHelper.exclude(exitTransition, android.support.v17.leanback.R.id.guidedstep_background, true); TransitionHelper.exclude(exitTransition, android.support.v17.leanback.R.id.guidedactions_sub_list_background, true); TransitionHelper.setExitTransition(this, exitTransition); } }
From source file:org.chromium.chrome.browser.bookmarks.BookmarkManager.java
@Override public void closeDrawer() { if (!doesDrawerExist()) return; mDrawer.closeDrawer(Gravity.START); }
From source file:com.ffmpeger.card.ui.BaseNaviActivity.java
private void onNavDrawerItemClicked(final int itemId) { if (itemId == getSelfNavDrawerItem()) { mDrawerLayout.closeDrawer(Gravity.START); return;/* ww w. j a va 2 s . com*/ } if (isSpecialItem(itemId)) { goToNavDrawerItem(itemId); } else { // launch the target Activity after a short delay, to allow the close animation to play mHandler.postDelayed(new Runnable() { @Override public void run() { goToNavDrawerItem(itemId); } }, NAVDRAWER_LAUNCH_DELAY); // change the active item on the list so the user can see the item changed setSelectedNavDrawerItem(itemId); // fade out the main content View mainContent = findViewById(R.id.container); if (mainContent != null) { mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION); } } mDrawerLayout.closeDrawer(Gravity.START); }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
/** * Override methods / listeners/* w w w . j a v a2 s . c om*/ */ @Override public Object instantiateItem(ViewGroup container, int position) { SwipeItem slideItem = mItems.get(position); LinearLayout layout = null; switch (slideItem.iconGravity) { case CENTER: case DEFAULT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_item, null); break; case LEFT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_left_item, null); break; case RIGHT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_right_item, null); break; } // GET VIEW ImageView icon = (ImageView) layout.findViewById(R.id.swipeselector_content_icon); TextView title = (TextView) layout.findViewById(R.id.swipeselector_content_title); TextView description = (TextView) layout.findViewById(R.id.swipeselector_content_description); // SET VIEW title.setText(slideItem.title); if (slideItem.description == null) { description.setVisibility(View.GONE); } else { description.setVisibility(View.VISIBLE); description.setText(slideItem.description); } if (slideItem.icon == null) { icon.setVisibility(View.GONE); } else { icon.setImageDrawable(slideItem.icon); icon.setVisibility(View.VISIBLE); } // We shouldn't get here if the typeface didn't exist. // But just in case, because we're paranoid. if (mCustomTypeFace != null) { title.setTypeface(mCustomTypeFace); description.setTypeface(mCustomTypeFace); } if (mTitleTextAppearance != -1) { setTextAppearanceCompat(title, mTitleTextAppearance); } if (mDescriptionTextAppearance != -1) { setTextAppearanceCompat(description, mDescriptionTextAppearance); } switch (slideItem.titleGravity) { case DEFAULT: case CENTER: title.setGravity(Gravity.CENTER); break; case LEFT: title.setGravity(Gravity.START); break; case RIGHT: title.setGravity(Gravity.END); break; } switch (slideItem.descriptionGravity) { case DEFAULT: if (mDescriptionGravity != -1) { description.setGravity(mDescriptionGravity); } else { description.setGravity(Gravity.CENTER); } break; case CENTER: description.setGravity(Gravity.CENTER); break; case LEFT: description.setGravity(Gravity.START); break; case RIGHT: description.setGravity(Gravity.END); break; } layout.setPadding(mContentLeftPadding, mSweetSixteen, mContentRightPadding, mSweetSixteen); container.addView(layout); return layout; }
From source file:com.cyanogenmod.filemanager.ui.widgets.ActionBarDrawerToggle.java
/** * This method should be called by your <code>Activity</code>'s * {@link Activity#onOptionsItemSelected(android.view.MenuItem) * onOptionsItemSelected} method. If it returns true, your * <code>onOptionsItemSelected</code> method should return true and skip * further processing.//from www . j av a 2 s . c o m * * @param item * the MenuItem instance representing the selected menu item * @return true if the event was handled and further processing should not * occur */ public boolean onOptionsItemSelected(MenuItem item) { if (item != null && item.getItemId() == ID_HOME && mDrawerIndicatorEnabled) { if (mDrawerLayout.isDrawerVisible(Gravity.START)) { mDrawerLayout.closeDrawer(Gravity.START); } else { mDrawerLayout.openDrawer(Gravity.START); } return true; } return false; }
From source file:org.anurag.file.quest.FileQuestHD.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub int panel = pager.getCurrentItem(); switch (item.getItemId()) { case R.id.action_share: //sharing the item.... //if archive is opened then share operation is aborted if (RootPanel.isArchiveOpened() || SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.share_in_archive_err, Toast.LENGTH_SHORT).show(); break; }/*from w w w. j a v a2s .com*/ //sharing the item break; case R.id.action_queued: { //showing the list of queued task in popup window if (Constants.ACTION_AT_TOP) { mgr.showQueuedPopupWindow(top_toolbar, Gravity.START | Gravity.TOP); } else { mgr.showQueuedPopupWindow(top_toolbar, Gravity.START | Gravity.BOTTOM); } } break; case R.id.action_exit: FileQuestHD.this.finish(); return true; case android.R.id.home: //if(!Constants.LONG_CLICK) //drawer.openDrawer(Gravity.START); break; case R.id.action_setting: Intent intent = new Intent(FileQuestHD.this, Settings.class); startActivity(intent); break; case R.id.action_delete: switch (panel) { case 0: { ArrayList<Item> re_ls = FileGallery.get_selected_items(); if (!FileGallery.does_list_has_locked_item()) new DeleteFiles(FileQuestHD.this, re_ls, null); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.DELETE, re_ls); } break; case 1: //if archive is opened then delete is aborted if (RootPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.delete_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //first checking the locked status of files to be deleted.... { ArrayList<Item> re_ls = RootPanel.get_selected_items(); if (!RootPanel.does_list_has_locked_item()) new DeleteFiles(FileQuestHD.this, re_ls, null); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.DELETE, re_ls); } break; case 2: //if archive is opened then delete is aborted if (SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.delete_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //first checking the locked status of files to be deleted.... { ArrayList<Item> re_ls = SdCardPanel.get_selected_items(); if (!SdCardPanel.does_list_has_locked_item()) new DeleteFiles(FileQuestHD.this, re_ls, null); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.DELETE, re_ls); } } break; case R.id.action_add_gesture: //if archive is opened then adding gesture operation is aborted if (RootPanel.isArchiveOpened() || SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.gesture_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //adding gesture.... Intent intnt = new Intent(FileQuestHD.this, AddGesture.class); startActivity(intnt); break; case R.id.action_rename: //renaming the file... if (Constants.LONG_CLICK[panel]) switch (panel) { case 0: //first checking the locked status of files to be renamed.... { ArrayList<Item> re_ls = FileGallery.get_selected_items(); if (!FileGallery.does_list_has_locked_item()) new Rename(FileQuestHD.this, re_ls, panel); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.RENAME, null); } break; case 1: //if archive is opened then rename is aborted if (RootPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.rename_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //first checking the locked status of files to be renamed.... { ArrayList<Item> re_ls = RootPanel.get_selected_items(); if (!RootPanel.does_list_has_locked_item()) new Rename(FileQuestHD.this, re_ls, panel); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.RENAME, null); } break; case 2: //if archive is opened then rename is aborted if (SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.rename_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //first checking the locked status of files to be renamed.... { ArrayList<Item> re_ls = SdCardPanel.get_selected_items(); if (!SdCardPanel.does_list_has_locked_item()) new Rename(FileQuestHD.this, re_ls, panel); else new MasterPassword(FileQuestHD.this, null, prefs, Constants.MODES.RENAME, null); } break; } break; case R.id.action_gesture: //launching activity to recognize the gesture.... Intent innt = new Intent(FileQuestHD.this, G_Open.class); startActivityForResult(innt, 10); break; case R.id.action_zip: //if archive is opened then compress operation is aborted if (RootPanel.isArchiveOpened() || SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.zip_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //zipping the files... int id = mgr.COMPRESS_ID; if (Constants.LONG_CLICK[panel]) queueItems(panel, id); break; case R.id.action_properties: //showing properties of files.... { Intent itent = new Intent(FileQuestHD.this, FileProperties.class); startActivity(itent); } break; case R.id.action_copy: { //if archive is opened then copy operation is aborted //this restriction will be removed.... if (RootPanel.isArchiveOpened() || SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.cut_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //queues the files for copy int ID = mgr.COPY_ID; queueItems(panel, ID); } break; case R.id.action_cut: { //if archive is opened then cut operation is aborted if (RootPanel.isArchiveOpened() || SdCardPanel.isArchiveOpened()) { Toast.makeText(FileQuestHD.this, R.string.cut_in_archive_err, Toast.LENGTH_SHORT).show(); break; } //queues the files for cut int ID = mgr.CUT_ID; queueItems(panel, ID); } break; } return super.onOptionsItemSelected(item); }
From source file:org.fedoraproject.mobile.activities.NavigationDrawerActivity.java
private void selectItem(int position) { // update the main content by replacing fragments switch (position) { case Constants.FRAGMENT_MY_ACCOUNT: mPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override/* w w w. ja v a 2s. c om*/ public Fragment getItem(int position) { return MyAccountFragment.newInstance(); } @Override public int getCount() { return 1; } @Override public int getItemPosition(Object object) { return POSITION_NONE; } }); setTitle(R.string.drawer_my_account); break; case Constants.FRAGMENT_NEWSFEED: mPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { return NewsfeedFragment.newInstance(); } @Override public int getCount() { return 1; } @Override public int getItemPosition(Object object) { return POSITION_NONE; } }); setTitle(R.string.drawer_newsfeed); break; case Constants.FRAGMENT_INFRA_STATUS: mPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { return InfraStatusFragment.newInstance(); } @Override public int getCount() { return 1; } @Override public int getItemPosition(Object object) { return POSITION_NONE; } }); setTitle(R.string.drawer_infrastructure_status); break; case Constants.FRAGMENT_BADGES: mPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { int index = mAccountUtil.hasAccount() ? position : position + 1; switch (index) { case 0: return UserBadgesFragment.newInstance(mAccountUtil.getAccount().name); default: return BadgesLeaderboardFragment.newInstance(); } } @Override public int getCount() { return mAccountUtil.hasAccount() ? 2 : 1; } @Override public int getItemPosition(Object object) { return POSITION_NONE; } }); setTitle(R.string.drawer_badges); break; case Constants.FRAGMENT_PREFERENCES: default: mPager.setAdapter(null); Toast.makeText(this, R.string.error_not_implemented_yet, Toast.LENGTH_SHORT).show(); return; } mPager.setCurrentItem(0); mPager.getAdapter().notifyDataSetChanged(); // update selected item title, then close the drawer mDrawerLayout.closeDrawer(Gravity.START); }
From source file:com.cypress.cysmart.HomePageActivity.java
/** * Handling the back pressed actions/*from w w w. jav a 2 s .c o m*/ */ @Override public void onBackPressed() { // Getting the current active fragment Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container); // Profile scanning fragment active if (currentFragment instanceof ProfileScanningFragment) { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else { alertbox(); } } else if (currentFragment instanceof AboutFragment) { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else { if (BluetoothLeService.getConnectionState() == 2 || BluetoothLeService.getConnectionState() == 1 || BluetoothLeService.getConnectionState() == 4) { BluetoothLeService.disconnect(); Toast.makeText(this, getResources().getString(R.string.alert_message_bluetooth_disconnect), Toast.LENGTH_SHORT).show(); } // Guiding the user back to profile scanning fragment Intent intent = getIntent(); finish(); overridePendingTransition(R.anim.slide_left, R.anim.push_left); startActivity(intent); overridePendingTransition(R.anim.slide_right, R.anim.push_right); } } else if (currentFragment instanceof ProfileControlFragment) { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else { // Guiding the user back to profile scanning fragment // Logger.i("BLE DISCONNECT---->"+BluetoothLeService.getConnectionState()); if (BluetoothLeService.getConnectionState() == 2 || BluetoothLeService.getConnectionState() == 1 || BluetoothLeService.getConnectionState() == 4) { BluetoothLeService.disconnect(); Toast.makeText(this, getResources().getString(R.string.alert_message_bluetooth_disconnect), Toast.LENGTH_SHORT).show(); } Intent intent = getIntent(); finish(); overridePendingTransition(R.anim.slide_right, R.anim.push_right); startActivity(intent); overridePendingTransition(R.anim.slide_left, R.anim.push_left); super.onBackPressed(); } } else if (currentFragment instanceof GattDescriptorFragment) { CySmartApplication mApplication = (CySmartApplication) getApplication(); BluetoothGattDescriptor descriptor = mApplication.getBluetoothgattDescriptor(); if (descriptor != null) { BluetoothLeService.readDescriptor(descriptor); } super.onBackPressed(); } else if (currentFragment instanceof HeartRateService || currentFragment instanceof HealthTemperatureService || currentFragment instanceof DeviceInformationService || currentFragment instanceof BatteryInformationService || currentFragment instanceof BloodPressureService || currentFragment instanceof CapsenseService || currentFragment instanceof CSCService || currentFragment instanceof FindMeService || currentFragment instanceof GlucoseService || currentFragment instanceof RGBFragment || currentFragment instanceof RSCService || currentFragment instanceof SensorHubService || currentFragment instanceof RemoteControlEmulatorFragment || currentFragment instanceof GattServicesFragment) { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else { Utils.setUpActionBar(this, getResources().getString(R.string.profile_control_fragment)); super.onBackPressed(); } } else if (currentFragment instanceof OTAFirmwareUpgradeFragment) { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else if (OTAFirmwareUpgradeFragment.mFileupgradeStarted) { AlertDialog alert; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(this.getResources().getString(R.string.alert_message_ota_pending)) .setTitle(this.getResources().getString(R.string.app_name)).setCancelable(false) .setPositiveButton(this.getResources().getString(R.string.alert_message_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (BluetoothLeService.getConnectionState() == 2 || BluetoothLeService.getConnectionState() == 1 || BluetoothLeService.getConnectionState() == 4) { final BluetoothDevice device = BluetoothLeService.mBluetoothAdapter .getRemoteDevice( BluetoothLeService.getmBluetoothDeviceAddress()); OTAFirmwareUpgradeFragment.mFileupgradeStarted = false; unpairDevice(device); BluetoothLeService.disconnect(); Toast.makeText(HomePageActivity.this, getResources() .getString(R.string.alert_message_bluetooth_disconnect), Toast.LENGTH_SHORT).show(); Intent intent = getIntent(); finish(); overridePendingTransition(R.anim.slide_right, R.anim.push_right); startActivity(intent); overridePendingTransition(R.anim.slide_left, R.anim.push_left); } } }) .setNegativeButton(this.getResources().getString(R.string.alert_message_no), null); alert = builder.create(); alert.setCanceledOnTouchOutside(true); if (!this.isDestroyed()) alert.show(); } else { Utils.setUpActionBar(this, getResources().getString(R.string.profile_control_fragment)); super.onBackPressed(); } } else { if (parentView.isDrawerOpen(Gravity.START)) { parentView.closeDrawer(Gravity.START); } else { super.onBackPressed(); } } }
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Called when the FileChooser (or possibly other) Intent we launched sends back results. *//*www .ja va2 s . co m*/ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(LOG, "ReaderActivity.onActivityResult"); // If the user has changed orientation when away from this activity, the Drawer will be left opened. if (navigationDrawerLayout.isDrawerOpen(Gravity.START)) { navigationDrawerLayout.closeDrawer(Gravity.START); } // Load the Governor and panels from persistent state if needed. loadGovernorAndPanelsIfNeeded(false); doNotLoadGovernorThisTimeInOnResume = true; // If we have just returned from the FileChooserActivity. if (requestCode == ACTIVITY_RESULT_FILE_CHOOSER) { // Open the selected book in a given panel if all went well. if (resultCode == Activity.RESULT_OK) { Log.d(LOG, "ReaderActivity.Loading book to panel " + bookSelector); String path = data.getStringExtra(getString(R.string.bpath)); governor.getPanelHolder(bookSelector).openBook(path); Log.d(LOG, "ReaderActivity.Loaded book to panel " + bookSelector); } } }
From source file:com.jaredrummler.materialspinner.MaterialSpinner.java
/** * Show the dropdown menu//w w w . ja v a 2s . co m */ public void expand() { if (!hideArrow) { animateArrow(true); } nothingSelected = true; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { popupWindow.setOverlapAnchor(false); popupWindow.showAsDropDown(this); } else { int[] location = new int[2]; getLocationOnScreen(location); int x = location[0]; int y = getHeight() + location[1]; popupWindow.showAtLocation(this, Gravity.TOP | Gravity.START, x, y); } }