1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 package com.android.gallery3d.data;
18 
19 import java.util.ArrayList;
20 
21 public class SingleItemAlbum extends MediaSet {
22     @SuppressWarnings("unused")
23     private static final String TAG = "SingleItemAlbum";
24     private final MediaItem mItem;
25     private final String mName;
26 
SingleItemAlbum(Path path, MediaItem item)27     public SingleItemAlbum(Path path, MediaItem item) {
28         super(path, nextVersionNumber());
29         mItem =  item;
30         mName = "SingleItemAlbum("+mItem.getClass().getSimpleName()+")";
31     }
32 
33     @Override
getMediaItemCount()34     public int getMediaItemCount() {
35         return 1;
36     }
37 
38     @Override
getMediaItem(int start, int count)39     public ArrayList<MediaItem> getMediaItem(int start, int count) {
40         ArrayList<MediaItem> result = new ArrayList<MediaItem>();
41 
42         // If [start, start+count) contains the index 0, return the item.
43         if (start <= 0 && start + count > 0) {
44             result.add(mItem);
45         }
46 
47         return result;
48     }
49 
getItem()50     public MediaItem getItem() {
51         return mItem;
52     }
53 
54     @Override
isLeafAlbum()55     public boolean isLeafAlbum() {
56         return true;
57     }
58 
59     @Override
getName()60     public String getName() {
61         return mName;
62     }
63 
64     @Override
reload()65     public long reload() {
66         return mDataVersion;
67     }
68 }
69