I was thinking of the case when setImageResource is called for the first
time, and I'd expect that most of the time it's only called once for an
ImageView instance. But you're right, on subsequent calls to
setImageResource(), if resId is 0, it calls updateDrawable(null) (not blow
up like I said previously).

Fixed with your suggestions.


On Thu, Sep 19, 2013 at 12:43 PM, Jake Wharton <notifications@github.com>wrote:

> In src/main/java/org/robolectric/shadows/ShadowImageView.java:
>
> > @@ -35,7 +35,9 @@ public void setImageDrawable(Drawable drawable) {
> >
> >    @Implementation
> >    public void setImageResource(int resId) {
> > -    setImageDrawable(buildDrawable(resId));
> > +    if (resId != 0) {
> > +      setImageDrawable(buildDrawable(resId));
>
> Really? As I read the code it matches more closely. As long as the
> resource Id is different it nulls out the drawable in updateDrawable.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/robolectric/robolectric/pull/691/files#r6471129>
> .
>