diff options
author | Bobby Georgescu <georgescu@google.com> | 2012-09-27 16:36:03 -0700 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2012-09-28 00:37:11 -0700 |
commit | 0fa0d96e5e0a8be32066740288ada89e938c33a8 (patch) | |
tree | 570b976ee22fd68450abc8103098d45f3374c46c /src/com/android/gallery3d/data/FilterEmptyPromptSet.java | |
parent | d9b8148210e667c19835460260b8609ac0ad4299 (diff) | |
download | android_packages_apps_Snap-0fa0d96e5e0a8be32066740288ada89e938c33a8.tar.gz android_packages_apps_Snap-0fa0d96e5e0a8be32066740288ada89e938c33a8.tar.bz2 android_packages_apps_Snap-0fa0d96e5e0a8be32066740288ada89e938c33a8.zip |
Show a placeholder when the camera filmstrip is empty
Bug: 7213757
Tapping the placeholder takes the user back to the
full-screen camera capture mode.
Change-Id: I844f789b8e80f34e79f4a9c366c1c244bbf1f2a5
Diffstat (limited to 'src/com/android/gallery3d/data/FilterEmptyPromptSet.java')
-rw-r--r-- | src/com/android/gallery3d/data/FilterEmptyPromptSet.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/data/FilterEmptyPromptSet.java b/src/com/android/gallery3d/data/FilterEmptyPromptSet.java new file mode 100644 index 000000000..b576e06d4 --- /dev/null +++ b/src/com/android/gallery3d/data/FilterEmptyPromptSet.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.gallery3d.data; + +import java.util.ArrayList; + +public class FilterEmptyPromptSet extends MediaSet implements ContentListener { + @SuppressWarnings("unused") + private static final String TAG = "FilterEmptyPromptSet"; + + private ArrayList<MediaItem> mEmptyItem; + private MediaSet mBaseSet; + + public FilterEmptyPromptSet(Path path, MediaSet baseSet, MediaItem emptyItem) { + super(path, INVALID_DATA_VERSION); + mEmptyItem = new ArrayList<MediaItem>(1); + mEmptyItem.add(emptyItem); + mBaseSet = baseSet; + mBaseSet.addContentListener(this); + } + + @Override + public int getMediaItemCount() { + int itemCount = mBaseSet.getMediaItemCount(); + if (itemCount > 0) { + return itemCount; + } else { + return 1; + } + } + + @Override + public ArrayList<MediaItem> getMediaItem(int start, int count) { + int itemCount = mBaseSet.getMediaItemCount(); + if (itemCount > 0) { + return mBaseSet.getMediaItem(start, count); + } else if (start == 0 && count == 1) { + return mEmptyItem; + } else { + throw new ArrayIndexOutOfBoundsException(); + } + } + + @Override + public void onContentDirty() { + notifyContentChanged(); + } + + @Override + public boolean isLeafAlbum() { + return true; + } + + @Override + public boolean isCameraRoll() { + return mBaseSet.isCameraRoll(); + } + + @Override + public long reload() { + return mBaseSet.reload(); + } + + @Override + public String getName() { + return mBaseSet.getName(); + } +} |