call initLoader in a runnable
b/7544801
Apparently, calling initLoader() from inside onLoadFinished()
is no good when using the support library. Now we post a
runnable to the main handler to call initLoader()
Change-Id: Idedfad5f3be0aecc55ca0f3d593c2df96482da77
diff --git a/src/com/android/ex/photo/fragments/PhotoViewFragment.java b/src/com/android/ex/photo/fragments/PhotoViewFragment.java
index 96f175f..da47ac7 100644
--- a/src/com/android/ex/photo/fragments/PhotoViewFragment.java
+++ b/src/com/android/ex/photo/fragments/PhotoViewFragment.java
@@ -23,6 +23,7 @@
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Bundle;
+import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
@@ -282,7 +283,14 @@
} else {
// Received a null result for the full size image. Instead attempt to load the
// thumbnail
- getLoaderManager().initLoader(LOADER_ID_THUMBNAIL, null, this);
+ Handler handler = new Handler();
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ getLoaderManager().initLoader(LOADER_ID_THUMBNAIL, null,
+ PhotoViewFragment.this);
+ }
+ });
}
break;
case LOADER_ID_THUMBNAIL: