glide icon indicating copy to clipboard operation
glide copied to clipboard

SimpleTarget deprecated

Open Mouadabdelghafouraitali opened this issue 8 years ago • 19 comments

Since latest update of Glide (4.8.0) SimpleTarget has been deprecated so instead of it i use Target as mention in this issue #3294 , but doesn't work at all the onResourceReady method 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() {

                            }
                        });

Mouadabdelghafouraitali avatar Sep 07 '18 14:09 Mouadabdelghafouraitali

I have same issue, too

sajjadyousefnia avatar Sep 11 '18 07:09 sajjadyousefnia

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.

stale[bot] avatar Sep 18 '18 07:09 stale[bot]

I am also having this issue.

Ken-Lim avatar Sep 21 '18 01:09 Ken-Lim

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.

stale[bot] avatar Sep 28 '18 02:09 stale[bot]

Same issue :(

hbdeveloppeur avatar Sep 28 '18 21:09 hbdeveloppeur

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

sjudd avatar Oct 05 '18 19:10 sjudd

Try changing Target to CustomViewTarget.

androidmh avatar Oct 22 '18 09:10 androidmh

@sjudd When do you think 4.9.0 will be available?

maherimcovery avatar Oct 31 '18 23:10 maherimcovery

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

AndroidDeveloperLB avatar Nov 19 '18 21:11 AndroidDeveloperLB

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 avatar Dec 22 '18 00:12 jackz314

@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

AndroidDeveloperLB avatar Dec 22 '18 08:12 AndroidDeveloperLB

there is a viewTarget in glide 4.8 but it is complex

preqel avatar Mar 06 '19 11:03 preqel

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

cristan avatar Mar 13 '19 15:03 cristan

@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!

chjan avatar Apr 25 '19 12:04 chjan

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.

emailsubjekt avatar Apr 30 '19 20:04 emailsubjekt

@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

sjudd avatar May 01 '19 14:05 sjudd

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

jcooperation0137 avatar May 07 '19 10:05 jcooperation0137

Here is the solution

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

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

                        }
                    });

vijayamurugan avatar Sep 14 '19 12:09 vijayamurugan

@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?

AndroidDeveloperLB avatar Aug 26 '20 12:08 AndroidDeveloperLB