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

The image is not loaded from the oncreate method #2152

Open
karlovm opened this issue Jan 28, 2020 · 0 comments
Open

The image is not loaded from the oncreate method #2152

karlovm opened this issue Jan 28, 2020 · 0 comments

Comments

@karlovm
Copy link

karlovm commented Jan 28, 2020

I have a messenger program. It loads avatars when starting from the server, But the first time the image does not perform any of the target method, and there are no errors, but it appears
Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection) Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection) Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection)
in debug. And no answer for target: no onBitmapLoaded and onBitmapFailed (but second time image successfully loads)
My code

` Log.d("loadimage", "url: " + url);
Target target = new Target() {
@OverRide
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {

            Bitmap a = cropToSquare(bitmap);
            Log.d("image", "image has been setted: " + url);
            RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(c.getResources(), a);
            roundDrawable.setCircular(true);
            i.setImageDrawable(roundDrawable);

            i.setBackgroundDrawable(null);

            //  i.setPadding(0, 0,0, 0);
            i.setPadding(pxcon.todpi(0, c.getResources()), pxcon.todpi(0, c.getResources()), pxcon.todpi(0, c.getResources()), pxcon.todpi(0, c.getResources()));

            i.setImageDrawable(roundDrawable);
        }

        @Override
        public void onBitmapFailed(Exception e, Drawable errorDrawable) {
            i.setImageDrawable(errorDrawable);
            Log.d("image", "ERR");
        }


        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
        }
    };

    int min = 1;
    int max = 10;
    int diff = max - min;
    Random random = new Random();
    int ia = random.nextInt(diff + 1);

  


        if (isOnline(c)) {
            Picasso.get().load(url).networkPolicy(NetworkPolicy.NO_CACHE).into(target);


            Log.d("image load", "Image was loaded " + url);

        } else {
            Picasso.get().load(url).into(target);

            Log.d("image load", "Image was loaded (offline) " + url);
        }
 `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant