Created
September 11, 2016 00:11
-
-
Save jsaund/a76da153c582db92471f35f9d0ad2f84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class UIHandler extends Handler { | |
private final WeakReference<ImageFetcherActivity> mActivityRef; | |
UIHandler(ImageFetcherActivity activity) { | |
mActivityRef = new WeakReference(activity); | |
} | |
@Override | |
public void handleMessage(Message msg) { | |
final ImageFetcherActivity activity = mActivityRef.get(); | |
if (activity == null) { | |
return | |
} | |
switch (msg.what) { | |
case MSG_SHOW_LOADER: { | |
activity.progressIndicator.setVisibility(View.VISIBLE); | |
break; | |
} | |
case MSG_HIDE_LOADER: { | |
activity.progressIndicator.setVisibility(View.GONE); | |
break; | |
} | |
case MSG_SHOW_IMAGE: { | |
activity.progressIndicator.setVisibility(View.GONE); | |
activity.imageView.setImageBitmap((Bitmap) msg.obj); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment