Search in sources :

Example 1 with HORIZONTAL

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);
            }
        }
    }
}
Also used : CollapsibleActionView(android.support.v7.view.CollapsibleActionView) MenuView(android.support.v7.view.menu.MenuView) View(android.view.View) ImageView(carbon.widget.ImageView) TextView(carbon.widget.TextView) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 2 with HORIZONTAL

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);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 3 with HORIZONTAL

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;
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Example 4 with HORIZONTAL

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);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 5 with HORIZONTAL

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);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)33 View (android.view.View)31 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)6 TextView (android.widget.TextView)5 ImageView (android.widget.ImageView)4 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 LayoutParams (com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams)3 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1