Invert if to reduce nesting.

This commit is contained in:
Dylan Vann 2018-04-24 22:57:26 -04:00
parent 599abfafaa
commit be1564fe54
1 changed files with 17 additions and 17 deletions

View File

@ -33,23 +33,23 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
@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();
}
});
}
});
}
}