Skip to content

Commit

Permalink
Invert if to reduce nesting.
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Apr 25, 2018
1 parent 599abfa commit be1564f
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
});
}
}

0 comments on commit be1564f

Please sign in to comment.