Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glide doesn't skip cache when skipMemoryCache(true) and/or diskCacheStrategy(DiskCacheStrategy.NONE)) #2663

Closed
lam-amsiq opened this issue Nov 30, 2017 · 3 comments

Comments

@lam-amsiq
Copy link

Glide Version:
4.3.1

Integration libraries:

Device/Android Version:
All

Issue details / Repro steps / Use case background:
Glide loads cached image when it should skip cache and/or not cache in the firstplace. This case happens for vector drawables.

Glide load line / GlideModule (if any) / list Adapter code (if any):

                if (backgroundIndex != -1 && background != null) {
                    int res = getBackgroundResource(backgroundIndex);
                    Glide.with(getContext())
                            .load(res)
                            .apply(new RequestOptions()
                                    .skipMemoryCache(true)
                                    .diskCacheStrategy(DiskCacheStrategy.NONE))
                            .listener(new RequestListener<Drawable>() {
                                @Override
                                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                    SoudfaLog.d(TAG, "Failed! : " + e);
                                    return false;
                                }

                                @Override
                                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                                    SoudfaLog.d(TAG, "Ready! : dataSource= " + dataSource);
                                    return false;
                                }
                            })
                            .into(background);
                }

Layout XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/auth_background"
    android:alpha="0"
    android:clickable="true"
    android:clipChildren="false"
    android:clipToPadding="false">

    <ImageView
        android:id="@+id/background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:adjustViewBounds="true"
        app:srcCompat="@drawable/pages_match_overlay_background_1" />

    <com.soudfa.views.CustomFontTextView
        android:id="@+id/title"
        style="@style/XLargeBold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="@dimen/overlay_card_margin_top"
        android:layout_marginStart="@dimen/padding_48"
        android:layout_marginEnd="@dimen/padding_48"
        android:lines="1"
        android:text="@string/overlay_mutual_interest_title"
        android:textAlignment="center"
        android:textColor="@color/brightest"
        android:textSize="@dimen/overlay_title" />

    <com.soudfa.views.CustomFontTextView
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/title"
        android:layout_marginBottom="@dimen/padding_24"
        android:layout_marginTop="@dimen/padding_8"
        android:layout_alignStart="@+id/title"
        android:layout_alignEnd="@+id/title"
        android:text="@string/overlay_mutual_interest_content"
        android:textAlignment="center"
        android:textColor="@color/brightest"
        android:textSize="@dimen/overlay_content" />

    <android.support.constraint.ConstraintLayout xmlns:constraint="http://schemas.android.com/apk/res-auto"
        android:id="@+id/pictureContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/content"
        android:layout_above="@+id/chat_now"
        android:layout_gravity="bottom"
        android:layout_marginStart="@dimen/overlay_picture_container_padding_sides"
        android:layout_marginEnd="@dimen/overlay_picture_container_padding_sides"
        android:layout_marginBottom="@dimen/overlay_picture_container_padding_bottom"
        android:clickable="true">

        <android.support.constraint.Guideline
            android:id="@+id/center"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:visibility="invisible"
            constraint:layout_constraintGuide_percent="0.5" />

        <com.soudfa.views.Notification.OverLay.OverlayPortrait_
            android:id="@+id/user"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@drawable/shape_mutual_profile_image_stroke"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            constraint:layout_constraintEnd_toEndOf="parent"
            constraint:layout_constraintStart_toStartOf="@id/center"
            constraint:layout_constraintHorizontal_bias="0"
            constraint:layout_constraintVertical_bias="0"
            android:padding="9dp" />

        <com.soudfa.views.Notification.OverLay.OverlayPortrait_
            android:id="@+id/match"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@drawable/shape_mutual_profile_image_stroke"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            constraint:layout_constraintEnd_toEndOf="@id/center"
            constraint:layout_constraintStart_toStartOf="parent"
            constraint:layout_constraintHorizontal_bias="1"
            constraint:layout_constraintVertical_bias="0"
            android:padding="9dp"/>

    </android.support.constraint.ConstraintLayout>

    <Button
        android:id="@+id/chat_now"
        style="@style/SoudfaButton.OverLayButton"
        android:layout_width="@dimen/overlay_button_chat_width"
        android:layout_height="@dimen/overlay_button_chat_height"
        android:layout_above="@+id/cancelButton"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="@dimen/padding_24"
        android:layout_marginEnd="@dimen/padding_48"
        android:layout_marginStart="@dimen/padding_48"
        android:background="@drawable/action_overlay_positive"
        android:text="@string/overlay_mutual_interest_action_positive" />

    <com.soudfa.views.Buttons.RoundButtonWithIcon_
        android:id="@+id/cancelButton"
        android:layout_width="@dimen/overlay_button_cancel"
        android:layout_height="@dimen/overlay_button_cancel"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="@dimen/padding_12"
        android:background="@drawable/action_match_overlay_cancel"/>

Stack trace / LogCat:

11-30 16:19:04.544 13685-13685/com.soudfa D/DEBUG: match-mutual-overlay: Ready! : dataSource MEMORY_CACHE
@lam-amsiq lam-amsiq changed the title Glide doesn't skip cache when when skipMemoryCache(true) and/or diskCacheStrategy(DiskCacheStrategy.NONE)) Glide doesn't skip cach when skipMemoryCache(true) and/or diskCacheStrategy(DiskCacheStrategy.NONE)) Nov 30, 2017
@lam-amsiq lam-amsiq changed the title Glide doesn't skip cach when skipMemoryCache(true) and/or diskCacheStrategy(DiskCacheStrategy.NONE)) Glide doesn't skip cache when skipMemoryCache(true) and/or diskCacheStrategy(DiskCacheStrategy.NONE)) Nov 30, 2017
@sjudd
Copy link
Collaborator

sjudd commented Nov 30, 2017

Could you send a pull request with a failing test case? More detail on how to do this here: http://bumptech.github.io/glide/tut/failing-test-cases.html

@lam-amsiq
Copy link
Author

Project with cache issue:
GlideCacheIssue.zip

@sjudd
Copy link
Collaborator

sjudd commented Dec 7, 2017

@sjudd sjudd added this to the 4.5 milestone Dec 7, 2017
@sjudd sjudd closed this as completed in 3dc1d18 Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants