Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d11536f authored by Angus Kong's avatar Angus Kong
Browse files

Load the FilmStrip data in onCreate()

The loading should be done in onCreate() so it won't waste time loading the data
which has been loaded everytime the app is brought to the foreground.

bug:10189998
Change-Id: I5b9158b206f96b065f6f18a5ab7da3ca14b9e52a
parent 51ccfbc9
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ public class CameraActivity extends Activity
        mCameraPreviewData = new CameraPreviewData(rootLayout,
                FilmStripView.ImageData.SIZE_FULL,
                FilmStripView.ImageData.SIZE_FULL);
        // Put a CameraPreviewData at the first position.
        mWrappedDataAdapter = new FixedFirstDataAdapter(
                new CameraDataAdapter(new ColorDrawable(
                        getResources().getColor(R.color.photo_placeholder))),
@@ -296,6 +297,25 @@ public class CameraActivity extends Activity
        mOrientationListener = new MyOrientationEventListener(this);
        mMainHandler = new Handler(getMainLooper());
        bindMediaSaveService();

        if (!mSecureCamera) {
            mDataAdapter = mWrappedDataAdapter;
            mDataAdapter.requestLoad(getContentResolver());
        } else {
            // Put a lock placeholder as the last image by setting its date to 0.
            ImageView v = (ImageView) getLayoutInflater().inflate(
                    R.layout.secure_album_placeholder, null);
            mDataAdapter = new FixedLastDataAdapter(
                    mWrappedDataAdapter,
                    new LocalData.LocalViewData(
                            v,
                            v.getDrawable().getIntrinsicWidth(),
                            v.getDrawable().getIntrinsicHeight(),
                            0, 0));
            // Flush out all the original data.
            mDataAdapter.flush();
        }
        mFilmStripView.setDataAdapter(mDataAdapter);
    }

    private void setRotationAnimation() {
@@ -343,25 +363,6 @@ public class CameraActivity extends Activity
    public void onStart() {
        super.onStart();

        // The loading is done in background and will update the filmstrip later.
        if (!mSecureCamera) {
            mDataAdapter = mWrappedDataAdapter;
            mDataAdapter.requestLoad(getContentResolver());
            mFilmStripView.setDataAdapter(mDataAdapter);
        } else {
            // Put a lock placeholder as the last image by setting its date to 0.
            ImageView v = (ImageView) getLayoutInflater().inflate(
                    R.layout.secure_album_placeholder, null);
            mDataAdapter = new FixedLastDataAdapter(
                    mWrappedDataAdapter,
                    new LocalData.LocalViewData(
                            v,
                            v.getDrawable().getIntrinsicWidth(),
                            v.getDrawable().getIntrinsicHeight(),
                            0, 0));
            // Flush out all the original data.
            mDataAdapter.flush();
        }
        mPanoramaViewHelper.onStart();
    }