Skip to content

Commit

Permalink
SubjectFragment: ShowImageTask(): Let this work for any ItemFragment.
Browse files Browse the repository at this point in the history
And rename it to ShowImageFromContentProviderTask.
  • Loading branch information
murraycu committed Nov 21, 2014
1 parent a2f9c1a commit 9edc930
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java
Expand Up @@ -212,13 +212,13 @@ private void updateFromCursor() {
}

//See http://developer.android.com/training/displaying-bitmaps/process-bitmap.html
private static class ShowImageTask extends AsyncTask<String, Void, Bitmap> {
private static class ShowImageFromContentProviderTask extends AsyncTask<String, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
private final WeakReference<SubjectFragment> fragmentReference;
private final WeakReference<ItemFragment> fragmentReference;

private String strUri = null;

public ShowImageTask(final ImageView imageView, final SubjectFragment fragment) {
public ShowImageFromContentProviderTask(final ImageView imageView, final ItemFragment fragment) {
// Use a WeakReference to ensure the ImageView can be garbage collected
imageViewReference = new WeakReference<>(imageView);

Expand All @@ -232,7 +232,7 @@ protected Bitmap doInBackground(String... params) {
strUri = params[0];

if (fragmentReference != null) {
final SubjectFragment fragment = fragmentReference.get();
final ItemFragment fragment = fragmentReference.get();
if (fragment != null) {
return UiUtils.getBitmapFromContentUri(fragment.getActivity(), strUri);
}
Expand All @@ -250,7 +250,7 @@ protected void onPostExecute(final Bitmap bitmap) {
//so just abandon this whole item.
//That seems safer and simpler than trying to recover just one of the 3 images.
if (fragmentReference != null) {
final SubjectFragment fragment = fragmentReference.get();
final ItemFragment fragment = fragmentReference.get();
if (fragment != null) {
fragment.abandonItem();
}
Expand Down Expand Up @@ -301,7 +301,7 @@ private void showImage() {
}

if (!TextUtils.isEmpty(imageUriStr)) {
final ShowImageTask task = new ShowImageTask(mImageView, this);
final ShowImageFromContentProviderTask task = new ShowImageFromContentProviderTask(mImageView, this);
task.execute(imageUriStr);
}
}
Expand Down

0 comments on commit 9edc930

Please sign in to comment.