Ramotion/folding-cell-android

Bug in Fold Animation

Sourish1997 opened this issue · 2 comments

When folding a folding cell in a recycler view with more than 50% of the top portion of the unfolded cell not visible on the screen, the folding does not happen properly and the folding cell becomes unresponsive.

Unfolded View:

whatsapp image 2017-04-12 at 8 15 08 pm 1

View with more than 50% of to part out of screen:

whatsapp image 2017-04-12 at 8 15 08 pm 2

Bug on Folding the View:

whatsapp image 2017-04-12 at 8 15 08 pm

Layout:

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

    <com.ramotion.foldingcell.FoldingCell
        android:id="@+id/coupon_folding_cell"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:backSideColor="@color/cardColorBackground">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"
            app:cardBackgroundColor="#414141">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="364dp"
                android:background="#414141">

                <ImageView
                    android:id="@+id/coupon_barcode"
                    android:layout_width="250dp"
                    android:layout_height="250dp"
                    android:layout_marginBottom="57dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="57dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/abhinav" />
            </android.support.constraint.ConstraintLayout>

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

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardBackgroundColor="#414141">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="182dp"
                android:background="#414141">

                <ImageView
                    android:id="@+id/coupon_primary_image"
                    android:layout_width="100dp"
                    android:layout_height="100dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toRightOf="@+id/linearLayout"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:srcCompat="@drawable/ic_coffee" />

                <LinearLayout
                    android:id="@+id/linearLayout"
                    android:layout_width="60dp"
                    android:layout_height="182dp"
                    android:layout_marginLeft="8dp"
                    android:background="@color/colorAccent"
                    android:orientation="vertical"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <TextView
                        android:id="@+id/coupon_title"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_margin="5dp"
                        android:gravity="center"
                        android:text="@string/dinner"
                        android:textAlignment="center"
                        android:textColor="@color/textColorPrimary"
                        android:textSize="12sp"
                        android:textStyle="bold" />
                </LinearLayout>
            </android.support.constraint.ConstraintLayout>
        </android.support.v7.widget.CardView>
    </com.ramotion.foldingcell.FoldingCell>
</LinearLayout>

Holder:

    public ImageView barcode, primaryImage;
    public TextView title;
    public FoldingCell foldingCell;

    public CouponsHolder(View itemView) {
        super(itemView);
        barcode = (ImageView) itemView.findViewById(R.id.coupon_barcode);
        primaryImage = (ImageView) itemView.findViewById(R.id.coupon_primary_image);
        title = (TextView) itemView.findViewById(R.id.coupon_title);
        foldingCell = (FoldingCell) itemView.findViewById(R.id.coupon_folding_cell);
        foldingCell.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                foldingCell.toggle(false);
            }
        });
    }
}

Adapter:

    ArrayList<String> couponTitles;
    ArrayList<Integer> primaryimages;
    ArrayList<Bitmap> qrCodes;

    public CouponsAdapter(ArrayList<String> couponTitles, ArrayList<Integer> primaryimages, ArrayList<Bitmap> qrCodes) {
        this.couponTitles = couponTitles;
        this.primaryimages = primaryimages;
        this.qrCodes = qrCodes;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new CouponsHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_coupons_item, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        CouponsHolder couponsHolder = (CouponsHolder) holder;
        couponsHolder.foldingCell.fold(true);
        couponsHolder.title.setText(couponTitles.get(position));
        couponsHolder.primaryImage.setImageResource(primaryimages.get(position));
        couponsHolder.barcode.setImageBitmap(qrCodes.get(position));
    }

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

@oleg-vasiliev, @Juriv anything regarding this issue?

Hello, guys. This issue was resolved in new version. Please update to the new version of this lib. It is also now migrated to androidX.