GithubHelp home page GithubHelp logo

carousellayoutmanager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carousellayoutmanager's Issues

Speed issue loading first time

Hello, thanks for share this repository. It is perfect drawing UI for my application.

The only issue I am facing of the speed of loading. It takes 3-4 seconds for first time loading whenever application moves carousel page. (Please note that Carousel loading static cards and images with in application)

Do you have any solution for this? Kindly add me on skype -- mobileapplication

Best,
Shani Shah

Opacity of next and previous item

Hi,

Thanks for the awesome library.

I've used it in my app and everything works great. However, i have a requirement to set the opacity level of next and previous item to as low as possible so that user's focus is mainly on center item.

Please help. Thanks in advance.

Regards
Sahmed

Question

There is a way to disable infinite scroll?

iOS version

It seems good on Android.
Is there any iOS version available to have similar behaviour?
I appreciate your help on it.

Thanks,
Mehul.

Disable Zooming effect while scrolling when Zooming is enabled

Im using the following line to enable the zoom effects , layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());. The problem with this , even when I am scrolling , every item is getting zoomed when it comes to center , which I feel is distracting the user. How to remove this effect while scrolling ?

Regards,
Sasank

Improvement: add support for not fixed item heights

Hello,

thanks for a great library! Do you have any thoughts on how to use it on not fixed item height? For instance I have an item view with multiple text views which are generated in the adapter based on adapter data. If item view is higher than the defined fixed height the item view is cut off at the bottom.

bug with width of layout element

Hi!

i used this library v1.1.9, and catch crash on rooted device nexus 5x with cyanogenmod and android 7.1.1.
bug is unboxing Integer mDecoratedChildWidth to int, when mDecoratedChildWidth == null
i looked v1.2.0, and this version is not fix this crash

info from fabric.io:

Device Nexus 5 CAF
ORIENTATION Portrait
PROXIMITY On

OS VERSION 7.1.1
UI ORIENTATION Portrait
ROOTED Yes

crash log:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.azoft.carousellayoutmanager.CarouselLayoutManager.getScrollItemSize(Unknown Source:590)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.scrollBy(Unknown Source:258)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.scrollHorizontallyBy(Unknown Source:233)
at android.support.v7.widget.RecyclerView.scrollByInternal(Unknown Source:1636)
at android.support.v7.widget.RecyclerView.onTouchEvent(Unknown Source:2759)
at android.view.View.dispatchTouchEvent(View.java:10024)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2626)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2307)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2632)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2321)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:413)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1808)
at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(Unknown Source:67)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:375)
at android.view.View.dispatchPointerEvent(View.java:10244)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4444)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4312)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3859)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3912)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3878)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4005)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3886)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4062)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3859)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3912)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3878)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3886)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3859)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6252)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6226)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6187)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6355)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(InputEventReceiver.java)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6326)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6378)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:615)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6126)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

How to set center item?

Is there any option/method to set center by manually(programatically)?

Please help?

Thanks in avdance.

Problems with proyect

Hello!

I want to use your carousel, but i cant do that. Have you any tutorial?

Thank you!

Patricio from Argentina.

Support onClick animaton to center an item

Hello,

Can I achieve a feature which is available on most of a carousel components implementation?
Right now if I click on an item which isn't centred (on the left or on the right) nothing happens.

What I have now is set onClickListner for each item in onBindViewHolder method.
I'd like to animate clicked item to a centre position somehow.

item z index not Observe

HORIZONTAL Recyclerview have 2 item and item place on each other
code :
layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener()); recyclerview_transfer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewsUtil.dpToPx(250))); recyclerview_transfer.setLayoutManager(layoutManager); recyclerview_transfer.setHasFixedSize(true); recyclerview_transfer.addOnScrollListener(new CenterScrollListener());

Carousel with live loading data

Excellent library and the idea. With your library, I would like to create the carousel with live load data, but I have a problem to insert data upward, notifiitemRangeInserted method does not work as it should work with usual adapter. There is a solution for this situation?

Thanks for help!)

LayoutManager is not recycling views.

The idea of the recycler is to reuse the views, and not actually inflate them again once they've been inflated (similar to the ViewHolder Pattern), but according to our logging, CarouselLayoutManager is not recycling the views.

In the adapter, we added two log calls:

  1. onCreateViewHolder ("onCreate called")
  2. onBindViewHolder ("onBind called at position %s")

Attached is our output of the logs:

com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 6
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 7
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 8
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 9
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 10
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 11
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 12
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 13
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 14
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 15
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 16
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 17
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 18
com.example.scroller D/ScrollAdapter: onCreate called
com.example.scroller D/ScrollAdapter: onBind called at position 19

No error, but nothing is shown (Inside Fragment)

I'm trying to use the vertical version with CardViews inside a fragment but nothing is showing, I have pasted the code as this is just for testing I'm ignoring data.

This is the fragment:

public class FavoritesFragment extends Fragment {

    private static final String TAG = "FavoritesFragment";

    private Context mContext;
    private RecyclerView mRecyclerView;
    private CarouselLayoutManager mCoverFlowLayoutManager;
    private FavoritesAdapter mFavoritesAdapter;

    private ArrayList<String> testData;


    public FavoritesFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View layout = inflater.inflate(R.layout.fragment_favorites, container, false);

        mContext = getContext();

        testData = new ArrayList<>();
        testData.add("0");
        testData.add("1");
        testData.add("2");
        testData.add("3");
        testData.add("4");

        initRecyclerView(layout, testData);

        return layout;
    }



    private void initRecyclerView(View layout, ArrayList<String> testData) {

        mCoverFlowLayoutManager = new CarouselLayoutManager(CarouselLayoutManager.VERTICAL, true);
        mCoverFlowLayoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

        mRecyclerView = (RecyclerView)layout.findViewById(R.id.recyclerViewFavorites);
        mRecyclerView.setLayoutManager(mCoverFlowManager);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setAdapter(new FavoritesAdapter(testData, mContext));
        mRecyclerView.addOnScrollListener(new CenterScrollListener());



    }
    private class FavoritesAdapter extends RecyclerView.Adapter<FavoritesAdapter.ViewHolder> {

        private List<String> data;
        private Context mContext;

        // ViewHolder to hold the card
        public class ViewHolder extends RecyclerView.ViewHolder {

            private View mContainer;
            private ImageView mItemImage;
            private TextView mDescription;
            private TextView mPrice;
            private TextView mShippingDate;

            public ViewHolder(View cardView) {
                super(cardView);

                mContainer = cardView.findViewById(R.id.card_container);
                mItemImage = (ImageView)cardView.findViewById(R.id.card_item_image);
                mDescription = (TextView)cardView.findViewById(R.id.card_description);
                mPrice = (TextView)cardView.findViewById(R.id.card_description);
                mShippingDate = (TextView)cardView.findViewById(R.id.card_shipping);
            }
        }

        public FavoritesAdapter(List<String> data, Context context) {
            mContext = context;
            this.data = data;
        }

        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(mContext).inflate(R.layout.card_layout, parent, false);

            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(ViewHolder holder, int position) {

        }

        @Override
        public int getItemCount() {
            return data.size();
        }


    }

}

fragment_favorites.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.panasonixx.asosplus.FavoritesFragment">

    <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerViewFavorites"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerInParent="true" />

</FrameLayout>

card_layout.xml:

<android.support.v7.widget.CardView xmlns:cardview="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/card_container"
    cardview:cardCornerRadius="2dp"
    cardview:cardElevation="4dp"
    cardview:cardUseCompatPadding="true">

    <RelativeLayout
        android:id="@+id/relativeLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="false"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="false"
            android:layout_alignParentStart="false"
            android:layout_above="@+id/card_description">

            <LinearLayout
                android:id="@+id/linearView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="@android:color/holo_purple"
                android:gravity="center_vertical"
                android:orientation="vertical"
                android:visibility="gone">

                <LinearLayout
                    android:id="@+id/layoutButtons"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:orientation="vertical"
                    android:visibility="gone">

                    <Button
                        style="@style/Widget.AppCompat.Button.Colored"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/activity_vertical_margin"
                        android:text="@string/card_reveal_buy" />

                    <Button
                        style="@style/Widget.AppCompat.Button.Colored"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/activity_vertical_margin"
                        android:text="@string/card_reveal_share" />

                    <Button
                        style="@style/Widget.AppCompat.Button.Colored"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/card_reveal_favorite" />


                </LinearLayout>

            </LinearLayout>

            <ImageView
                android:id="@+id/card_item_image"
                android:layout_width="match_parent"
                android:layout_height="440dp"
                android:adjustViewBounds="true"
                android:contentDescription="@string/image"
                android:src="@drawable/test_image"
                android:scaleType="centerCrop"
                android:layout_gravity="center_horizontal|top" />

        </FrameLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/price"
            android:id="@+id/card_price"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true"
            android:layout_margin="2dp" />

        <TextView
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/shipping"
            android:id="@+id/card_shipping"
            android:textAlignment="viewEnd"
            android:layout_alignTop="@+id/card_price"
            android:layout_alignParentEnd="true"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_marginTop="2dp"
            android:layout_marginBottom="2dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="@string/desc"
            android:id="@+id/card_description"
            android:textAlignment="center"
            android:layout_above="@+id/card_price"
            android:layout_alignParentStart="true"
            android:layout_alignEnd="@+id/card_shipping"
            android:layout_marginBottom="8dp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/card_image_description"
            android:id="@+id/card_shipping_icon"
            android:src="@drawable/ic_local_shipping"
            android:layout_alignTop="@+id/card_shipping"
            android:layout_toStartOf="@+id/card_shipping" />


    </RelativeLayout>


</android.support.v7.widget.CardView>

Not working in nested RecyclerView

I have an horizontal RecyclerView in which I'm trying to show a vertical carousel. Nothing is displayed.

If I show the same carousel (using the same code - recycler view, adapter, etc) outside of the horizontal RecyclerView it works.

And if I use a normal vertical RecyclerView (i.e. use LinearLayoutManager) in the horizontal RecyclerView instead of carousel, it also works (again, same code, I just change the layout manager + the configuration indicated in the readme).

Any ideas...?

itemCount==0 的时候发生NullPointerException, 希望可以解决一下, 谢谢Thanks

Log:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.azoft.carousellayoutmanager.CarouselLayoutManager.getScrollItemSize(CarouselLayoutManager.java:574)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.getMaxScrollOffset(CarouselLayoutManager.java:415)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.getCurrentScrollPosition(CarouselLayoutManager.java:404)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.getOffsetCenterView(CarouselLayoutManager.java:584)
at com.azoft.carousellayoutmanager.CenterScrollListener.onScrollStateChanged(CenterScrollListener.java:25)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:3990)

Buggy animation after adjusting PostLayoutListener

Hi, after following the advice in the issue: #4 , and adjusting the zoom size and some of the spacing sizes and animation tends to jump around, especially when a carousel item settles at the centre point. Cheers

can not add delete item animation?

just add the animator like below, but the animateRemove is not called. Could you help this?

    recyclerView.setItemAnimator(new DefaultItemAnimator() {
        @Override
        public boolean animateRemove(RecyclerView.ViewHolder holder) {
            Log.e("carousel","animateRemove");
            return super.animateRemove(holder);
        }

        @Override
        public boolean animateAdd(RecyclerView.ViewHolder holder) {
            Log.e("carousel","animateAdd");
            return super.animateAdd(holder);
        }
    });

disabling the circular motion of the center item when scrolling.

i'm using the vertical view for the carousel, but when i scroll the items, the center will kinda look jerky/jumpy its a bit circular transition, My code below

@OverRide
public ItemTransformation transformChild(@nonnull View child, float itemPositionToCenterDiff, int orientation) {
final float scale = (float) (2 * (2 * -StrictMath.atan(Math.abs(itemPositionToCenterDiff) + 1.30) / Math.PI + 1));

    // because scaling will make view smaller in its center, then we should move this item to the top or bottom to make it visible
    final float translateY;
    final float translateX;
    if (CarouselLayoutManager.VERTICAL == orientation) {
        final float translateYGeneral = child.getMeasuredHeight() * (1 - scale) * 2 * .50f;
        translateY = Math.signum(itemPositionToCenterDiff) * translateYGeneral;
        translateX = 0;
    } else {// 0.60

        final float translateXGeneral = (float) (child.getMeasuredWidth() * (0 - scale) / 2f);
        translateX = Math.signum(itemPositionToCenterDiff) * translateXGeneral;
        translateY = 0;
    }

    return new ItemTransformation(scale, scale, translateX, translateY);
}

How to change carousel parameters?

Hi! You carousel is awesom :)
And working fine (bug with the animations turned out to be my problev, sorry).
But i have some questions:

  • How to change the depth of the carousel?
  • How to change the animation speed? (Its very fast in centering)

Regards Max

scrollToPosition method throws exception

Hi,
I'm getting a crash when I call scrollToPosition() method, my code

 final CarouselLayoutManager layoutManager = new CarouselLayoutManager
                (CarouselLayoutManager.HORIZONTAL, false);
        Carousel2Adapter adapter = new Carousel2Adapter();
        ArrayList<Object> objects = getObjects();
        adapter.setObjects(objects);
        recyclerView.setAdapter(adapter);
        recyclerView.setHasFixedSize(true);
        layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());
        layoutManager.setMaxVisibleItems(1);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.addOnScrollListener(new CenterScrollListener());
        recyclerView.scrollToPosition(2);

I have tried with default LayoutManager (LinearLayoutManager) and it worked. exception I'm getting is

ava.lang.IllegalArgumentException: position can't be great then adapter items count. position is : 2

I have around 10 items is in my recycler view

Spacing between 1st right & 1st left item in Carousel

Im using layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

But it is giving me a spacing like this between the center item & 1st right, 1st left like this
image

How to reduce the gap ?

Regards,
Sasank

Sliding an item left or right (but not deleting it), then scrolling up / down fast causes the program to crash

Hello.

I used your library in order to stack cards for my program.
Since it is a RecyclerView, I have added an ItemTouchListener to the RecyclerView in order to slide the items.

All is fine. But one issue I encountered was that when I slide the item left or right (but not removing it), then scrolling the list up / down very fast, my program would crash and will say

java.lang.IllegalArgumentException: Tmp detached view should be removed from RecyclerView before it can be recycled: ViewHolder{f0f213a position=5 id=-1, oldPos=-1, pLpos:-1 tmpDetached no parent}
at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5424)
at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1242)
at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:11151)
at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:11651)
at android.support.v7.widget.SimpleItemAnimator.dispatchMoveFinished(SimpleItemAnimator.java:279)
at android.support.v7.widget.DefaultItemAnimator$6.onAnimationEnd(DefaultItemAnimator.java:304)
at android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd(ViewPropertyAnimatorCompatJB.java:47)
at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1114)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766)
at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:628)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Hoping for your response on this issue. Thank you.

Scroll Direction Hint

Hello,

Thank you for your amazing library. I am trying to find out the direction of scrolling while the center item changes. The problem exists when the adapter has only two items and the layout manager is circular. For example the first item displays the minute 0 and the second item displays the minute 30. The item in the center is the 30 one. When I scroll up the item changes correctly to 0 but I have no indication that the scroll happened forwards. The same thing happens when I scroll down and the item goes from 0 to 30 (backwards). The scrollBy(...) function gets a diff that may be bigger or lower than 0 in any given situation thus I am not able to distinct that the scroll happened backwards or forwards.

Any given thoughts?

Pagination

How to implement pagination in this layout manager , unlike the other layout mangers i cant get the first and last visible item methods here ....

smoothScrollToPosition crash

Hi,
I tried to smooth scroll to next item from carousel using two buttons(left and right). For this I used the following:

  • left navigation: carouselLayoutManager.smoothScrollToPosition(listHorizontalRecyclerView, null, carouselLayoutManager.getCenterItemPosition() - 1);
  • right navigation: carouselLayoutManager.smoothScrollToPosition(listHorizontalRecyclerView, null, carouselLayoutManager.getCenterItemPosition() + 1);
    Right navigation works good, but on left navigation, when I am on first item and try to navigate another one step to left, app crash, for both infinite and non infinite scroll modes.

Process: com.azoft.carousellayoutmanager.sample, PID: 31908
java.lang.IllegalArgumentException: Invalid target position
at android.support.v7.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:9562)
at android.support.v7.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:6596)
at com.azoft.carousellayoutmanager.CarouselLayoutManager.smoothScrollToPosition(CarouselLayoutManager.java:193)

There is a workaround for example for non infinite scroll to check when navigate left if carouselLayoutManager.getCenterItemPosition() != 0, but the issue is still there.

Make childs bigger

Hi, thanks for perfect library. I hava a problem about childs. Here is my implementation :

layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());
layoutManager.setMaxVisibleItems(4);


        recyclerView.setLayoutManager(layoutManager);
        // we expect only fixed sized item for now
        recyclerView.setHasFixedSize(true);
        // sample adapter with random data
        recyclerView.setAdapter(adapter);
        // enable center post scrolling
        recyclerView.addOnScrollListener(new CenterScrollListener());

here what i want to do : ios photo

here what i do : android

how can i make bigger these childs? thank you

Jumping feel while sliding slowly

Hi,
When I scroll from one card to another very slowly it jumps from on to another. the scrolling is not smooth, I think you are bringing the next card immediately. can you make it pixel by pixel ? also is there any way that I can adjust the position of cards ?

Only two items in Carousel

Hey guys. Thanks for really great lib :) I have a question. I have only two items in view, and right left child is visible. How to put it behind center one, and show it on sides when items count is > than 2?)

ItemViewBinding

Why I can‘t find the CLASS ItemViewBinding so that many problems happened...
I'm a beginner...

example:("ItemViewBinding" is red in the following code)

private static class TestViewHolder extends RecyclerView.ViewHolder {

    private final ItemViewBinding mItemViewBinding;

    TestViewHolder(final ItemViewBinding itemViewBinding) {
        super(itemViewBinding.getRoot());

        mItemViewBinding = itemViewBinding;
    }
}

Scroll not smooth

Hello,
first thanks for great job you did on this project!

Secondly. I successfully used your library but now I am experiencing little problem.

When I try to change text of textview inside OnItemSelectionListener than immediately recyclerview jump to center item and scroll animation is not smooth but is completed immediately.

Any idea at least for some workaround? So far I postponed changing a text with runnable so if user scroll fast, than he will not experience this jumping.

Thank you!

findFirstVisibleItemPosition

Can provide findFirstVisibleItemPosition(),findLastVisibleItemPosition() method or provide a listener notify which item selected now ?

Add 10 images in adapter using this library

Hi Author,

I have downloaded 10 images from internet and i need to use this carosel for them. How to do so?

Alsoi need to open new activity on clicking any item of the carosel. Please help me in this.

Thanks

Optimise scrolling with PostLayoutListener by using object pools

Love this lib! It's brilliant!

Every time a scroll occurs, ItemTransformation objects are created per view per scroll. This use of creating many ItemTransformation objects a lot of the time, it makes the GC fire off many times and therefore, you see jank. If an object pool is used, it would mean that the GC won't be fired constantly.

This would look something like adding a method to ItemTransformation.obtain(scaleX,scaleY,translationX,translationY) and using an object pool internally to get objects. Then once it's been used, just call release method on object and that tells the system it can be recycled.

Colt McAnlis explains the concept here: https://www.youtube.com/watch?v=bSOREVMEFnM

What do you think? Is it something worth exploring?

Distance between items

Hi! The carousel is great! I have a question... What do I have to set or change when the distance between each item are very large? I mean, I have a list of items but the height of each one is no too large, it just one textview. But when I implement the layout manager on vertical I get a distance between each one, and I want them to be overloaded.

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.