aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/ruesga/android/wallpapers/photophase/TextureManager.java')
-rw-r--r--src/com/ruesga/android/wallpapers/photophase/TextureManager.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/ruesga/android/wallpapers/photophase/TextureManager.java b/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
index 033ca6c..a21051a 100644
--- a/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
+++ b/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
@@ -24,6 +24,7 @@ import android.media.ThumbnailUtils;
import android.media.effect.Effect;
import android.media.effect.EffectContext;
import android.opengl.GLES20;
+import android.os.Handler;
import android.util.Log;
import android.widget.Toast;
@@ -50,12 +51,13 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
private static final int QUEUE_SIZE = 3;
final Context mContext;
+ final Handler mHandler;
final Effects mEffects;
final Object mSync;
final List<TextureRequestor> mPendingRequests;
final FixedQueue<GLESTextureInfo> mQueue = new FixedQueue<GLESTextureInfo>(QUEUE_SIZE);
BackgroundPictureLoaderThread mBackgroundTask;
- private final MediaPictureDiscoverer mPictureDiscoverer;
+ /*protected*/ final MediaPictureDiscoverer mPictureDiscoverer;
/*package*/ Rect mScreenDimensions;
/*package*/ Rect mDimensions;
@@ -138,10 +140,11 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
* @param requestors The number of requestors
* @param screenDimensions The screen dimensions
*/
- public TextureManager(final Context ctx, final EffectContext effectCtx,
+ public TextureManager(final Context ctx, final Handler handler, final EffectContext effectCtx,
GLESSurfaceDispatcher dispatcher, int requestors, Rect screenDimensions) {
super();
mContext = ctx;
+ mHandler = handler;
mEffects = new Effects(effectCtx);
mDispatcher = dispatcher;
mScreenDimensions = screenDimensions;
@@ -202,10 +205,18 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
*
* @param userRequest If the request was generated by the user
*/
- void reloadMedia(boolean userRequest) {
+ void reloadMedia(final boolean userRequest) {
Log.d(TAG, "Reload media picture data");
// Discovery new media
- mPictureDiscoverer.discover(userRequest);
+ // GLThread doesn't run in the UI thread and AsyncThread can't create a
+ // valid handler in ICS (it's fixed in JB+) so we force to run the async
+ // thread in a valid UI thread
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mPictureDiscoverer.discover(userRequest);
+ }
+ });
}
/**