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

SimpleTarget deprecated #3304

Closed
Mouadabdelghafouraitali opened this issue Sep 7, 2018 · 19 comments
Closed

SimpleTarget deprecated #3304

Mouadabdelghafouraitali opened this issue Sep 7, 2018 · 19 comments
Milestone

Comments

@Mouadabdelghafouraitali
Copy link

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() {

                            }
                        });
@sajjadyousefnia
Copy link

I have same issue, too

@stale
Copy link

stale bot commented Sep 18, 2018

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 stale bot added the stale label Sep 18, 2018
@Ken-Lim
Copy link

Ken-Lim commented Sep 21, 2018

I am also having this issue.

@stale stale bot removed the stale label Sep 21, 2018
sjudd added a commit to sjudd/glide that referenced this issue Sep 21, 2018
Extending Target directly requires implementing some not totally trivial
boilerplate logic in set/getRequest and getSize. This class does not
implement onLoadCleared, and should provide an implementation safer than
BaseTarget and SimpleTarget, but more convenient than just the Target
interface. See bumptech#3304 for an example request for this class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212743879
@stale
Copy link

stale bot commented Sep 28, 2018

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 stale bot added the stale label Sep 28, 2018
@hbdeveloppeur
Copy link

Same issue :(

@stale stale bot removed the stale label Sep 28, 2018
@sjudd
Copy link
Collaborator

sjudd commented Oct 5, 2018

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

@sjudd sjudd closed this as completed Oct 5, 2018
@sjudd sjudd added this to the 4.9.0 milestone Oct 5, 2018
@androidmh
Copy link

androidmh commented Oct 22, 2018

Try changing Target to CustomViewTarget.

@maherimcovery
Copy link

@sjudd When do you think 4.9.0 will be available?

@AndroidDeveloperLB
Copy link

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

@jackz314
Copy link

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

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

@AndroidDeveloperLB
Copy link

@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

@preqel
Copy link

preqel commented Mar 6, 2019

there is a viewTarget in glide 4.8 but it is complex

@cristan
Copy link

cristan commented Mar 13, 2019

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

@chjan
Copy link

chjan commented Apr 25, 2019

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

@emailsubjekt
Copy link

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.

@sjudd
Copy link
Collaborator

sjudd commented May 1, 2019

@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

@jcooperation0137
Copy link

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

@vijayamurugan
Copy link

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) {

                        }
                    });

@AndroidDeveloperLB
Copy link

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

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