Search in sources :

Example 6 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project Signal-Android by WhisperSystems.

the class RecyclerViewPositionHelper method findOneVisibleChild.

View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible, boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }
    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
Also used : OrientationHelper(android.support.v7.widget.OrientationHelper) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 7 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project material-dialogs by afollestad.

the class MaterialEditTextPreference method onBindDialogView.

@SuppressLint("MissingSuperCall")
@Override
protected void onBindDialogView(@NonNull View view) {
    EditText editText = this.editText;
    editText.setText(getText());
    // Initialize cursor to end of text
    if (editText.getText().length() > 0) {
        editText.setSelection(editText.length());
    }
    ViewParent oldParent = editText.getParent();
    if (oldParent != view) {
        if (oldParent != null) {
            ((ViewGroup) oldParent).removeView(editText);
        }
        onAddEditTextToDialogView(view, editText);
    }
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) EditText(android.widget.EditText) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) SuppressLint(android.annotation.SuppressLint)

Example 8 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project Carbon by ZieIony.

the class DefaultItemAnimator method endAnimation.

@Override
public void endAnimation(RecyclerView.ViewHolder item) {
    final View view = item.itemView;
    // TODO if some other animations are chained to end, how do we cancel them as well?
    for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
        MoveInfo moveInfo = mPendingMoves.get(i);
        if (moveInfo.holder == item) {
            ViewHelper.setTranslationY(view, 0);
            ViewHelper.setTranslationX(view, 0);
            dispatchMoveFinished(item);
            mPendingMoves.remove(i);
        }
    }
    endChangeAnimation(mPendingChanges, item);
    if (mPendingRemovals.remove(item)) {
        ViewHelper.setAlpha(view, 1);
        dispatchRemoveFinished(item);
    }
    if (mPendingAdditions.remove(item)) {
        ViewHelper.setAlpha(view, 1);
        dispatchAddFinished(item);
    }
    for (int i = mChangesList.size() - 1; i >= 0; i--) {
        ArrayList<ChangeInfo> changes = mChangesList.get(i);
        endChangeAnimation(changes, item);
        if (changes.isEmpty()) {
            mChangesList.remove(i);
        }
    }
    for (int i = mMovesList.size() - 1; i >= 0; i--) {
        ArrayList<MoveInfo> moves = mMovesList.get(i);
        for (int j = moves.size() - 1; j >= 0; j--) {
            MoveInfo moveInfo = moves.get(j);
            if (moveInfo.holder == item) {
                ViewHelper.setTranslationY(view, 0);
                ViewHelper.setTranslationX(view, 0);
                dispatchMoveFinished(item);
                moves.remove(j);
                if (moves.isEmpty()) {
                    mMovesList.remove(i);
                }
                break;
            }
        }
    }
    for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
        ArrayList<RecyclerView.ViewHolder> additions = mAdditionsList.get(i);
        if (additions.remove(item)) {
            ViewHelper.setAlpha(view, 1);
            dispatchAddFinished(item);
            if (additions.isEmpty()) {
                mAdditionsList.remove(i);
            }
        }
    }
    //noinspection PointlessBooleanExpression,ConstantConditions
    if (mRemoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
    }
    //noinspection PointlessBooleanExpression,ConstantConditions
    if (mAddAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
    }
    //noinspection PointlessBooleanExpression,ConstantConditions
    if (mChangeAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
    }
    //noinspection PointlessBooleanExpression,ConstantConditions
    if (mMoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
    }
    dispatchFinishedWhenDone();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 9 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project Carbon by ZieIony.

the class DefaultItemAnimator method animateMoveImpl.

private void animateMoveImpl(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ValueAnimator animation = ValueAnimator.ofFloat(0, 1);
    mMoveAnimations.add(holder);
    animation.setDuration(getMoveDuration());
    final float startX = ViewHelper.getTranslationX(view);
    final float startY = ViewHelper.getTranslationY(view);
    animation.addUpdateListener(__ -> {
        ViewHelper.setTranslationX(view, MathUtils.lerp(startX, 0, (Float) animation.getAnimatedValue()));
        ViewHelper.setTranslationY(view, MathUtils.lerp(startY, 0, (Float) animation.getAnimatedValue()));
    });
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            if (deltaX != 0) {
                ViewHelper.setTranslationX(view, 0);
            }
            if (deltaY != 0) {
                ViewHelper.setTranslationY(view, 0);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    });
    animation.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 10 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project SuperSLiM by TonicArtos.

the class LayoutManager method findAttachedHeaderForSectionFromEnd.

/**
     * The header is almost guaranteed to be at the end so just use look there.
     *
     * @param sfp Section identifier.
     * @return Header, or null if not found.
     */
private View findAttachedHeaderForSectionFromEnd(int sfp) {
    for (int i = getChildCount() - 1; i >= 0; i--) {
        View child = getChildAt(i);
        LayoutParams params = (LayoutParams) child.getLayoutParams();
        if (params.getTestedFirstPosition() != sfp) {
            break;
        } else if (params.isHeader) {
            return child;
        }
    }
    return null;
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

View (android.view.View)129 RecyclerView (android.support.v7.widget.RecyclerView)113 TextView (android.widget.TextView)35 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)25 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)19 SuppressLint (android.annotation.SuppressLint)15 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)13 DialogInterface (android.content.DialogInterface)12 PreferenceScreen (android.support.v7.preference.PreferenceScreen)11 Toolbar (android.support.v7.widget.Toolbar)11 AdapterView (android.widget.AdapterView)11 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)10 List (java.util.List)10 AlertDialog (android.support.v7.app.AlertDialog)9 Context (android.content.Context)8 ActionBar (android.support.v7.app.ActionBar)8 ListView (android.widget.ListView)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8