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

Commit a53b13e4 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa Committed by Android (Google) Code Review
Browse files

Merge "Stop showing default thumbnail in photo manager"

parents 2e1fb570 f5be9baf
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -86,26 +86,22 @@
                    android:id="@+id/icon_1"
                    android:layout_width="@dimen/group_list_icon_size"
                    android:layout_height="@dimen/group_list_icon_size"
                    android:layout_marginRight="1dip"
                    android:src="@drawable/ic_contact_picture" />
                    android:layout_marginRight="1dip" />
                <ImageView
                    android:id="@+id/icon_2"
                    android:layout_width="@dimen/group_list_icon_size"
                    android:layout_height="@dimen/group_list_icon_size"
                    android:src="@drawable/ic_contact_picture" />
                    android:layout_height="@dimen/group_list_icon_size" />
            </TableRow>
            <TableRow>
                <ImageView
                    android:id="@+id/icon_3"
                    android:layout_width="@dimen/group_list_icon_size"
                    android:layout_height="@dimen/group_list_icon_size"
                    android:layout_marginRight="1dip"
                    android:src="@drawable/ic_contact_picture" />
                    android:layout_marginRight="1dip" />
                <ImageView
                    android:id="@+id/icon_4"
                    android:layout_width="@dimen/group_list_icon_size"
                    android:layout_height="@dimen/group_list_icon_size"
                    android:src="@drawable/ic_contact_picture" />
                    android:layout_height="@dimen/group_list_icon_size" />
            </TableRow>

        </TableLayout>
+12 −0
Original line number Diff line number Diff line
@@ -96,6 +96,12 @@ public abstract class ContactPhotoManager {
     */
    public abstract void loadPhoto(ImageView view, Uri photoUri);

    /**
     * Remove photo from the supplied image view. This also cancels current pending load request
     * inside this photo manager.
     */
    public abstract void removePhoto(ImageView view);

    /**
     * Temporarily stops loading photos from the database.
     */
@@ -260,6 +266,12 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
        }
    }

    @Override
    public void removePhoto(ImageView view) {
        view.setImageDrawable(null);
        mPendingRequests.remove(view);
    }

    @Override
    public void refreshCache() {
        for (BitmapHolder holder : mBitmapHolderCache.snapshot().values()) {
+11 −5
Original line number Diff line number Diff line
@@ -153,8 +153,11 @@ public class GroupBrowseListAdapter extends BaseAdapter {
            if (currentGroupId == mGroupId) {
                final ImageView[] children = getIconViewsSordedByFillOrder(icons);
                for (int i = 0; i < children.length; i++) {
                    final long photoId = i < photoIds.size() ? photoIds.get(i) : 0;
                    mContactPhotoManager.loadPhoto(children[i], photoId);
                    if (i < photoIds.size()) {
                        mContactPhotoManager.loadPhoto(children[i], photoIds.get(i));
                    } else {
                        mContactPhotoManager.removePhoto(children[i]);
                    }
                }
            }
        }
@@ -318,13 +321,16 @@ public class GroupBrowseListAdapter extends BaseAdapter {
        if (photoIds != null) {
            // Cache is available. Let the photo manager load those IDs.
            for (int i = 0; i < children.length; i++) {
                final long photoId = i < photoIds.size() ? photoIds.get(i) : 0;
                mContactPhotoManager.loadPhoto(children[i], photoId);
                if (i < photoIds.size()) {
                    mContactPhotoManager.loadPhoto(children[i], photoIds.get(i));
                } else {
                    mContactPhotoManager.removePhoto(children[i]);
                }
            }
        } else {
            // Cache is not available. Load photo IDs asynchronously.
            for (ImageView child : children) {
                mContactPhotoManager.loadPhoto(child, 0);
                mContactPhotoManager.removePhoto(child);
            }
            new AsyncPhotoIdLoadTask().execute(
                    new AsyncPhotoIdLoadArg(icons, entry.getGroupId(),
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ public class MockContactPhotoManager extends ContactPhotoManager {
        view.setImageResource(mDefaultResourceId);
    }

    @Override
    public void removePhoto(ImageView view) {
        view.setImageDrawable(null);
    }

    @Override
    public void pause() {
    }