2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.gallery3d.data;
19 import com.android.gallery3d.R;
20 import com.android.gallery3d.app.GalleryApp;
21 import com.android.gallery3d.util.Future;
23 // ComboAlbumSet combines multiple media sets into one. It lists all sub
24 // media sets from the input album sets.
25 // This only handles SubMediaSets, not MediaItems. (That's all we need now)
26 public class ComboAlbumSet extends MediaSet implements ContentListener {
27 @SuppressWarnings("unused")
28 private static final String TAG = "ComboAlbumSet";
29 private final MediaSet[] mSets;
30 private final String mName;
32 public ComboAlbumSet(Path path, GalleryApp application, MediaSet[] mediaSets) {
33 super(path, nextVersionNumber());
35 for (MediaSet set : mSets) {
36 set.addContentListener(this);
38 mName = application.getResources().getString(
39 R.string.set_label_all_albums);
43 public MediaSet getSubMediaSet(int index) {
44 for (MediaSet set : mSets) {
45 int size = set.getSubMediaSetCount();
47 return set.getSubMediaSet(index);
55 public int getSubMediaSetCount() {
57 for (MediaSet set : mSets) {
58 count += set.getSubMediaSetCount();
64 public String getName() {
69 public boolean isLoading() {
70 for (int i = 0, n = mSets.length; i < n; ++i) {
71 if (mSets[i].isLoading()) return true;
77 public long reload() {
78 boolean changed = false;
79 for (int i = 0, n = mSets.length; i < n; ++i) {
80 long version = mSets[i].reload();
81 if (version > mDataVersion) changed = true;
83 if (changed) mDataVersion = nextVersionNumber();
88 public void onContentDirty() {
89 notifyContentChanged();
93 public Future<Integer> requestSync(SyncListener listener) {
94 return requestSyncOnMultipleSets(mSets, listener);