diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java b/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java index 501cf8a3..beb13c1f 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java @@ -33,23 +33,23 @@ public String getName() { @ReactMethod public void preload(final ReadableArray sources) { final Activity activity = getCurrentActivity(); - if (activity != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - for (int i = 0; i < sources.size(); i++) { - final ReadableMap source = sources.getMap(i); - final GlideUrl glideUrl = FastImageViewConverter.glideUrl(source); - final Priority priority = FastImageViewConverter.priority(source); - Glide - .with(activity.getApplicationContext()) - .load(glideUrl) - .priority(priority) - .placeholder(TRANSPARENT_DRAWABLE) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) - .preload(); - } + if (activity == null) return; + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + for (int i = 0; i < sources.size(); i++) { + final ReadableMap source = sources.getMap(i); + final GlideUrl glideUrl = FastImageViewConverter.glideUrl(source); + final Priority priority = FastImageViewConverter.priority(source); + Glide + .with(activity.getApplicationContext()) + .load(glideUrl) + .priority(priority) + .placeholder(TRANSPARENT_DRAWABLE) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .preload(); } - }); + } + }); } }