diff options
author | Steve Kondik <steve@cyngn.com> | 2015-10-17 23:40:33 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-17 23:40:33 -0700 |
commit | bcbf7c98a521b9ee4a7d03e00dcfc469c9b3a398 (patch) | |
tree | 85d07b2095695fe79235ab16e627f8b22c7bfd8d /src/com/android/gallery3d/app/AbstractGalleryActivity.java | |
parent | a3fcd50080c0546ebd5f0caf932eef02fabdd7ad (diff) | |
parent | 8de528917bf03cca93ac2a3dd19b7a5719d1a26e (diff) | |
download | android_packages_apps_Gallery2-bcbf7c98a521b9ee4a7d03e00dcfc469c9b3a398.tar.gz android_packages_apps_Gallery2-bcbf7c98a521b9ee4a7d03e00dcfc469c9b3a398.tar.bz2 android_packages_apps_Gallery2-bcbf7c98a521b9ee4a7d03e00dcfc469c9b3a398.zip |
Merge branch 'cm-12.1' of git://github.com/CyanogenMod/android_packages_apps_Gallery2 into cm-13.0
Change-Id: Ib8caa024d2e6feca332e3645038f226fd5a910a2
Diffstat (limited to 'src/com/android/gallery3d/app/AbstractGalleryActivity.java')
-rw-r--r-- | src/com/android/gallery3d/app/AbstractGalleryActivity.java | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 9af1fb8ba..9f43b8de4 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -28,15 +28,20 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.os.IBinder; +import android.os.storage.StorageManager; +import android.preference.PreferenceManager; import android.support.v4.print.PrintHelper; import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; +import android.os.Handler; import com.android.gallery3d.R; import com.android.gallery3d.common.ApiHelper; @@ -45,6 +50,7 @@ import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLRootView; +import com.android.gallery3d.util.MediaSetUtils; import com.android.gallery3d.util.PanoramaViewHelper; import com.android.gallery3d.util.ThreadPool; import com.android.photos.data.GalleryBitmapPool; @@ -60,6 +66,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext private TransitionStore mTransitionStore = new TransitionStore(); private boolean mDisableToggleStatusBar; private PanoramaViewHelper mPanoramaViewHelper; + private static final int ONRESUME_DELAY = 50; private AlertDialog mAlertDialog = null; private BroadcastReceiver mMountReceiver = new BroadcastReceiver() { @@ -73,6 +80,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setStoragePath(); mOrientationManager = new OrientationManager(this); toggleStatusBarByOrientation(); getWindow().setBackgroundDrawable(null); @@ -81,6 +89,21 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext doBindBatchService(); } + private void setStoragePath() { + final String defaultStoragePath = Environment.getExternalStorageDirectory().toString(); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + String storagePath = prefs.getString(StorageChangeReceiver.KEY_STORAGE, + defaultStoragePath); + + // Check if volume is mounted + StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); + if (!sm.getVolumeState(storagePath).equals(Environment.MEDIA_MOUNTED)) { + storagePath = defaultStoragePath; + } + + MediaSetUtils.setRoot(storagePath); + } + @Override protected void onSaveInstanceState(Bundle outState) { mGLRootView.lockRenderThread(); @@ -133,6 +156,15 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext return mGLRootView; } + public void GLRootResume(boolean isResume) { + if (isResume) { + mGLRootView.onResume(); + mGLRootView.lockRenderThread(); + } else { + mGLRootView.unlockRenderThread(); + } + } + public OrientationManager getOrientationManager() { return mOrientationManager; } @@ -203,15 +235,31 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext @Override protected void onResume() { super.onResume(); - mGLRootView.lockRenderThread(); - try { - getStateManager().resume(); - getDataManager().resume(); - } finally { - mGLRootView.unlockRenderThread(); - } - mGLRootView.onResume(); - mOrientationManager.resume(); + delayedOnResume(ONRESUME_DELAY); + } + + private void delayedOnResume(final int delay){ + final Handler handler = new Handler(); + Runnable delayTask = new Runnable() { + @Override + public void run() { + handler.postDelayed(new Runnable() { + @Override + public void run() { + mGLRootView.lockRenderThread(); + try { + getStateManager().resume(); + getDataManager().resume(); + } finally { + mGLRootView.unlockRenderThread(); + } + mGLRootView.onResume(); + mOrientationManager.resume(); + }}, delay); + } + }; + Thread delayThread = new Thread(delayTask); + delayThread.start(); } @Override |