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;
}
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);
}
}
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();
}
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();
}
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;
}
Aggregations