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

NullPointerException with Picasso when there is no placeholder. #52

Open
ZxoR opened this issue Nov 7, 2015 · 10 comments
Open

NullPointerException with Picasso when there is no placeholder. #52

ZxoR opened this issue Nov 7, 2015 · 10 comments

Comments

@ZxoR
Copy link

ZxoR commented Nov 7, 2015

The lines of code:

            final CircularImageView circularImageView = (CircularImageView) holder.mRootView.findViewById(R.id.circularImageView);

                Picasso.with(holder.mRootView.getContext()).load(new File(trackingNumbers.get(position).getImageUrl())).error(R.drawable.no_image_place_holder).noFade().into(circularImageView);

The exception:

11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:596)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.pkmmte.view.CircularImageView.refreshBitmapShader(CircularImageView.java:341)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:262)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.widget.ImageView.setImageDrawable(ImageView.java:456)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.squareup.picasso.PicassoDrawable.setPlaceholder(PicassoDrawable.java:61)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.squareup.picasso.RequestCreator.into(RequestCreator.java:664)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.squareup.picasso.RequestCreator.into(RequestCreator.java:601)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at kael.trackninja.Adapters.TrackingRecyclerViewAdapter.onBindViewHolder(TrackingRecyclerViewAdapter.java:83)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at kael.trackninja.Adapters.TrackingRecyclerViewAdapter.onBindViewHolder(TrackingRecyclerViewAdapter.java:30)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5212)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5245)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4483)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1435)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:282)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:580)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:549)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5272)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
11-07 16:16:46.246 29353-29353/kael.trackninja E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

It happens only when using CircleImageView, when switching to regualr ImageView its not working.

EDIT: I found that when you adding "placeholder" to picasso its working fine:

                Picasso.with(holder.mRootView.getContext()).load(new File(trackingNumbers.get(position).getImageUrl())).error(R.drawable.no_image_place_holder).noFade().placeholder(R.drawable.no_image_place_holder).into(circularImageView);
@ionull
Copy link

ionull commented Dec 3, 2015

Same here, please fix this :)

@deboLing
Copy link

Please use the imageloader jar

@rahulfhp
Copy link

Same here , Any fix for this ?

@rugved-in
Copy link

same here but I'm using Glide

@timkoers
Copy link

timkoers commented Mar 2, 2016

I just received the same NullPointerException. Please fix this

@levibostian
Copy link

Just received crash as well. Added a placeholder image as my view needs one anyway. Other cases I might not want a placeholder.

@anupamchugh
Copy link

Any fixes found?

@snehaltembare
Copy link

Give placeholder explicitly like
Picasso.with(this).load(imageUrl).placeholder(R.drawable.placeHolder).into(mImg);
Above line solved my problem... :)

@jrcaz
Copy link

jrcaz commented Oct 3, 2019

Give placeholder explicitly like
Picasso.with(this).load(imageUrl).placeholder(R.drawable.placeHolder).into(mImg);
Above line solved my problem... :)

Wow, that solved my problem too. Thank you so much.

@khyveasna
Copy link

Udine and the rest are all good JDownloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests