Permalink
Browse files

Refactored code not to have too many nested if clauses.

  • Loading branch information...
1 parent 256134b commit b9c88ebf0f1ef96e12482c434c4775075f4ddeb1 Stefano Dacchille committed Oct 30, 2012
@@ -158,21 +158,19 @@ protected boolean handleImageLoaded(Bitmap bitmap, Message msg) {
// the thread will set the image only if it's the right position,
// otherwise it won't do anything.
Object viewTag = view.getTag();
- if (imageUrl.equals(viewTag)) {
- if (bitmap == null) {
- if (view != null) {
- onImageLoadedFailed();
- }
- } else {
- if (view != null) {
- onImageLoadedSuccess(bitmap);
- }
- }
+ if (!imageUrl.equals(viewTag)) {
+ return false;
+ }
+ if (bitmap == null) {
+ onImageLoadedFailed();
+ } else {
+ onImageLoadedSuccess(bitmap);
+ }
+ if (view != null) {
// remove the image URL from the view's tag
view.setTag(null);
- return true;
}
- return false;
+ return true;
}
protected abstract void onImageLoadedFailed();

0 comments on commit b9c88eb

Please sign in to comment.