use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project Carbon by ZieIony.
the class Toolbar method addCustomViewsWithGravity.
/**
* Prepare a list of non-SYSTEM child views. If the layout direction is RTL
* this will be in reverse child order.
*
* @param views List to populate. It will be cleared before use.
* @param gravity Horizontal gravity to match against
*/
private void addCustomViewsWithGravity(List<View> views, int gravity) {
final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
final int childCount = getChildCount();
final int absGrav = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
views.clear();
if (isRtl) {
for (int i = childCount - 1; i >= 0; i--) {
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (lp.mViewType == LayoutParams.CUSTOM && shouldLayout(child) && getChildHorizontalGravity(lp.gravity) == absGrav) {
views.add(child);
}
}
} else {
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (lp.mViewType == LayoutParams.CUSTOM && shouldLayout(child) && getChildHorizontalGravity(lp.gravity) == absGrav) {
views.add(child);
}
}
}
}
use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project actor-platform by actorapp.
the class StickersView method buildAdapter.
private void buildAdapter(Context context) {
GridLayoutManager layoutManager = new GridLayoutManager(context, Screen.getWidth() / Screen.dp(70));
setLayoutManager(layoutManager);
stickersAdapter = new StickersAdapter(keyboard, this);
setAdapter(stickersAdapter);
RecyclerView packSwitch = new RecyclerView(context);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, HORIZONTAL, false);
packSwitch.setLayoutManager(linearLayoutManager);
packSwitch.setItemAnimator(null);
packSwitch.setHasFixedSize(true);
PacksAdapter packsAdapter = new PacksAdapter(context, stickersAdapter, keyboard.getStickerIndicatorContainer());
packSwitch.setAdapter(packsAdapter);
stickersAdapter.setPacksAdapter(packsAdapter);
keyboard.getStickerIndicatorContainer().removeAllViews();
keyboard.getStickerIndicatorContainer().addView(packSwitch, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
}
use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.
the class ItemSlidingAnimator method slideInternalPreHoneycomb.
@SuppressLint("RtlHardcoded")
private static boolean slideInternalPreHoneycomb(RecyclerView.ViewHolder holder, boolean horizontal, int translationX, int translationY) {
if (!(holder instanceof SwipeableItemViewHolder)) {
return false;
}
final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder);
final ViewGroup.LayoutParams lp = containerView.getLayoutParams();
if (lp instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
mlp.leftMargin = translationX;
mlp.rightMargin = -translationX;
mlp.topMargin = translationY;
mlp.bottomMargin = -translationY;
if (lp instanceof FrameLayout.LayoutParams) {
((FrameLayout.LayoutParams) lp).gravity = Gravity.TOP | Gravity.LEFT;
}
containerView.setLayoutParams(mlp);
} else {
Log.w(TAG, "should use MarginLayoutParams supported view for compatibility on Android 2.3");
}
return false;
}
use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.
the class RecyclerViewSwipeManager method applySlideItem.
/*package*/
void applySlideItem(RecyclerView.ViewHolder holder, int itemPosition, float prevAmount, float amount, boolean proportionalAmount, boolean horizontal, boolean shouldAnimate, boolean isSwiping) {
final SwipeableItemViewHolder holder2 = (SwipeableItemViewHolder) holder;
final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder2);
if (containerView == null) {
return;
}
final int reqBackgroundType;
if (amount == 0.0f) {
if (prevAmount == 0.0f) {
reqBackgroundType = DRAWABLE_SWIPE_NEUTRAL_BACKGROUND;
} else {
reqBackgroundType = determineBackgroundType(prevAmount, horizontal);
}
} else {
reqBackgroundType = determineBackgroundType(amount, horizontal);
}
float adjustedAmount = amount;
if (amount != 0.0f) {
boolean isLimitProportional = holder2.isProportionalSwipeAmountModeEnabled();
float minLimit = horizontal ? holder2.getMaxLeftSwipeAmount() : holder2.getMaxUpSwipeAmount();
float maxLimit = horizontal ? holder2.getMaxRightSwipeAmount() : holder2.getMaxDownSwipeAmount();
minLimit = adaptAmount(holder2, horizontal, minLimit, isLimitProportional, proportionalAmount);
maxLimit = adaptAmount(holder2, horizontal, maxLimit, isLimitProportional, proportionalAmount);
adjustedAmount = Math.max(adjustedAmount, minLimit);
adjustedAmount = Math.min(adjustedAmount, maxLimit);
}
slideItem(holder, adjustedAmount, proportionalAmount, horizontal, shouldAnimate);
mWrapperAdapter.onUpdateSlideAmount(holder, itemPosition, amount, proportionalAmount, horizontal, isSwiping, reqBackgroundType);
}
use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.
the class RecyclerViewSwipeManager method handleActionUpOrCancelWhileSwiping.
private void handleActionUpOrCancelWhileSwiping(int action) {
int result = RESULT_CANCELED;
if (action == MotionEvent.ACTION_UP) {
final float swipeThresholdDistanceCoeff = 0.8f;
final float swipeThresholdVelocity = mMinFlingVelocity;
final boolean horizontal = mSwipeHorizontal;
final SwipeableItemViewHolder holder = (SwipeableItemViewHolder) mSwipingItem;
final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder);
final int containerSize = (horizontal) ? containerView.getWidth() : containerView.getHeight();
final float distance = (horizontal) ? (mLastTouchX - mInitialTouchX) : (mLastTouchY - mInitialTouchY);
final float absDistance = Math.abs(distance);
final boolean canSwipeNegativeDir = (horizontal) ? SwipeReactionUtils.canSwipeLeft(mSwipingItemReactionType) : SwipeReactionUtils.canSwipeUp(mSwipingItemReactionType);
final boolean canSwipePositiveDir = (horizontal) ? SwipeReactionUtils.canSwipeRight(mSwipingItemReactionType) : SwipeReactionUtils.canSwipeDown(mSwipingItemReactionType);
final boolean proportional = holder.isProportionalSwipeAmountModeEnabled();
float negativeDirLimit = (horizontal) ? holder.getMaxLeftSwipeAmount() : holder.getMaxUpSwipeAmount();
float positiveDirLimit = (horizontal) ? holder.getMaxRightSwipeAmount() : holder.getMaxDownSwipeAmount();
negativeDirLimit = adaptAmount(holder, horizontal, negativeDirLimit, proportional, false);
positiveDirLimit = adaptAmount(holder, horizontal, positiveDirLimit, proportional, false);
if (isSpecialSwipeAmountValue(negativeDirLimit)) {
negativeDirLimit = -containerSize;
}
if (isSpecialSwipeAmountValue(positiveDirLimit)) {
positiveDirLimit = containerSize;
}
// 1000: pixels per second
mVelocityTracker.computeCurrentVelocity(1000, mMaxFlingVelocity);
final float velocity = (horizontal) ? mVelocityTracker.getXVelocity() : mVelocityTracker.getYVelocity();
final float absVelocity = Math.abs(velocity);
boolean swiped = false;
boolean positiveDir = false;
if (absDistance > mSwipeThresholdDistance) {
if (absVelocity >= swipeThresholdVelocity) {
if ((velocity * distance) >= 0) {
swiped = true;
positiveDir = (velocity > 0);
}
} else if ((distance < 0) && (distance <= negativeDirLimit * swipeThresholdDistanceCoeff)) {
swiped = true;
positiveDir = false;
} else if ((distance > 0) && (distance >= positiveDirLimit * swipeThresholdDistanceCoeff)) {
swiped = true;
positiveDir = true;
}
}
if (swiped) {
if (!positiveDir && canSwipeNegativeDir) {
result = (horizontal) ? RESULT_SWIPED_LEFT : RESULT_SWIPED_UP;
} else if (positiveDir && canSwipePositiveDir) {
result = (horizontal) ? RESULT_SWIPED_RIGHT : RESULT_SWIPED_DOWN;
}
}
}
if (LOCAL_LOGD) {
Log.d(TAG, "swiping finished --- result = " + result);
}
finishSwiping(result);
}
Aggregations