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

Commit 614255bc authored by Roman Birg's avatar Roman Birg Committed by Adnan Begovic
Browse files

WallpaperCropper: load wallpapers in the background



Change-Id: I134d94a85f25bf5db4c15fa9a89265c53e5b0c1d
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent f523fdec
Loading
Loading
Loading
Loading
+33 −12
Original line number Diff line number Diff line
@@ -875,20 +875,41 @@ public class LockWallpaperPickerActivity extends WallpaperCropActivity {
        setWallpaperItemPaddingToZero(clearImageTile);
        masterWallpaperList.addView(clearImageTile, 0);

        // theme LOCKSCREEN wallpapers
        ArrayList<ThemeLockWallpaperInfo> themeLockWallpapers = findThemeLockWallpapers();
        ThemeLockWallpapersAdapter tla = new ThemeLockWallpapersAdapter(this, themeLockWallpapers);
        populateWallpapersFromAdapter(mWallpapersView, tla, false, true);

        // theme wallpapers
        ArrayList<ThemeWallpaperInfo> themeWallpapers = findThemeWallpapers();
        ThemeWallpapersAdapter ta = new ThemeWallpapersAdapter(this, themeWallpapers);
        populateWallpapersFromAdapter(mWallpapersView, ta, false, true);

        // Populate the saved wallpapers
        mSavedImages = new SavedWallpaperImages(this);
        mSavedImages.loadThumbnailsAndImageIdList();
        populateWallpapersFromAdapter(mWallpapersView, mSavedImages, true, true);
        populateWallpapersFromAdapter(mWallpapersView, mSavedImages, true, false);

        // populate lockscreen wallpapers
        new AsyncTask<Void, Void, ArrayList<ThemeLockWallpaperInfo>>() {
            @Override
            protected ArrayList<ThemeLockWallpaperInfo> doInBackground(Void... params) {
                return findThemeLockWallpapers();
            }

            @Override
            protected void onPostExecute(ArrayList<ThemeLockWallpaperInfo>
                                                 themeLockWallpaperInfos) {
                ThemeLockWallpapersAdapter tla = new ThemeLockWallpapersAdapter(
                        LockWallpaperPickerActivity.this, themeLockWallpaperInfos);
                populateWallpapersFromAdapter(mWallpapersView, tla, false, true);
            }
        }.execute((Void) null);

        // populate wallpapers
        new AsyncTask<Void, Void, ArrayList<ThemeWallpaperInfo>>() {
            @Override
            protected ArrayList<ThemeWallpaperInfo> doInBackground(Void... params) {
                return findThemeWallpapers();
            }

            @Override
            protected void onPostExecute(ArrayList<ThemeWallpaperInfo> themeWallpaperInfos) {
                ThemeWallpapersAdapter ta = new ThemeWallpapersAdapter(
                        LockWallpaperPickerActivity.this, themeWallpaperInfos);
                populateWallpapersFromAdapter(mWallpapersView, ta, false, false);
            }
        }.execute((Void) null);

        // Make its background the last photo taken on external storage
        Bitmap lastPhoto = getThumbnailOfLastPhoto();
@@ -1103,7 +1124,7 @@ public class LockWallpaperPickerActivity extends WallpaperCropActivity {
            boolean addLongPressHandler, boolean selectFirstTile) {
        for (int i = 0; i < adapter.getCount(); i++) {
            FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
            parent.addView(thumbnail, i);
            parent.addView(thumbnail);
            WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
            thumbnail.setTag(info);
            info.setView(thumbnail);
+18 −6
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LevelListDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.ThemesContract;
@@ -286,21 +287,32 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
            }
        };

        mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);

        // Populate the built-in wallpapers
        ArrayList<ResourceWallpaperInfo> wallpapers = findBundledWallpapers();
        mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);
        BuiltInWallpapersAdapter ia = new BuiltInWallpapersAdapter(this, wallpapers);
        populateWallpapersFromAdapter(mWallpapersView, ia, false, true);

        // Populate the saved wallpapers
        mSavedImages = new SavedWallpaperImages(this);
        mSavedImages.loadThumbnailsAndImageIdList();
        populateWallpapersFromAdapter(mWallpapersView, mSavedImages, true, true);
        populateWallpapersFromAdapter(mWallpapersView, mSavedImages, true, false);

        // theme wallpapers
        ArrayList<ThemeWallpaperInfo> themeWallpapers = findThemeWallpapers();
        ThemeWallpapersAdapter twa = new ThemeWallpapersAdapter(this, themeWallpapers);
        populateWallpapersFromAdapter(mWallpapersView, twa, false, false);
        new AsyncTask<Void, Void, ArrayList<ThemeWallpaperInfo>>() {
            @Override
            protected ArrayList<ThemeWallpaperInfo> doInBackground(Void... params) {
                return findThemeWallpapers();
            }

            @Override
            protected void onPostExecute(ArrayList<ThemeWallpaperInfo> themeWallpaperInfos) {
                ThemeWallpapersAdapter ta = new ThemeWallpapersAdapter(
                        WallpaperPickerActivity.this, themeWallpaperInfos);
                populateWallpapersFromAdapter(mWallpapersView, ta, false, false);
            }
        }.execute((Void) null);

        // Populate the live wallpapers
        final LinearLayout liveWallpapersView =
@@ -512,7 +524,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
            boolean addLongPressHandler, boolean selectFirstTile) {
        for (int i = 0; i < adapter.getCount(); i++) {
            FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
            parent.addView(thumbnail, i);
            parent.addView(thumbnail);
            WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
            thumbnail.setTag(info);
            info.setView(thumbnail);