Example usage for android.view View getRight

List of usage examples for android.view View getRight

Introduction

In this page you can find the example usage for android.view View getRight.

Prototype

@ViewDebug.CapturedViewProperty
public final int getRight() 

Source Link

Document

Right position of this view relative to its parent.

Usage

From source file:com.actionbarsherlock.internal.widget.IcsLinearLayout.java

void drawDividersHorizontal(Canvas canvas) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);

        if (child != null && child.getVisibility() != GONE) {
            if (hasDividerBeforeChildAt(i)) {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
                drawVerticalDivider(canvas, left);
            }//from www .  j a  v a 2 s  .  co  m
        }
    }

    if (hasDividerBeforeChildAt(count)) {
        final View child = getChildAt(count - 1);
        int right = 0;
        if (child == null) {
            right = getWidth() - getPaddingRight() - mDividerWidth;
        } else {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            right = child.getRight()/* + lp.rightMargin*/;
        }
        drawVerticalDivider(canvas, right);
    }
}

From source file:com.eccyan.widget.SpinningTabStrip.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current tab

    View currentTab = tabsContainer.getChildAt(getRealCurrentPosition());
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && getRealCurrentPosition() < realTabCount - 1) {

        View nextTab = tabsContainer.getChildAt(getRealCurrentPosition() + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }//w ww.j a v a  2  s.  c om
    return new Pair<Float, Float>(lineLeft, lineRight);
}

From source file:android.support.car.app.CarFragmentActivity.java

private static String viewToString(View view) {
    StringBuilder out = new StringBuilder(128);
    out.append(view.getClass().getName());
    out.append('{');
    out.append(Integer.toHexString(System.identityHashCode(view)));
    out.append(' ');
    switch (view.getVisibility()) {
    case View.VISIBLE:
        out.append('V');
        break;/*from w  ww.ja v  a2 s .  com*/
    case View.INVISIBLE:
        out.append('I');
        break;
    case View.GONE:
        out.append('G');
        break;
    default:
        out.append('.');
        break;
    }
    out.append(view.isFocusable() ? 'F' : '.');
    out.append(view.isEnabled() ? 'E' : '.');
    out.append(view.willNotDraw() ? '.' : 'D');
    out.append(view.isHorizontalScrollBarEnabled() ? 'H' : '.');
    out.append(view.isVerticalScrollBarEnabled() ? 'V' : '.');
    out.append(view.isClickable() ? 'C' : '.');
    out.append(view.isLongClickable() ? 'L' : '.');
    out.append(' ');
    out.append(view.isFocused() ? 'F' : '.');
    out.append(view.isSelected() ? 'S' : '.');
    out.append(view.isPressed() ? 'P' : '.');
    out.append(' ');
    out.append(view.getLeft());
    out.append(',');
    out.append(view.getTop());
    out.append('-');
    out.append(view.getRight());
    out.append(',');
    out.append(view.getBottom());
    final int id = view.getId();
    if (id != View.NO_ID) {
        out.append(" #");
        out.append(Integer.toHexString(id));
        final Resources r = view.getResources();
        if (id != 0 && r != null) {
            try {
                String pkgname;
                switch (id & 0xff000000) {
                case 0x7f000000:
                    pkgname = "app";
                    break;
                case 0x01000000:
                    pkgname = "android";
                    break;
                default:
                    pkgname = r.getResourcePackageName(id);
                    break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                out.append(" ");
                out.append(pkgname);
                out.append(":");
                out.append(typename);
                out.append("/");
                out.append(entryname);
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    out.append("}");
    return out.toString();
}

From source file:com.facebook.litho.MountState.java

private static void mountViewIncrementally(View view, Rect localVisibleRect) {
    assertMainThread();//from   w w w  .j  av  a 2  s.c o  m

    if (view instanceof LithoView) {
        final LithoView lithoView = (LithoView) view;
        lithoView.performIncrementalMount(localVisibleRect);
    } else if (view instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) view;

        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            final View childView = viewGroup.getChildAt(i);

            if (localVisibleRect.intersects(childView.getLeft(), childView.getTop(), childView.getRight(),
                    childView.getBottom())) {
                final Rect rect = ComponentsPools.acquireRect();
                rect.set(Math.max(0, localVisibleRect.left - childView.getLeft()),
                        Math.max(0, localVisibleRect.top - childView.getTop()),
                        childView.getWidth() - Math.max(0, childView.getRight() - localVisibleRect.right),
                        childView.getHeight() - Math.max(0, childView.getBottom() - localVisibleRect.bottom));

                mountViewIncrementally(childView, rect);

                ComponentsPools.release(rect);
            }
        }
    }
}

From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java

/**
 * This is the standard support library way of implementing "swipe to delete" feature. You can do custom drawing in onChildDraw method
 * but whatever you draw will disappear once the swipe is over, and while the items are animating to their new position the recycler view
 * background will be visible. That is rarely an desired effect.
 *///from   www .  j a v a2  s  . co m
private void setUpItemTouchHelper() {
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0,
            ItemTouchHelper.LEFT) {

        // we want to cache these and not allocate anything repeatedly in the onChildDraw method
        Drawable background;
        Drawable xMark;
        int xMarkMargin;
        boolean initiated;

        private void init() {
            background = new ColorDrawable(Color.DKGRAY);
            xMark = ContextCompat.getDrawable(TaskListActivity.this, R.drawable.ic_delete_white_24dp);
            xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
            xMarkMargin = (int) TaskListActivity.this.getResources().getDimension(R.dimen.fab_margin);
            initiated = true;
        }

        // not important, we don't want drag & drop
        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            int position = viewHolder.getAdapterPosition();
            TaskAdapter testAdapter = (TaskAdapter) recyclerView.getAdapter();
            if (testAdapter.isUndoOn() && testAdapter.isPendingRemoval(position)) {
                return 0;
            }
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            int swipedPosition = viewHolder.getAdapterPosition();
            TaskAdapter adapter = (TaskAdapter) mRecyclerView.getAdapter();
            boolean undoOn = adapter.isUndoOn();
            if (undoOn) {
                adapter.pendingRemoval(swipedPosition);
            } else {
                adapter.remove(swipedPosition);
            }
        }

        @Override
        public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                float dX, float dY, int actionState, boolean isCurrentlyActive) {

            View itemView = viewHolder.itemView;

            // not sure why, but this method get's called for viewholder that are already swiped away
            if (viewHolder.getAdapterPosition() == -1) {
                // not interested in those
                return;
            }

            if (!initiated) {
                init();
            }

            // draw background
            background.setBounds(itemView.getRight() + (int) dX, itemView.getTop(), itemView.getRight(),
                    itemView.getBottom());
            background.draw(canvas);

            // draw x mark
            int itemHeight = itemView.getBottom() - itemView.getTop();
            int intrinsicWidth = xMark.getIntrinsicWidth();
            int intrinsicHeight = xMark.getIntrinsicWidth();

            int xMarkLeft = itemView.getRight() - xMarkMargin - intrinsicWidth;
            int xMarkRight = itemView.getRight() - xMarkMargin;
            int xMarkTop = itemView.getTop() + (itemHeight - intrinsicHeight) / 2;
            int xMarkBottom = xMarkTop + intrinsicHeight;
            xMark.setBounds(xMarkLeft, xMarkTop, xMarkRight, xMarkBottom);

            xMark.draw(canvas);

            super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }

    };
    ItemTouchHelper mItemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    mItemTouchHelper.attachToRecyclerView(mRecyclerView);
}

From source file:com.andfchat.frontend.activities.ChatScreen.java

/**
 * Hides the soft keyboard if user is touching anywhere else.
 *//*from   w  ww. java 2 s  . c o  m*/
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    View view = getCurrentFocus();
    boolean ret = super.dispatchTouchEvent(event);

    if (view instanceof EditText) {
        View w = getCurrentFocus();
        int scrcoords[] = new int[2];
        w.getLocationOnScreen(scrcoords);
        float x = event.getRawX() + w.getLeft() - scrcoords[0];
        float y = event.getRawY() + w.getTop() - scrcoords[1];

        if (event.getAction() == MotionEvent.ACTION_UP
                && (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w.getBottom())) {
            inputFragment.hideKeyboard();
            inputFragment.saveEntry();
        }
    }

    return ret;
}

From source file:com.aretha.slidemenu.SlideMenu.java

protected final boolean canScroll(View v, int dx, int x, int y) {
    if (null == mScrollDetector) {
        return false;
    }//from   w  w w . j a  va  2  s . co m

    if (v instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();

        final int childCount = viewGroup.getChildCount();
        for (int index = 0; index < childCount; index++) {
            View child = viewGroup.getChildAt(index);
            final int left = child.getLeft();
            final int top = child.getTop();
            if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top
                    && y + scrollY < child.getBottom()
                    && (mScrollDetector.isScrollable(child, dx, x + scrollX - left, y + scrollY - top)
                            || canScroll(child, dx, x + scrollX - left, y + scrollY - top))) {
                return true;
            }
        }
    }

    return ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.hamzahrmalik.calculator2.Calculator.java

private void reveal(View sourceView, int colorRes, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);// w  w  w  .j  av  a 2 s  .  c  om

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mResultEditText.setText("");
    mFormulaEditText.setText("");
    mCurrentAnimator = animatorSet;
    animatorSet.start();

}

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 * or just its children (false).//from   w  w  w.  j  a  v  a2s . c  om
 * @param dx Delta scrolled in pixels
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.ebaonet.lawyer.ui.weight.DraggableGridViewPager.java

private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .8f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);/*from w  ww. j  av  a2 s. c  om*/
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}