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:android.support.v7.internal.widget.ActionBarView.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int x = getPaddingLeft();
    final int y = getPaddingTop();
    final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();

    if (contentHeight <= 0) {
        // Nothing to do if we can't see anything.
        return;/*from   ww  w  .j  av a2 s.c o m*/
    }

    HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
    if (homeLayout.getVisibility() != GONE) {
        final int leftOffset = homeLayout.getLeftOffset();
        x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset;
    }

    if (mExpandedActionView == null) {
        final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE
                && (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
        if (showTitle) {
            x += positionChild(mTitleLayout, x, y, contentHeight);
        }

        switch (mNavigationMode) {
        case ActionBar.NAVIGATION_MODE_STANDARD:
            break;
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mListNavLayout != null) {
                if (showTitle) {
                    x += mItemPadding;
                }
                x += positionChild(mListNavLayout, x, y, contentHeight) + mItemPadding;
            }
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabScrollView != null) {
                if (showTitle) {
                    x += mItemPadding;
                }
                x += positionChild(mTabScrollView, x, y, contentHeight) + mItemPadding;
            }
            break;
        }
    }

    int menuLeft = r - l - getPaddingRight();
    if (mMenuView != null && mMenuView.getParent() == this) {
        positionChildInverse(mMenuView, menuLeft, y, contentHeight);
        menuLeft -= mMenuView.getMeasuredWidth();
    }

    if (mIndeterminateProgressView != null && mIndeterminateProgressView.getVisibility() != GONE) {
        positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight);
        menuLeft -= mIndeterminateProgressView.getMeasuredWidth();
    }

    View customView = null;
    if (mExpandedActionView != null) {
        customView = mExpandedActionView;
    } else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
        customView = mCustomNavView;
    }
    if (customView != null) {
        ViewGroup.LayoutParams lp = customView.getLayoutParams();
        final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ? (ActionBar.LayoutParams) lp
                : null;

        final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY;
        final int navWidth = customView.getMeasuredWidth();

        int topMargin = 0;
        int bottomMargin = 0;
        if (ablp != null) {
            x += ablp.leftMargin;
            menuLeft -= ablp.rightMargin;
            topMargin = ablp.topMargin;
            bottomMargin = ablp.bottomMargin;
        }

        int hgravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
        // See if we actually have room to truly center; if not push against left or right.
        if (hgravity == Gravity.CENTER_HORIZONTAL) {
            final int centeredLeft = (getWidth() - navWidth) / 2;
            if (centeredLeft < x) {
                hgravity = Gravity.LEFT;
            } else if (centeredLeft + navWidth > menuLeft) {
                hgravity = Gravity.RIGHT;
            }
        } else if (gravity == -1) {
            hgravity = Gravity.LEFT;
        }

        int xpos = 0;
        switch (hgravity) {
        case Gravity.CENTER_HORIZONTAL:
            xpos = (getWidth() - navWidth) / 2;
            break;
        case Gravity.LEFT:
            xpos = x;
            break;
        case Gravity.RIGHT:
            xpos = menuLeft - navWidth;
            break;
        }

        int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

        if (gravity == -1) {
            vgravity = Gravity.CENTER_VERTICAL;
        }

        int ypos = 0;
        switch (vgravity) {
        case Gravity.CENTER_VERTICAL:
            final int paddedTop = getPaddingTop();
            final int paddedBottom = getHeight() - getPaddingBottom();
            ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2;
            break;
        case Gravity.TOP:
            ypos = getPaddingTop() + topMargin;
            break;
        case Gravity.BOTTOM:
            ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight() - bottomMargin;
            break;
        }
        final int customWidth = customView.getMeasuredWidth();
        customView.layout(xpos, ypos, xpos + customWidth, ypos + customView.getMeasuredHeight());
        x += customWidth;
    }

    if (mProgressView != null) {
        mProgressView.bringToFront();
        final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2;
        mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
                mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight);
    }
}

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
        final View toOpen = findDrawerWithGravity(ss.openDrawerGravity);
        if (toOpen != null) {
            openDrawer(toOpen);/*w w  w.  jav  a 2 s . c  om*/
        }
    }
    setDrawerLockMode(ss.lockModeBottom, Gravity.BOTTOM);
}

From source file:com.juick.android.ThreadFragment.java

public void showThread(JuickMessage jmsg, boolean keepShow) {
    if (jmsg.getReplyTo() != 0) {
        JuickMessage reply = jmsg;//from  www  . java2 s . co  m
        LinearLayout ll = new LinearLayout(getActivity());
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        int totalCount = 0;
        while (reply != null) {
            totalCount += reply.Text.length();
            if (totalCount > 500 || ll.getChildCount() > 10)
                break;
            JuickMessagesAdapter.ParsedMessage parsedMessage = JuickMessagesAdapter
                    .formatMessageText(getActivity(), reply, true);
            TextView child = new TextView(getActivity());
            ll.addView(child, 0);
            child.setText(parsedMessage.textContent);
            if (reply.getReplyTo() < 1)
                break;
            reply = findReply(getListView(), reply.getReplyTo());
        }
        if (ll.getChildCount() != 0) {
            int xy[] = new int[2];
            getListView().getLocationOnScreen(xy);
            int windowHeight = getActivity().getWindow().getWindowManager().getDefaultDisplay().getHeight();
            int listBottom = getListView().getHeight() + xy[1];
            int bottomSize = windowHeight - listBottom;
            ll.setPressed(true);
            MainActivity.restyleChildrenOrWidget(ll);
            if (!keepShow || shownThreadToast.getView().getParent() == null) { // new or already hidden
                shownThreadToast = new Toast(getActivity());
                shownThreadToast.setView(ll);
                shownThreadToast.setGravity(Gravity.BOTTOM | Gravity.LEFT, 0, bottomSize);
                shownThreadToast.setDuration(Toast.LENGTH_LONG);
            }
            shownThreadToast.show();
        }
    }
}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Lay out a child view with respect to a keyline.
 *
 * <p>The keyline represents a horizontal offset from the unpadded starting edge of
 * the CoordinatorLayout. The child's gravity will affect how it is positioned with
 * respect to the keyline.</p>/* w w  w . ja  va  2s.  c  o m*/
 *
 * @param child child to lay out
 * @param keyline offset from the starting edge in pixels of the keyline to align with
 * @param layoutDirection ViewCompat constant for layout direction
 */
private void layoutChildWithKeyline(View child, int keyline, int layoutDirection) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    final int absGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(lp.gravity), layoutDirection);

    final int hgrav = absGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    final int vgrav = absGravity & Gravity.VERTICAL_GRAVITY_MASK;
    final int width = getWidth();
    final int height = getHeight();
    final int childWidth = child.getMeasuredWidth();
    final int childHeight = child.getMeasuredHeight();

    if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
        keyline = width - keyline;
    }

    int left = getKeyline(keyline) - childWidth;
    int top = 0;

    switch (hgrav) {
    default:
    case Gravity.LEFT:
        // Nothing to do.
        break;
    case Gravity.RIGHT:
        left += childWidth;
        break;
    case Gravity.CENTER_HORIZONTAL:
        left += childWidth / 2;
        break;
    }

    switch (vgrav) {
    default:
    case Gravity.TOP:
        // Do nothing, we're already in position.
        break;
    case Gravity.BOTTOM:
        top += childHeight;
        break;
    case Gravity.CENTER_VERTICAL:
        top += childHeight / 2;
        break;
    }

    // Obey margins and padding
    left = Math.max(getPaddingLeft() + lp.leftMargin,
            Math.min(left, width - getPaddingRight() - childWidth - lp.rightMargin));
    top = Math.max(getPaddingTop() + lp.topMargin,
            Math.min(top, height - getPaddingBottom() - childHeight - lp.bottomMargin));

    child.layout(left, top, left + childWidth, top + childHeight);
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

/**
 * Start transition to expand or collapse GuidedActionStylist.
 * @param avh When not null, the GuidedActionStylist expands the sub actions of avh.  When null
 * the GuidedActionStylist will collapse sub actions.
 *///from w  w  w .  j a v a2  s  . co  m
public void startExpandedTransition(ViewHolder avh) {
    ViewHolder focusAvh = null; // expand / collapse view holder
    final int count = mActionsGridView.getChildCount();
    for (int i = 0; i < count; i++) {
        ViewHolder vh = (ViewHolder) mActionsGridView.getChildViewHolder(mActionsGridView.getChildAt(i));
        if (avh == null && vh.itemView.getVisibility() == View.VISIBLE) {
            // going to collapse this one.
            focusAvh = vh;
            break;
        } else if (avh != null && vh.getAction() == avh.getAction()) {
            // going to expand this one.
            focusAvh = vh;
            break;
        }
    }
    if (focusAvh == null) {
        // huh?
        onUpdateExpandedViewHolder(avh);
        return;
    }
    boolean isSubActionTransition = focusAvh.getAction().hasSubActions();
    Object set = TransitionHelper.createTransitionSet(false);
    float slideDistance = isSubActionTransition ? focusAvh.itemView.getHeight()
            : focusAvh.itemView.getHeight() * 0.5f;
    Object slideAndFade = TransitionHelper.createFadeAndShortSlide(Gravity.TOP | Gravity.BOTTOM, slideDistance);
    Object changeFocusItemTransform = TransitionHelper.createChangeTransform();
    Object changeFocusItemBounds = TransitionHelper.createChangeBounds(false);
    Object fade = TransitionHelper.createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT);
    Object changeGridBounds = TransitionHelper.createChangeBounds(false);
    if (avh == null) {
        TransitionHelper.setStartDelay(slideAndFade, 150);
        TransitionHelper.setStartDelay(changeFocusItemTransform, 100);
        TransitionHelper.setStartDelay(changeFocusItemBounds, 100);
    } else {
        TransitionHelper.setStartDelay(fade, 100);
        TransitionHelper.setStartDelay(changeGridBounds, 100);
        TransitionHelper.setStartDelay(changeFocusItemTransform, 50);
        TransitionHelper.setStartDelay(changeFocusItemBounds, 50);
    }
    for (int i = 0; i < count; i++) {
        ViewHolder vh = (ViewHolder) mActionsGridView.getChildViewHolder(mActionsGridView.getChildAt(i));
        if (vh == focusAvh) {
            // going to expand/collapse this one.
            if (isSubActionTransition) {
                TransitionHelper.include(changeFocusItemTransform, vh.itemView);
                TransitionHelper.include(changeFocusItemBounds, vh.itemView);
            }
        } else {
            // going to slide this item to top / bottom.
            TransitionHelper.include(slideAndFade, vh.itemView);
            TransitionHelper.exclude(fade, vh.itemView, true);
        }
    }
    TransitionHelper.include(changeGridBounds, mSubActionsGridView);
    TransitionHelper.addTransition(set, slideAndFade);
    // note that we don't run ChangeBounds for activating view due to the rounding problem
    // of multiple level views ChangeBounds animation causing vertical jittering.
    if (isSubActionTransition) {
        TransitionHelper.addTransition(set, changeFocusItemTransform);
        TransitionHelper.addTransition(set, changeFocusItemBounds);
    }
    TransitionHelper.addTransition(set, fade);
    TransitionHelper.addTransition(set, changeGridBounds);
    mExpandTransition = set;
    TransitionHelper.addTransitionListener(mExpandTransition, new TransitionListener() {
        @Override
        public void onTransitionEnd(Object transition) {
            mExpandTransition = null;
        }
    });
    if (avh != null && mSubActionsGridView.getTop() != avh.itemView.getTop()) {
        // For expanding, set the initial position of subActionsGridView before running
        // a ChangeBounds on it.
        final ViewHolder toUpdate = avh;
        mSubActionsGridView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
                    int oldTop, int oldRight, int oldBottom) {
                if (mSubActionsGridView == null) {
                    return;
                }
                mSubActionsGridView.removeOnLayoutChangeListener(this);
                mMainView.post(new Runnable() {
                    public void run() {
                        if (mMainView == null) {
                            return;
                        }
                        TransitionHelper.beginDelayedTransition(mMainView, mExpandTransition);
                        onUpdateExpandedViewHolder(toUpdate);
                    }
                });
            }
        });
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mSubActionsGridView.getLayoutParams();
        lp.topMargin = avh.itemView.getTop();
        lp.height = 0;
        mSubActionsGridView.setLayoutParams(lp);
        return;
    }
    TransitionHelper.beginDelayedTransition(mMainView, mExpandTransition);
    onUpdateExpandedViewHolder(avh);
}

From source file:com.gome.ecmall.custom.VerticalViewPager.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // For simple implementation, or internal size is always 0.
    // We depend on the container to specify the layout size of
    // our view. We can't really know what it is since we will be
    // adding and removing different arbitrary views and do not
    // want the layout to change as this happens.
    setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));

    // final int measuredWidth = getMeasuredWidth();
    final int measuredHeight = getMeasuredHeight();
    final int maxGutterSize = measuredHeight / 10;
    mGutterSize = Math.min(maxGutterSize, mDefaultGutterSize);

    // Children are just made to fill our space.
    // int childWidthSize = measuredWidth - getPaddingLeft()
    // - getPaddingRight();
    // int childHeightSize = getMeasuredHeight() - getPaddingTop()
    // - getPaddingBottom();

    int childWidthSize = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
    int childHeightSize = measuredHeight - getPaddingTop() - getPaddingBottom();

    /*//w w w  .  j a v a2s.c om
     * Make sure all children have been properly measured. Decor views first. Right now we cheat and make this less
     * complicated by assuming decor views won't intersect. We will pin to edges based on gravity.
     */
    int size = getChildCount();
    for (int i = 0; i < size; ++i) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp != null && lp.isDecor) {
                final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
                final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
                int widthMode = MeasureSpec.AT_MOST;
                int heightMode = MeasureSpec.AT_MOST;
                boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM;
                boolean consumeHorizontal = hgrav == Gravity.LEFT || hgrav == Gravity.RIGHT;

                if (consumeVertical) {
                    widthMode = MeasureSpec.EXACTLY;
                } else if (consumeHorizontal) {
                    heightMode = MeasureSpec.EXACTLY;
                }

                int widthSize = childWidthSize;
                int heightSize = childHeightSize;
                if (lp.width != LayoutParams.WRAP_CONTENT) {
                    widthMode = MeasureSpec.EXACTLY;
                    if (lp.width != LayoutParams.MATCH_PARENT) {
                        widthSize = lp.width;
                    }
                }
                if (lp.height != LayoutParams.WRAP_CONTENT) {
                    heightMode = MeasureSpec.EXACTLY;
                    if (lp.height != LayoutParams.MATCH_PARENT) {
                        heightSize = lp.height;
                    }
                }
                final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);
                final int heightSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
                child.measure(widthSpec, heightSpec);

                if (consumeVertical) {
                    childHeightSize -= child.getMeasuredHeight();
                } else if (consumeHorizontal) {
                    childWidthSize -= child.getMeasuredWidth();
                }
            }
        }
    }

    mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
    mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY);

    // Make sure we have created all fragments that we need to have shown.
    mInLayout = true;
    populate();
    mInLayout = false;

    // Page views next.
    size = getChildCount();
    for (int i = 0; i < size; ++i) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            if (DEBUG)
                Log.v(TAG, "Measuring #" + i + " " + child + ": " + mChildWidthMeasureSpec);

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp == null || !lp.isDecor) {
                // final int widthSpec = MeasureSpec.makeMeasureSpec(
                // (int) (childWidthSize * lp.heightFactor),
                // MeasureSpec.EXACTLY);
                final int heightSpec = MeasureSpec.makeMeasureSpec((int) (childHeightSize * lp.heightFactor),
                        MeasureSpec.EXACTLY);
                child.measure(mChildWidthMeasureSpec, heightSpec);
            }
        }
    }
}

From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
        final View toOpen = findDrawerWithGravity(ss.openDrawerGravity);
        if (toOpen != null) {
            openDrawer(toOpen);/*from   w  w  w  .jav a 2  s  .c om*/
        }
    }

    setDrawerLockMode(ss.lockModeTop, Gravity.TOP);
    setDrawerLockMode(ss.lockModeBottom, Gravity.BOTTOM);
}

From source file:com.rbware.github.androidcouchpotato.widget.GuidedActionsStylist.java

/**
 * Start transition to expand or collapse GuidedActionStylist.
 * @param avh When not null, the GuidedActionStylist expands the sub actions of avh.  When null
 * the GuidedActionStylist will collapse sub actions.
 *///w  ww  .  j  av a 2 s  .com
public void startExpandedTransition(ViewHolder avh) {
    ViewHolder focusAvh = null; // expand / collapse view holder
    final int count = mActionsGridView.getChildCount();
    for (int i = 0; i < count; i++) {
        ViewHolder vh = (ViewHolder) mActionsGridView.getChildViewHolder(mActionsGridView.getChildAt(i));
        if (avh == null && vh.itemView.getVisibility() == View.VISIBLE) {
            // going to collapse this one.
            focusAvh = vh;
            break;
        } else if (avh != null && vh.getAction() == avh.getAction()) {
            // going to expand this one.
            focusAvh = vh;
            break;
        }
    }
    if (focusAvh == null) {
        // huh?
        onUpdateExpandedViewHolder(avh);
        return;
    }
    boolean isSubActionTransition = focusAvh.getAction().hasSubActions();
    Object set = TransitionHelper.createTransitionSet(false);
    float slideDistance = isSubActionTransition ? focusAvh.itemView.getHeight()
            : focusAvh.itemView.getHeight() * 0.5f;
    Object slideAndFade = TransitionHelper.createFadeAndShortSlide(Gravity.TOP | Gravity.BOTTOM, slideDistance);
    Object changeFocusItemTransform = TransitionHelper.createChangeTransform();
    Object changeFocusItemBounds = TransitionHelper.createChangeBounds(false);
    Object fade = TransitionHelper.createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT);
    Object changeGridBounds = TransitionHelper.createChangeBounds(false);
    if (avh == null) {
        TransitionHelper.setStartDelay(slideAndFade, 150);
        TransitionHelper.setStartDelay(changeFocusItemTransform, 100);
        TransitionHelper.setStartDelay(changeFocusItemBounds, 100);
    } else {
        TransitionHelper.setStartDelay(fade, 100);
        TransitionHelper.setStartDelay(changeGridBounds, 100);
        TransitionHelper.setStartDelay(changeFocusItemTransform, 50);
        TransitionHelper.setStartDelay(changeFocusItemBounds, 50);
    }
    for (int i = 0; i < count; i++) {
        ViewHolder vh = (ViewHolder) mActionsGridView.getChildViewHolder(mActionsGridView.getChildAt(i));
        if (vh == focusAvh) {
            // going to expand/collapse this one.
            if (isSubActionTransition) {
                TransitionHelper.include(changeFocusItemTransform, vh.itemView);
                TransitionHelper.include(changeFocusItemBounds, vh.itemView);
            }
        } else {
            // going to slide this item to top / bottom.
            TransitionHelper.include(slideAndFade, vh.itemView);
            TransitionHelper.exclude(fade, vh.itemView, true);
        }
    }
    TransitionHelper.include(changeGridBounds, mSubActionsGridView);
    TransitionHelper.include(changeGridBounds, mSubActionsBackground);
    TransitionHelper.addTransition(set, slideAndFade);
    // note that we don't run ChangeBounds for activating view due to the rounding problem
    // of multiple level views ChangeBounds animation causing vertical jittering.
    if (isSubActionTransition) {
        TransitionHelper.addTransition(set, changeFocusItemTransform);
        TransitionHelper.addTransition(set, changeFocusItemBounds);
    }
    TransitionHelper.addTransition(set, fade);
    TransitionHelper.addTransition(set, changeGridBounds);
    mExpandTransition = set;
    TransitionHelper.addTransitionListener(mExpandTransition, new TransitionListener() {
        @Override
        public void onTransitionEnd(Object transition) {
            mExpandTransition = null;
        }
    });
    if (avh != null && mSubActionsGridView.getTop() != avh.itemView.getTop()) {
        // For expanding, set the initial position of subActionsGridView before running
        // a ChangeBounds on it.
        final ViewHolder toUpdate = avh;
        mSubActionsGridView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
                    int oldTop, int oldRight, int oldBottom) {
                if (mSubActionsGridView == null) {
                    return;
                }
                mSubActionsGridView.removeOnLayoutChangeListener(this);
                mMainView.post(new Runnable() {
                    @Override
                    public void run() {
                        if (mMainView == null) {
                            return;
                        }
                        TransitionHelper.beginDelayedTransition(mMainView, mExpandTransition);
                        onUpdateExpandedViewHolder(toUpdate);
                    }
                });
            }
        });
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mSubActionsGridView.getLayoutParams();
        lp.topMargin = avh.itemView.getTop();
        lp.height = 0;
        mSubActionsGridView.setLayoutParams(lp);
        return;
    }
    TransitionHelper.beginDelayedTransition(mMainView, mExpandTransition);
    onUpdateExpandedViewHolder(avh);
}

From source file:com.dsdar.thosearoundme.TeamViewActivity.java

@Override
public boolean onMarkerClick(final Marker theMarker) {
    if (theMarker.equals(MyAppConstants.myMarker)) {
        return false;
    }/* w ww .  j a v  a 2 s  . com*/

    // Normal Marker
    if (!theMarker.equals(MyAppConstants.myMarker) && (theMarker.getTitle() != null)) {

        final Dialog aMemberDialog = new Dialog(TeamViewActivity.this, R.style.DialogSlideAnim);
        aMemberDialog.setContentView(R.layout.member_dialog);

        TextView aMemberTextName = (TextView) aMemberDialog.findViewById(R.id.tvMemberName);
        Button aTextButton = (Button) aMemberDialog.findViewById(R.id.bMemberText);
        Button aPushButton = (Button) aMemberDialog.findViewById(R.id.bMemberPush);
        Button aCallButton = (Button) aMemberDialog.findViewById(R.id.bMemberCall);
        Button aRemoveButton = (Button) aMemberDialog.findViewById(R.id.bMemberRemove);

        String[] res = theMarker.getTitle().split("~");
        String title = res[0];
        final String phone = res[1];

        aMemberTextName.setText("Say hello to " + title + "!");
        aMemberDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        aMemberDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        aMemberDialog.getWindow().setGravity(Gravity.BOTTOM);
        aMemberDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        aMemberDialog.show();
        ImageView aCancelButton = (ImageView) aMemberDialog.findViewById(R.id.bCancelMemberDialog);
        aCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                aMemberDialog.dismiss();
            }
        });

        aTextButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Uri sms_uri = Uri.parse("smsto:" + phone);
                Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri);
                startActivity(sms_intent);
            }
        });

        // aPushButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // // startActivity(new Intent(Intent.ACTION_VIEW,
        // // Uri.parse("sms:"
        // // + theMarker.getSnippet())));
        // }
        // });

        aCallButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent callIntent = new Intent(Intent.ACTION_DIAL);
                callIntent.setData(Uri.parse("tel:" + phone));
                startActivity(callIntent);
            }
        });

        // aRemoveButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // }
        // });
    } else {

        StickyMarkerBehaviorDialog dialog = new StickyMarkerBehaviorDialog(this);
        dialog.show();
    }

    return true;
}

From source file:com.edible.ocr.CaptureActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    switch (item.getItemId()) {

    case OPTIONS_COPY_RECOGNIZED_TEXT_ID:
        clipboardManager.setText(ocrResultView.getText());
        if (clipboardManager.hasText()) {
            Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.show();//from w  ww.  j  a  v  a2 s  .  c  om
        }
        return true;
    case OPTIONS_SHARE_RECOGNIZED_TEXT_ID:
        Intent shareRecognizedTextIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareRecognizedTextIntent.setType("text/plain");
        shareRecognizedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, ocrResultView.getText());
        startActivity(Intent.createChooser(shareRecognizedTextIntent, "Share via"));
        return true;
    case OPTIONS_COPY_TRANSLATED_TEXT_ID:
        clipboardManager.setText(translationView.getText());
        if (clipboardManager.hasText()) {
            Toast toast = Toast.makeText(this, "Text copied.", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.show();
        }
        return true;
    case OPTIONS_SHARE_TRANSLATED_TEXT_ID:
        Intent shareTranslatedTextIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareTranslatedTextIntent.setType("text/plain");
        shareTranslatedTextIntent.putExtra(android.content.Intent.EXTRA_TEXT, translationView.getText());
        startActivity(Intent.createChooser(shareTranslatedTextIntent, "Share via"));
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}