Glide: SimpleTarget deprecated

Created on 7 Sep 2018  路  19Comments  路  Source: bumptech/glide

Since latest update of Glide (4.8.0) SimpleTargethas been deprecated so instead of it i use Targetas mention in this issue #3294 , but doesn't work at all the onResourceReadymethod is not called .

  Glide.with(getApplicationContext()).asBitmap()
                                .load(url)
                                .apply(options).into(new Target<Bitmap>() {
                            @Override
                            public void onLoadStarted(@Nullable Drawable placeholder) {

                            }

                            @Override
                            public void onLoadFailed(@Nullable Drawable errorDrawable) {

                            }

                            @Override
                            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                                    new saveImage().execute(resource);
                            }

                            @Override
                            public void onLoadCleared(@Nullable Drawable placeholder) {
                            }

                            @Override
                            public void getSize(@NonNull SizeReadyCallback cb) {
                            }

                            @Override
                            public void removeCallback(@NonNull SizeReadyCallback cb) {

                            }

                            @Nullable
                            @Override
                            public Request getRequest() {
                                return null;
                            }

                            @Override
                            public void setRequest(@Nullable Request request) {

                            }

                            @Override
                            public void onStart() {

                            }

                            @Override
                            public void onStop() {

                            }

                            @Override
                            public void onDestroy() {

                            }
                        });
enhancement

Most helpful comment

What is supposed to be the replacement of SimpleTarget ? If there isn't, why deprecate it?

All 19 comments

I have same issue, too

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

I am also having this issue.

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

Same issue :(

A simpler alternative will be available in 4.9.0 from: https://github.com/sjudd/glide/commit/b3b2d7aa84a5beb8eddea39f2ec0e8ba35ceaa20

Try changing Target to CustomViewTarget.

@sjudd When do you think 4.9.0 will be available?

What is supposed to be the replacement of SimpleTarget ? If there isn't, why deprecate it?

A simpler alternative will be available in 4.9.0 from: sjudd@b3b2d7a

So what should we do until then? Just keep using SimpleTarget?

@jackz314 Probably.
I wonder what else is new on 4.9.0 . And if it's hard to migrate to it from 4.8.0

there is a viewTarget in glide 4.8 but it is complex

Please update the getting started docs: https://bumptech.github.io/glide/doc/getting-started.html Here, SimpleTarget is still used.

@sjudd, please respond properly to above questions. What is to be used instead of SimpleTarget? 4.9.0 is here, but the tutorial uses simpletarget. Please update the tutorial. Thanks!

I am having the same issue, can't find a replacement anywhere, no mention in the docs. Official docs still use the 3.9.0, someone f'd up real bad here by not releasing their work.

@chjan - see the earlier comments, you want CustomTarget, or just don't use SimpleTarget and extend Target, that's also fine.

There's some detail in the deprecation message about which other targets to use - http://bumptech.github.io/glide/javadocs/490/com/bumptech/glide/request/target/SimpleTarget.html.

I will update the getting started docs, thanks @cristan for the link

Same issue. I've used Glide (4.9.0), but onResourceReady has not been called.
Logcat shows setRequest -> getSize -> onLoadCreated.

Here is the solution

Glide
.with(this)
.load("URL")
.into(new CustomTarget() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) {
menu_local.getItem(0).setIcon(resource);
}

                        @Override
                        public void onLoadCleared(@Nullable Drawable placeholder) {

                        }
                    });

@vijayamurugan Should we worry about onLoadCleared ?
It says:

A mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.
You must ensure that any current Drawable received in onResourceReady(Object, Transition) is no longer used before redrawing the container (usually a View) or changing its visibility.

I don't understand its usage. Do we need to put there something ? If so, what, and in which cases?

Was this page helpful?
0 / 5 - 0 ratings