List of usage examples for android.view Gravity END
int END
To view the source code for android.view Gravity END.
Click Source Link
From source file:im.vector.adapters.VectorMessagesAdapter.java
/** * The user taps on the action icon.//from w w w.j a v a2s .c o m * @param event the selected event. * @param textMsg the event text * @param anchorView the popup anchor. */ @SuppressLint("NewApi") private void onMessageClick(final Event event, final String textMsg, final View anchorView) { final PopupMenu popup = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? new PopupMenu(mContext, anchorView, Gravity.END) : new PopupMenu(mContext, anchorView); popup.getMenuInflater().inflate(R.menu.vector_room_message_settings, popup.getMenu()); // force to display the icons try { Field[] fields = popup.getClass().getDeclaredFields(); for (Field field : fields) { if ("mPopup".equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(popup); Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); break; } } } catch (Exception e) { Log.e(LOG_TAG, "onMessageClick : force to display the icons failed " + e.getLocalizedMessage()); } Menu menu = popup.getMenu(); // hide entries for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(false); } menu.findItem(R.id.ic_action_view_source).setVisible(true); menu.findItem(R.id.ic_action_vector_permalink).setVisible(true); if (!TextUtils.isEmpty(textMsg)) { menu.findItem(R.id.ic_action_vector_copy).setVisible(true); menu.findItem(R.id.ic_action_vector_quote).setVisible(true); } if (event.isUploadingMedias(mMediasCache)) { menu.findItem(R.id.ic_action_vector_cancel_upload).setVisible(true); } if (event.isDownloadingMedias(mMediasCache)) { menu.findItem(R.id.ic_action_vector_cancel_download).setVisible(true); } if (event.canBeResent()) { menu.findItem(R.id.ic_action_vector_resend_message).setVisible(true); if (event.isUndeliverable()) { menu.findItem(R.id.ic_action_vector_redact_message).setVisible(true); } } else if (event.mSentState == Event.SentState.SENT) { // test if the event can be redacted boolean canBeRedacted = !mIsPreviewMode; if (canBeRedacted) { // oneself message -> can redact it if (TextUtils.equals(event.sender, mSession.getMyUserId())) { canBeRedacted = true; } else { // need the mininum power level to redact an event Room room = mSession.getDataHandler().getRoom(event.roomId); if ((null != room) && (null != room.getLiveState().getPowerLevels())) { PowerLevels powerLevels = room.getLiveState().getPowerLevels(); canBeRedacted = powerLevels.getUserPowerLevel(mSession.getMyUserId()) >= powerLevels.redact; } } } menu.findItem(R.id.ic_action_vector_redact_message).setVisible(canBeRedacted); if (Event.EVENT_TYPE_MESSAGE.equals(event.type)) { Message message = JsonUtils.toMessage(event.getContentAsJsonObject()); // share / forward the message menu.findItem(R.id.ic_action_vector_share).setVisible(true); menu.findItem(R.id.ic_action_vector_forward).setVisible(true); // save the media in the downloads directory if (Message.MSGTYPE_IMAGE.equals(message.msgtype) || Message.MSGTYPE_VIDEO.equals(message.msgtype) || Message.MSGTYPE_FILE.equals(message.msgtype)) { menu.findItem(R.id.ic_action_vector_save).setVisible(true); } // offer to report a message content menu.findItem(R.id.ic_action_vector_report) .setVisible(!mIsPreviewMode && !TextUtils.equals(event.sender, mSession.getMyUserId())); } } // display the menu popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { // warn the listener if (null != mVectorMessagesAdapterEventsListener) { mVectorMessagesAdapterEventsListener.onEventAction(event, textMsg, item.getItemId()); } // disable the selection mHighlightedEventId = null; notifyDataSetChanged(); return true; } }); popup.show(); }
From source file:com.ruesga.rview.SearchActivity.java
private void performShowOptions() { final ListPopupWindow popupWindow = new ListPopupWindow(this); ArrayList<String> values = new ArrayList<>( Arrays.asList(getResources().getStringArray(R.array.search_options_labels))); String value = values.get(mCurrentOption); SimpleDropDownAdapter adapter = new SimpleDropDownAdapter(this, values, mIcons, value); popupWindow.setAnchorView(mBinding.anchor); popupWindow.setDropDownGravity(Gravity.END); popupWindow.setAdapter(adapter);/*from ww w . j a v a 2 s . co m*/ popupWindow.setContentWidth(adapter.measureContentWidth()); popupWindow.setOnItemClickListener((parent, view, position, id) -> { popupWindow.dismiss(); mCurrentOption = position; Preferences.setAccountSearchMode(this, mAccount, mCurrentOption); configureSearchHint(); mBinding.searchView.setCustomIcon(ContextCompat.getDrawable(this, mIcons[position])); clearSuggestions(); mHandler.removeMessages(FETCH_SUGGESTIONS_MESSAGE); mHandler.removeMessages(SHOW_HISTORY_MESSAGE); final Message msg = Message.obtain(mHandler, SHOW_HISTORY_MESSAGE); mHandler.sendMessageDelayed(msg, 500L); }); popupWindow.setModal(true); popupWindow.show(); }
From source file:sharedcode.turboeditor.activity.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int i = item.getItemId(); if (mDrawerToggle.onOptionsItemSelected(item)) { Toast.makeText(getBaseContext(), "drawer click", Toast.LENGTH_SHORT).show(); mDrawerLayout.closeDrawer(Gravity.END); return true; } else if (i == R.id.im_save) { saveTheFile();/*from w w w . j a va 2 s .com*/ } else if (i == R.id.im_undo) { mEditor.onTextContextMenuItem(ID_UNDO); } else if (i == R.id.im_redo) { mEditor.onTextContextMenuItem(ID_REDO); } else if (i == R.id.im_search) { FindTextDialog.newInstance(mEditor.getText().toString()).show(getFragmentManager().beginTransaction(), "dialog"); } else if (i == R.id.im_cancel) { searchingText = false; invalidateOptionsMenu(); } else if (i == R.id.im_replace) { replaceText(); } else if (i == R.id.im_next_item) { nextResult(); } else if (i == R.id.im_previous_item) { previousResult(); } else if (i == R.id.im_goto_line) { int min = mEditor.getLineUtils().firstReadLine(); int max = mEditor.getLineUtils().lastReadLine(); NumberPickerDialog.newInstance(NumberPickerDialog.Actions.GoToLine, min, min, max) .show(getFragmentManager().beginTransaction(), "dialog"); } else if (i == R.id.im_view_it_on_browser) { Intent browserIntent; try { browserIntent = new Intent(Intent.ACTION_VIEW); browserIntent.setDataAndType(Uri.fromFile(new File(sFilePath)), "text/*"); startActivity(browserIntent); } catch (ActivityNotFoundException ex2) { // } } else if (i == R.id.im_info) { FileInfoDialog.newInstance(sFilePath).show(getFragmentManager().beginTransaction(), "dialog"); } else if (i == R.id.im_donate) { DialogHelper.showDonateDialog(this); } return super.onOptionsItemSelected(item); }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
private int getGravity(int gravity) { if (gravity == -1) return -1; int realGravityValue; switch (gravity) { case 0:/* w w w . j a v a 2 s . c o m*/ realGravityValue = Gravity.START; break; case 1: realGravityValue = Gravity.CENTER_HORIZONTAL; break; case 2: realGravityValue = Gravity.END; break; default: throw new IllegalArgumentException("Invalid value " + "specified for swipe_descriptionGravity. " + "Use \"left\", \"center\", \"right\" or leave " + "blank for default."); } return realGravityValue; }
From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java
private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) { holder.stationNameTextView.setText(busRoute.getId()); holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp); final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>(); final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData .getBusArrivalsMapped(busRoute.getId()); for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) { // Build data for button outside of the loop final String stopName = entry.getKey(); final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName); final Map<String, List<BusArrival>> value = entry.getValue(); for (final String key2 : value.keySet()) { final BusArrival busArrival = value.get(key2).get(0); final String boundTitle = busArrival.getRouteDirection(); final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum .fromString(boundTitle); final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId()) .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle) .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName()) .stopName(stopName).build(); busDetailsDTOs.add(busDetails); }// w w w .jav a 2 s . com boolean newLine = true; int i = 0; for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) { final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1); final LinearLayout container = new LinearLayout(context); container.setOrientation(LinearLayout.HORIZONTAL); container.setLayoutParams(containParams); // Left final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final RelativeLayout left = new RelativeLayout(context); left.setLayoutParams(leftParams); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId); destinationParams.setMargins(pixelsHalf, 0, 0, 0); final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase(); final String leftString = stopNameTrimmed + " " + bound; final SpannableString destinationSpannable = new SpannableString(leftString); destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(), leftString.length(), 0); // set size destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color final TextView boundCustomTextView = new TextView(context); boundCustomTextView.setText(destinationSpannable); boundCustomTextView.setSingleLine(true); boundCustomTextView.setLayoutParams(destinationParams); left.addView(lineIndication); left.addView(boundCustomTextView); // Right final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rightParams.setMargins(marginLeftPixel, 0, 0, 0); final LinearLayout right = new LinearLayout(context); right.setOrientation(LinearLayout.VERTICAL); right.setLayoutParams(rightParams); final List<BusArrival> buses = entry2.getValue(); final StringBuilder currentEtas = new StringBuilder(); for (final BusArrival arri : buses) { currentEtas.append(" ").append(arri.getTimeLeftDueDelay()); } final TextView arrivalText = new TextView(context); arrivalText.setText(currentEtas); arrivalText.setGravity(Gravity.END); arrivalText.setSingleLine(true); arrivalText.setTextColor(grey5); arrivalText.setEllipsize(TextUtils.TruncateAt.END); right.addView(arrivalText); container.addView(left); container.addView(right); holder.mainLayout.addView(container); newLine = false; i++; } } holder.mapButton.setText(activity.getString(R.string.favorites_view_buses)); holder.detailsButton .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs)); holder.mapButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else { final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound) .collect(Collectors.toSet()); final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class); final Bundle extras = new Bundle(); extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId()); extras.putStringArray(activity.getString(R.string.bundle_bus_bounds), bounds.toArray(new String[bounds.size()])); intent.putExtras(extras); activity.startActivity(intent); } }); }
From source file:com.avapira.bobroreader.Bober.java
private DrawerBuilder generateFeaturesDrawerBuilder(Bundle sIS) { return new DrawerBuilder().withDrawerGravity(Gravity.END).withActivity(this).withHeaderDivider(false) .withSelectedItem(-1).withFullscreen(false).withSavedInstance(sIS) .addDrawerItems(new PrimaryDrawerItem().withName("History").withIdentifier(0).withSelectable(false), new PrimaryDrawerItem().withName("Thread AutoHide").withIdentifier(1).withSelectable(false), new PrimaryDrawerItem().withName("Bookmarks").withIdentifier(2).withSelectable(false), new SettingsDrawerItem().withIdentifier(3).withSelectable(false)) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override//from w ww.j a v a 2s. c o m public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) { switch (iDrawerItem.getIdentifier()) { case 0: case 1: case 2: case 3: startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); } return false; } }); }
From source file:com.android.tv.ui.TvOverlayManager.java
/** * Shows setup dialog.//from www.j av a 2s . c o m */ public void showSetupFragment() { if (DEBUG) Log.d(TAG, "showSetupFragment"); mSetupFragmentActive = true; mSetupFragment.enableFragmentTransition( SetupFragment.FRAGMENT_ENTER_TRANSITION | SetupFragment.FRAGMENT_EXIT_TRANSITION | SetupFragment.FRAGMENT_RETURN_TRANSITION | SetupFragment.FRAGMENT_REENTER_TRANSITION); mSetupFragment.setFragmentTransition(SetupFragment.FRAGMENT_EXIT_TRANSITION, Gravity.END); showFragment(mSetupFragment); }
From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java
@Override public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { if (key.equals(TiC.PROPERTY_LEFT_VIEW)) { if (newValue == null || newValue == this.leftView) { return; }/*from w ww. ja va 2 s .c om*/ TiViewProxy newProxy = null; int index = 0; if (this.leftView != null) { index = this.leftFrame.indexOfChild(this.leftView.getOrCreateView().getNativeView()); } if (newValue instanceof TiViewProxy) { if (newValue instanceof WindowProxy) { throw new IllegalStateException("cannot add window as a child view of other window"); } newProxy = (TiViewProxy) newValue; initLeft(); this.leftFrame.addView(newProxy.getOrCreateView().getOuterView(), index); } else { Log.e(TAG, "invalid type for leftView"); } if (this.leftView != null) { this.leftFrame.removeView(this.leftView.getOrCreateView().getNativeView()); } this.leftView = newProxy; } else if (key.equals(TiC.PROPERTY_RIGHT_VIEW)) { if (newValue == null || newValue == this.rightView) { return; } TiViewProxy newProxy = null; int index = 0; if (this.rightView != null) { index = this.rightFrame.indexOfChild(this.rightView.getOrCreateView().getNativeView()); } if (newValue instanceof TiViewProxy) { if (newValue instanceof WindowProxy) { throw new IllegalStateException("cannot add window as a child view of other window"); } newProxy = (TiViewProxy) newValue; initRight(); this.rightFrame.addView(newProxy.getOrCreateView().getOuterView(), index); } else { Log.e(TAG, "invalid type for rightView"); } if (this.rightView != null) { this.rightFrame.removeView(this.rightView.getOrCreateView().getNativeView()); } this.rightView = newProxy; } else if (key.equals(TiC.PROPERTY_CENTER_VIEW)) { TiViewProxy newProxy = (TiViewProxy) newValue; setCenterView(newProxy); } else if (key.equals(TiC.PROPERTY_LEFT_WIDTH)) { if (leftFrame == null) { return; } initLeft(); if (newValue.equals(TiC.LAYOUT_SIZE)) { leftWidth = LayoutParams.WRAP_CONTENT; } else if (newValue.equals(TiC.LAYOUT_FILL)) { leftWidth = LayoutParams.MATCH_PARENT; } else if (!newValue.equals(TiC.SIZE_AUTO)) { leftWidth = getDevicePixels(newValue); } LayoutParams leftFrameLayout = new LayoutParams(leftWidth, LayoutParams.MATCH_PARENT); leftFrameLayout.gravity = Gravity.START; this.leftFrame.setLayoutParams(leftFrameLayout); } else if (key.equals(TiC.PROPERTY_RIGHT_WIDTH)) { if (rightFrame == null) { return; } initRight(); if (newValue.equals(TiC.LAYOUT_SIZE)) { rightWidth = LayoutParams.WRAP_CONTENT; } else if (newValue.equals(TiC.LAYOUT_FILL)) { rightWidth = LayoutParams.MATCH_PARENT; } else if (!newValue.equals(TiC.SIZE_AUTO)) { rightWidth = getDevicePixels(newValue); } LayoutParams rightFrameLayout = new LayoutParams(rightWidth, LayoutParams.MATCH_PARENT); rightFrameLayout.gravity = Gravity.END; this.rightFrame.setLayoutParams(rightFrameLayout); } else if (key.equals(TiC.PROPERTY_DRAWER_LOCK_MODE)) { layout.setDrawerLockMode(TiConvert.toInt(newValue)); } else if (key.equals(TiC.PROPERTY_DRAWER_INDICATOR_ENABLED)) { if (drawerToggle != null) { drawerToggle.setDrawerIndicatorEnabled((Boolean) newValue); } } else if (key.equals(TiC.PROPERTY_TOOLBAR_ENABLED)) { toolbarEnabled = TiConvert.toBoolean(newValue); setToolbarVisible(toolbarEnabled); } else if (key.equals(TiC.PROPERTY_DRAG_MARGIN)) { setDrawMargin(getDevicePixels(newValue)); } else { super.propertyChanged(key, oldValue, newValue, proxy); } }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
private void setupToolbar() { mToolbar = (Toolbar) findViewById(R.id.openhab_toolbar); setSupportActionBar(mToolbar);/*from w w w . j a v a 2 s .c om*/ if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } // ProgressBar layout params inside the toolbar have to be done programmatically // because it doesn't work through layout file :-( mProgressBar = (ProgressBar) mToolbar.findViewById(R.id.toolbar_progress_bar); mProgressBar.setLayoutParams(new Toolbar.LayoutParams(Gravity.END | Gravity.CENTER_VERTICAL)); setProgressIndicatorVisible(true); }
From source file:com.saphion.stencilweather.activities.MainActivity.java
private void showPopupMenu(View view) { // Create a PopupMenu, giving it the clicked view for an anchor PopupMenu popup = new PopupMenu(MainActivity.this, view, Gravity.END); // Inflate our menu resource into the PopupMenu's Menu popup.getMenuInflater().inflate(R.menu.navbar_actions, popup.getMenu()); // Set a listener so we are notified if a menu item is clicked popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//w w w .j a v a 2 s. c o m public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_about: // startActivity(new Intent(getBaseContext(), AboutClass.class)); // overridePendingTransition(R.anim.slide_in_left, // R.anim.slide_out_right); // finish(); return true; case R.id.action_morebydev: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=sachin+shinde"))); return true; case R.id.action_rate: Utils.launchMarket(getBaseContext(), getPackageName()); return true; case R.id.action_share: startActivity(Utils.createShareIntent(getBaseContext())); return true; } return false; } }); // Finally show the PopupMenu popup.show(); }