Skip to content

Commit 340b595

Browse files
committed
Check existence of attacher when setting an image
1 parent 8b1344a commit 340b595

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

photoview/src/main/java/com/github/chrisbanes/photoview/PhotoView.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,25 @@ public void setScaleType(ScaleType scaleType) {
109109
public void setImageDrawable(Drawable drawable) {
110110
super.setImageDrawable(drawable);
111111
// setImageBitmap calls through to this method
112-
attacher.update();
112+
if (attacher != null) {
113+
attacher.update();
114+
}
113115
}
114116

115117
@Override
116118
public void setImageResource(int resId) {
117119
super.setImageResource(resId);
118-
attacher.update();
120+
if (attacher != null) {
121+
attacher.update();
122+
}
119123
}
120124

121125
@Override
122126
public void setImageURI(Uri uri) {
123127
super.setImageURI(uri);
124-
attacher.update();
128+
if (attacher != null) {
129+
attacher.update();
130+
}
125131
}
126132

127133
@Override

0 commit comments

Comments
 (0)