team-supercharge / ShimmerLayout

DEPRECATED - Memory efficient shimmering effect for Android applications by Supercharge.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No effect inside recyclerview

ClaudeHangui opened this issue · comments

I have an adapter which consists of a SimpleDraweeView, Textview and a View (which serves as a line separator between items)...
I injected the ShimmerLayout (for each view) inside my xml, bound the items in my ViewHolder, but when I launch the app, nothing is visible on the screen; even the placeholder image I defined in my xml is not showing...The items appears only when the image is loaded....I stopped the Shimmer Effect for the 3 views once the image is loaded; the thing is I don't even see my placeholder image and so I don't see any shimmer animation in my list..
Here's my xml:
`

<io.supercharge.shimmerlayout.ShimmerLayout
    app:shimmer_animation_duration="1200"
    android:id="@+id/sl_thumbnail"
    android:layout_width="match_parent"
    android:layout_height="170dp">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/sdv_thumbnail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/dimen_3"
        fresco:actualImageScaleType="focusCrop"
        fresco:backgroundImage="@color/category_title_bgd"
        fresco:pressedStateOverlayImage="@color/dark_red"
        fresco:placeholderImage="@drawable/cs_placeholder_grey"
        fresco:roundAsCircle="false"
        fresco:roundedCornerRadius="4dp"
        fresco:roundTopLeft="true"
        fresco:roundTopRight="true"
        fresco:roundBottomLeft="true"
        fresco:roundBottomRight="true"
        fresco:roundWithOverlayColor="@color/grey_50"
        fresco:roundingBorderWidth="2dp"
        fresco:roundingBorderColor="@color/grey_50" />

</io.supercharge.shimmerlayout.ShimmerLayout>

<io.supercharge.shimmerlayout.ShimmerLayout
    app:shimmer_animation_duration="1200"
    android:id="@+id/sl_video_title"
    android:layout_below="@id/sl_thumbnail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<TextView
    android:id="@+id/tv_video_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="15sp"
    android:textAlignment="center"
    android:textColor="@color/category_title_bgd"
    android:maxLines="2"
    android:textStyle="italic"
    android:gravity="fill_horizontal"
    android:layout_margin="@dimen/dimen_5"
    android:paddingTop="@dimen/dimen_3"
    android:paddingBottom="@dimen/dimen_3"
    android:ellipsize="end"
    />
</io.supercharge.shimmerlayout.ShimmerLayout>

<io.supercharge.shimmerlayout.ShimmerLayout
    android:id="@+id/sl_line_separator"
    android:layout_below="@id/sl_video_title"
    android:layout_width="wrap_content"
    app:shimmer_animation_duration="1200"
    android:layout_margin="@dimen/dimen_5"
    android:layout_height="0.7dp">
    <View
        android:layout_width="match_parent"
        android:background="@android:color/darker_gray"
        android:layout_height="match_parent"/>
</io.supercharge.shimmerlayout.ShimmerLayout>

`

Here's the code in my adapter:

`@Override
public void onBindViewHolder(final ViewHolder holder, int position)
{
    holder.shimmerLayoutThumbnail.startShimmerAnimation();
    Item mVideoItem = mDataSet.get(position);
    holder.mVideoTitle.setText(mVideoItem.getSnippet().getTitle());
    DraweeController controller
            = Fresco.newDraweeControllerBuilder()
            .setImageRequest(ImageRequestBuilder.newBuilderWithSource(Uri.parse(
                    mVideoItem.getSnippet().getThumbnails().getHigh().getUrl()))
                    .build())
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                    Log.i("DraweeUpdate", "Image is fully loaded!");
                    holder.shimmerLayoutThumbnail.stopShimmerAnimation();
                    holder.shimmerLayoutTitle.stopShimmerAnimation();
                    holder.shimmerLayoutSeparator.stopShimmerAnimation();
                }
    @Override
                public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
                    Log.i("DraweeUpdate", "Image is partly loaded! (maybe it's a progressive JPEG?)");
                    if (imageInfo != null)
                    {
                        int quality = imageInfo.getQualityInfo().getQuality();
                        Log.i("DraweeUpdate", "Image quality (number scans) is: " + quality);
                    }
                }

                @Override
                public void onFailure(String id, Throwable throwable) {
                    super.onFailure(id, throwable);
                    Log.i("DraweeUpdate", "Image failed to load: " + throwable.getMessage());
                    holder.shimmerLayoutThumbnail.stopShimmerAnimation();
                }
            })
            .build();
    holder.sdvYoutubeThumbnail.setController(controller);
}`

@ClaudeHangui thanks for reporting the issue. I will do the investigation soon.

@ClaudeHangui First of all, the usage of ShimmerLayout here is not proper. You have 3 ShimmerLayout in your list item, however you only start the animation for one of them. The other 2 (Shimmer effect on the title and the separator) is not visible since they are not started. At the onFinalImageSet method, you stop all of them, even they are not started, on the onFailure method only one of them is stopped.

For the next attributes I would use a color/image which has non zero alpha layer:

fresco:backgroundImage="@color/category_title_bgd" 
fresco:placeholderImage="@drawable/cs_placeholder_grey"

I tried your code and for me it worked after correcting the mentioned defects. Sorry for the look of it, but it demonstrates that it works.

If it is still not working, write me!

shimmer_working

Ok then..I'll give it a try and get back if I encounter any issues