Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

In this page you can find the example usage for android.view Gravity BOTTOM.

Prototype

int BOTTOM

To view the source code for android.view Gravity BOTTOM.

Click Source Link

Document

Push object to the bottom of its container, not changing its size.

Usage

From source file:ch.luklanis.esscan.history.HistoryActivity.java

private Uri createDTAFile(long bankProfileId) {
    List<HistoryItem> historyItems = mHistoryManager.buildHistoryItemsForDTA(bankProfileId);
    BankProfile bankProfile = mHistoryManager.getBankProfile(bankProfileId);

    String error = dtaFileCreator.getFirstError(bankProfile, historyItems);

    if (!TextUtils.isEmpty(error)) {
        setOkAlert(error);//from  w w w  .j  a  va2  s .com
        return null;
    }

    CharSequence dta = dtaFileCreator.buildDTA(bankProfile, historyItems);

    if (!dtaFileCreator.saveDTAFile(dta.toString())) {
        setOkAlert(R.string.msg_unmount_usb);
        return null;
    } else {
        Uri dtaFileUri = dtaFileCreator.getDTAFileUri();
        String dtaFileName = dtaFileUri.getLastPathSegment();

        new HistoryExportUpdateAsyncTask(mHistoryManager, dtaFileName)
                .execute(historyItems.toArray(new HistoryItem[historyItems.size()]));

        this.dtaFileCreator = new DTAFileCreator(getApplicationContext());

        Toast toast = Toast.makeText(this,
                getResources().getString(R.string.msg_dta_saved, dtaFileUri.getPath()), Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.show();

        return dtaFileUri;
    }
}

From source file:com.game.simple.Game3.java

private void createAd() {

    adView = new AdView(this);
    adView.setAdUnitId(AD_UNIT_ID);/* w  w  w.ja v  a2s.  co m*/
    adView.setAdSize(AdSize.BANNER);
    try {
        AdView.LayoutParams layoutParams = new AdView.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);

        RelativeLayout relativeLayout = new RelativeLayout(this);

        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);

        relativeLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

        adView.setLayoutParams(layoutParams);

        relativeLayout.addView(adView);

        addContentView(relativeLayout, rlp);

        AdRequest req = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("6BAC439445EBA320C6E42298650F159E").build();

        adView.loadAd(req);

        adView.setVisibility(View.INVISIBLE);

    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.goftagram.telegram.ui.Components.PasscodeView.java

public PasscodeView(final Context context) {
    super(context);

    setWillNotDraw(false);//from  ww w . j  a v  a 2 s .co m
    setVisibility(GONE);

    backgroundFrameLayout = new FrameLayout(context);
    addView(backgroundFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    backgroundFrameLayout.setLayoutParams(layoutParams);

    passwordFrameLayout = new FrameLayout(context);
    addView(passwordFrameLayout);
    layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    passwordFrameLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.drawable.passcode_logo);
    passwordFrameLayout.addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    if (AndroidUtilities.density < 1) {
        layoutParams.width = AndroidUtilities.dp(30);
        layoutParams.height = AndroidUtilities.dp(30);
    } else {
        layoutParams.width = AndroidUtilities.dp(40);
        layoutParams.height = AndroidUtilities.dp(40);
    }
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    layoutParams.bottomMargin = AndroidUtilities.dp(100);
    imageView.setLayoutParams(layoutParams);

    passcodeTextView = new TextView(context);
    passcodeTextView.setTextColor(0xffffffff);
    passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordFrameLayout.addView(passcodeTextView);
    layoutParams = (LayoutParams) passcodeTextView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(62);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passcodeTextView.setLayoutParams(layoutParams);

    passwordEditText2 = new AnimatingTextView(context);
    passwordFrameLayout.addView(passwordEditText2);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText2.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText2.setLayoutParams(layoutParams);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
    passwordEditText.setTextColor(0xffffffff);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setBackgroundDrawable(null);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    passwordFrameLayout.addView(passwordEditText);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText.setLayoutParams(layoutParams);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processDone(false);
                return true;
            }
            return false;
        }
    });
    passwordEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) {
                processDone(false);
            }
        }
    });
    if (android.os.Build.VERSION.SDK_INT < 11) {
        passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
            public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
                menu.clear();
            }
        });
    } else {
        passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
    }

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.passcode_check);
    checkImage.setScaleType(ImageView.ScaleType.CENTER);
    checkImage.setBackgroundResource(R.drawable.bar_selector_lock);
    passwordFrameLayout.addView(checkImage);
    layoutParams = (LayoutParams) checkImage.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(60);
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    layoutParams.rightMargin = AndroidUtilities.dp(10);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    checkImage.setLayoutParams(layoutParams);
    checkImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            processDone(false);
        }
    });

    FrameLayout lineFrameLayout = new FrameLayout(context);
    lineFrameLayout.setBackgroundColor(0x26ffffff);
    passwordFrameLayout.addView(lineFrameLayout);
    layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
    layoutParams.leftMargin = AndroidUtilities.dp(20);
    layoutParams.rightMargin = AndroidUtilities.dp(20);
    lineFrameLayout.setLayoutParams(layoutParams);

    numbersFrameLayout = new FrameLayout(context);
    addView(numbersFrameLayout);
    layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    numbersFrameLayout.setLayoutParams(layoutParams);

    lettersTextViews = new ArrayList<>(10);
    numberTextViews = new ArrayList<>(10);
    numberFrameLayouts = new ArrayList<>(10);
    for (int a = 0; a < 10; a++) {
        TextView textView = new TextView(context);
        textView.setTextColor(0xffffffff);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
        textView.setGravity(Gravity.CENTER);
        textView.setText(String.format(Locale.US, "%d", a));
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(50);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        numberTextViews.add(textView);

        textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
        textView.setTextColor(0x7fffffff);
        textView.setGravity(Gravity.CENTER);
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(20);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        switch (a) {
        case 0:
            textView.setText("+");
            break;
        case 2:
            textView.setText("ABC");
            break;
        case 3:
            textView.setText("DEF");
            break;
        case 4:
            textView.setText("GHI");
            break;
        case 5:
            textView.setText("JKL");
            break;
        case 6:
            textView.setText("MNO");
            break;
        case 7:
            textView.setText("PQRS");
            break;
        case 8:
            textView.setText("TUV");
            break;
        case 9:
            textView.setText("WXYZ");
            break;
        default:
            break;
        }
        lettersTextViews.add(textView);
    }
    eraseView = new ImageView(context);
    eraseView.setScaleType(ImageView.ScaleType.CENTER);
    eraseView.setImageResource(R.drawable.passcode_delete);
    numbersFrameLayout.addView(eraseView);
    layoutParams = (LayoutParams) eraseView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(50);
    layoutParams.height = AndroidUtilities.dp(50);
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    eraseView.setLayoutParams(layoutParams);
    for (int a = 0; a < 11; a++) {
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundResource(R.drawable.bar_selector_lock);
        frameLayout.setTag(a);
        if (a == 10) {
            frameLayout.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    passwordEditText.setText("");
                    passwordEditText2.eraseAllCharacters(true);
                    return true;
                }
            });
        }
        frameLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int tag = (Integer) v.getTag();
                switch (tag) {
                case 0:
                    passwordEditText2.appendCharacter("0");
                    break;
                case 1:
                    passwordEditText2.appendCharacter("1");
                    break;
                case 2:
                    passwordEditText2.appendCharacter("2");
                    break;
                case 3:
                    passwordEditText2.appendCharacter("3");
                    break;
                case 4:
                    passwordEditText2.appendCharacter("4");
                    break;
                case 5:
                    passwordEditText2.appendCharacter("5");
                    break;
                case 6:
                    passwordEditText2.appendCharacter("6");
                    break;
                case 7:
                    passwordEditText2.appendCharacter("7");
                    break;
                case 8:
                    passwordEditText2.appendCharacter("8");
                    break;
                case 9:
                    passwordEditText2.appendCharacter("9");
                    break;
                case 10:
                    passwordEditText2.eraseLastCharacter();
                    break;
                }
                if (passwordEditText2.lenght() == 4) {
                    processDone(false);
                }
            }
        });
        numberFrameLayouts.add(frameLayout);
    }
    for (int a = 10; a >= 0; a--) {
        FrameLayout frameLayout = numberFrameLayouts.get(a);
        numbersFrameLayout.addView(frameLayout);
        layoutParams = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(100);
        layoutParams.height = AndroidUtilities.dp(100);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        frameLayout.setLayoutParams(layoutParams);
    }
}

From source file:at.alladin.rmbt.android.map.RMBTMapFragment.java

private void showInfoToast() {
    final Map<String, String> currentMapOptionTitles = ((RMBTMainActivity) getActivity())
            .getCurrentMapOptionTitles();
    String infoString = "";
    for (final String s : currentMapOptionTitles.values()) {
        if (infoString.length() > 0)
            infoString += "\n";

        infoString += s;/*from   w ww .java 2s . com*/
    }
    if (infoString.length() > 0) {
        final Toast toast = Toast.makeText(getActivity(), infoString, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.BOTTOM, 0, 0);
        toast.show();
    }
}

From source file:com.hippo.drawerlayout.DrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;//w w w  .ja v a2 s .  c  o m
    final int width = r - l;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        int additionalTopMargin = 0;
        int additionalBottomMargin = 0;
        if (child instanceof DrawerLayoutChild) {
            DrawerLayoutChild dlc = (DrawerLayoutChild) child;
            additionalTopMargin = dlc.getAdditionalTopMargin();
            additionalBottomMargin = dlc.getAdditionalBottomMargin();
        }
        if (child == mContentView) {
            child.layout(lp.leftMargin, lp.topMargin + additionalTopMargin,
                    lp.leftMargin + child.getMeasuredWidth(),
                    lp.topMargin + additionalTopMargin + child.getMeasuredHeight());
        } else if (child == mShadow) {
            child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
        } else { // Drawer, if it wasn't onMeasure would have thrown an exception.
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childLeft;
            float percent;

            if (child == mLeftDrawer) {
                percent = mLeftPercent;
                childLeft = -childWidth + (int) (childWidth * percent);
            } else { // Right; onMeasure checked for us.
                percent = mRightPercent;
                childLeft = width - (int) (childWidth * percent);
            }

            final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;

            switch (vgrav) {
            default:
            case Gravity.TOP: {
                child.layout(childLeft, lp.topMargin + additionalTopMargin, childLeft + childWidth,
                        lp.topMargin + additionalTopMargin + childHeight);
                break;
            }

            case Gravity.BOTTOM: {
                final int height = b - t;
                child.layout(childLeft,
                        height - lp.bottomMargin - additionalBottomMargin - child.getMeasuredHeight(),
                        childLeft + childWidth, height - lp.bottomMargin - additionalBottomMargin);
                break;
            }

            case Gravity.CENTER_VERTICAL: {
                final int height = b - t;
                int childTop = (height - childHeight - additionalTopMargin - additionalBottomMargin
                        - lp.topMargin - lp.bottomMargin) / 2 + additionalTopMargin;
                // Offset for margins. If things don't fit right because of
                // bad measurement before, oh well.
                if (childTop < lp.topMargin + additionalTopMargin) {
                    childTop = lp.topMargin + additionalTopMargin;
                } else if (childTop + childHeight > height - additionalBottomMargin - lp.bottomMargin) {
                    childTop = height - additionalBottomMargin - lp.bottomMargin - childHeight;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                break;
            }
            }

            final int newVisibility = percent > 0 ? VISIBLE : INVISIBLE;
            if (child.getVisibility() != newVisibility) {
                child.setVisibility(newVisibility);
            }
        }
    }
    mInLayout = false;
}

From source file:com.google.android.apps.muzei.MuzeiActivity.java

private void setupArtDetailModeUi() {
    mChromeContainerView = findViewById(R.id.chrome_container);
    mStatusBarScrimView = findViewById(R.id.statusbar_scrim);

    mChromeContainerView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0xaa000000, 8, Gravity.BOTTOM));

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mStatusBarScrimView.setVisibility(View.GONE);
        mStatusBarScrimView = null;//from   w w  w . ja  va  2  s .  c  om
    } else {
        mStatusBarScrimView.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x44000000, 8, Gravity.TOP));
    }

    mMetadataView = findViewById(R.id.metadata);

    final float metadataSlideDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    mContainerView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int vis) {
            final boolean visible = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0;

            boolean showArtDetailChrome = (mUiMode == UI_MODE_ART_DETAIL);
            mChromeContainerView.setVisibility(showArtDetailChrome ? View.VISIBLE : View.GONE);
            mChromeContainerView.animate().alpha(visible ? 1f : 0f)
                    .translationY(visible ? 0 : metadataSlideDistance).setDuration(200)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            if (!visible) {
                                mChromeContainerView.setVisibility(View.GONE);
                            }
                        }
                    });

            if (mStatusBarScrimView != null) {
                mStatusBarScrimView.setVisibility(showArtDetailChrome ? View.VISIBLE : View.GONE);
                mStatusBarScrimView.animate().alpha(visible ? 1f : 0f).setDuration(200)
                        .withEndAction(new Runnable() {
                            @Override
                            public void run() {
                                if (!visible) {
                                    mStatusBarScrimView.setVisibility(View.GONE);
                                }
                            }
                        });
            }
        }
    });

    mTitleView = (TextView) findViewById(R.id.title);
    mBylineView = (TextView) findViewById(R.id.byline);
    mAttributionView = (TextView) findViewById(R.id.attribution);

    setupOverflowButton();

    mNextButton = findViewById(R.id.next_button);
    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mSourceManager.sendAction(MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK);
            mNextFakeLoading = true;
            showNextFakeLoading();
        }
    });
    CheatSheet.setup(mNextButton);

    mPanScaleProxyView = (PanScaleProxyView) findViewById(R.id.pan_scale_proxy);
    mPanScaleProxyView.setMaxZoom(5);
    mPanScaleProxyView.setOnViewportChangedListener(new PanScaleProxyView.OnViewportChangedListener() {
        @Override
        public void onViewportChanged() {
            if (mGuardViewportChangeListener) {
                return;
            }

            ArtDetailViewport.getInstance().setViewport(mCurrentViewportId,
                    mPanScaleProxyView.getCurrentViewport(), true);
        }
    });
    mPanScaleProxyView.setOnOtherGestureListener(new PanScaleProxyView.OnOtherGestureListener() {
        @Override
        public void onSingleTapUp() {
            if (mUiMode == UI_MODE_ART_DETAIL) {
                showHideChrome((mContainerView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0);
            }
        }
    });

    mLoadingContainerView = findViewById(R.id.image_loading_container);
    mLoadingIndicatorView = (AnimatedMuzeiLoadingSpinnerView) findViewById(R.id.image_loading_indicator);
    mLoadErrorContainerView = findViewById(R.id.image_error_container);
    mLoadErrorEasterEggView = findViewById(R.id.error_easter_egg);

    findViewById(R.id.image_error_retry_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showNextFakeLoading();
            startService(TaskQueueService.getDownloadCurrentArtworkIntent(MuzeiActivity.this));
        }
    });
}

From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    super.addView(child, index, params);

    if (!(child instanceof WearableDrawerView)) {
        return;//from   www .j  a v  a2 s .c o  m
    }

    WearableDrawerView drawerChild = (WearableDrawerView) child;
    drawerChild.setDrawerController(new WearableDrawerController(this, drawerChild));
    int childGravity = ((FrameLayout.LayoutParams) params).gravity;
    // Check for preferential gravity if no gravity is set in the layout.
    if (childGravity == Gravity.NO_GRAVITY || childGravity == GRAVITY_UNDEFINED) {
        ((FrameLayout.LayoutParams) params).gravity = drawerChild.preferGravity();
        childGravity = drawerChild.preferGravity();
        drawerChild.setLayoutParams(params);
    }
    WearableDrawerView drawerView;
    if (childGravity == Gravity.TOP) {
        mTopDrawerView = drawerChild;
        drawerView = mTopDrawerView;
    } else if (childGravity == Gravity.BOTTOM) {
        mBottomDrawerView = drawerChild;
        drawerView = mBottomDrawerView;
    } else {
        drawerView = null;
    }

    if (drawerView != null) {
        drawerView.addOnLayoutChangeListener(this);
    }
}

From source file:com.amazon.appstream.fireclient.FireClientActivity.java

@Override
public void onErrorMessage(final boolean fatal, final String message) {
    runOnUiThread(new Runnable() {
        @Override/*from www.  jav a  2  s . c om*/
        public void run() {
            if (mStopped) {
                Log.i(TAG, "Ignoring error during stopped state :" + (fatal ? "fatal" : "non fatal") + ":"
                        + message);
                return; // ignore errors if we're stopped.
            }
            if (fatal) {
                // Tell the app it needs to pause.
                AppStreamInterface.pause(true);
                ErrorDialogFragment dialog = new ErrorDialogFragment();
                dialog.setMessage(message);
                dialog.show(getSupportFragmentManager(), "ErrorDialogFragment");

                // And finally stop AppStream; kill the interfaces to give us a clean slate.
                stopAppStream();
            } else {
                if (mConnectDialog != null) {
                    openConnectDialog(message);
                } else {
                    Toast toast = Toast.makeText(FireClientActivity.this, message, Toast.LENGTH_LONG);
                    toast.setGravity(Gravity.RIGHT | Gravity.BOTTOM, 10, 10);
                    toast.show();
                }
            }
        }
    });
}

From source file:com.github.topbottomsnackbar.TBSnackbar.java

final void showView() {
    if (mView.getParent() == null) {
        final ViewGroup.LayoutParams lp = mView.getLayoutParams();

        if (lp instanceof CoordinatorLayout.LayoutParams && mStyle == STYLE_SHOW_BOTTOM) {
            // If our LayoutParams are from a CoordinatorLayout, we'll setup our Behavior
            final CoordinatorLayout.LayoutParams clp = (CoordinatorLayout.LayoutParams) lp;

            final Behavior behavior = new Behavior();
            behavior.setStartAlphaSwipeDistance(0.1f);
            behavior.setEndAlphaSwipeDistance(0.6f);
            behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
            behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
                @Override//w  w w .  jav  a2 s  .com
                public void onDismiss(View view) {
                    view.setVisibility(View.GONE);
                    dispatchDismiss(Callback.DISMISS_EVENT_SWIPE);
                }

                @Override
                public void onDragStateChanged(int state) {
                    switch (state) {
                    case SwipeDismissBehavior.STATE_DRAGGING:
                    case SwipeDismissBehavior.STATE_SETTLING:
                        // If the view is being dragged or settling, cancel the timeout
                        TBSnackbarManager.getInstance().cancelTimeout(mManagerCallback);
                        break;
                    case SwipeDismissBehavior.STATE_IDLE:
                        // If the view has been released and is idle, restore the timeout
                        TBSnackbarManager.getInstance().restoreTimeout(mManagerCallback);
                        break;
                    }
                }
            });
            clp.setBehavior(behavior);
            // Also set the inset edge so that views can dodge the snackbar correctly
            clp.insetEdge = Gravity.BOTTOM;
        }

        mTargetParent.addView(mView);
    }

    mView.setOnAttachStateChangeListener(new SnackbarLayout.OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            if (isShownOrQueued()) {
                // If we haven't already been dismissed then this event is coming from a
                // non-user initiated action. Hence we need to make sure that we callback
                // and keep our state up to date. We need to post the call since removeView()
                // will call through to onDetachedFromWindow and thus overflow.
                sHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        onViewHidden(Callback.DISMISS_EVENT_MANUAL);
                    }
                });
            }
        }
    });

    if (ViewCompat.isLaidOut(mView)) {
        if (shouldAnimate()) {
            // If animations are enabled, animate it in
            animateViewIn();
        } else {
            // Else if anims are disabled just call back now
            onViewShown();
        }
    } else {
        // Otherwise, add one of our layout change listeners and show it in when laid out
        mView.setOnLayoutChangeListener(new SnackbarLayout.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View view, int left, int top, int right, int bottom) {
                mView.setOnLayoutChangeListener(null);

                if (shouldAnimate()) {
                    // If animations are enabled, animate it in
                    animateViewIn();
                } else {
                    // Else if anims are disabled just call back now
                    onViewShown();
                }
            }
        });
    }
}

From source file:com.facebook.litho.widget.TextSpec.java

private static VerticalGravity getVerticalGravity(int gravity) {
    final VerticalGravity verticalGravity;
    switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.TOP:
        verticalGravity = TOP;/*from  www.j  a  va2 s.  c o  m*/
        break;
    case Gravity.CENTER_VERTICAL:
        verticalGravity = CENTER;
        break;
    case Gravity.BOTTOM:
        verticalGravity = BOTTOM;
        break;
    default:
        verticalGravity = TextSpec.verticalGravity;
        break;
    }
    return verticalGravity;
}