MediaSetUtils.java revision 0addfc7f6342184a67cdd8b5cc3872c6a5c87e55
1/* 2 * Copyright (C) 2010 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 17package com.android.gallery3d.util; 18 19import android.os.Environment; 20 21import com.android.gallery3d.data.LocalAlbum; 22import com.android.gallery3d.data.LocalMergeAlbum; 23import com.android.gallery3d.data.MediaSet; 24import com.android.gallery3d.data.Path; 25 26import java.util.Comparator; 27 28public class MediaSetUtils { 29 public static final Comparator<MediaSet> NAME_COMPARATOR = new NameComparator(); 30 31 public static final int CAMERA_BUCKET_ID = GalleryUtils.getBucketId( 32 Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera"); 33 public static final int DOWNLOAD_BUCKET_ID = GalleryUtils.getBucketId( 34 Environment.getExternalStorageDirectory().toString() + "/" 35 + BucketNames.DOWNLOAD); 36 public static final int EDITED_ONLINE_PHOTOS_BUCKET_ID = GalleryUtils.getBucketId( 37 Environment.getExternalStorageDirectory().toString() + "/" 38 + BucketNames.EDITED_ONLINE_PHOTOS); 39 public static final int IMPORTED_BUCKET_ID = GalleryUtils.getBucketId( 40 Environment.getExternalStorageDirectory().toString() + "/" 41 + BucketNames.IMPORTED); 42 public static final int SNAPSHOT_BUCKET_ID = GalleryUtils.getBucketId( 43 Environment.getExternalStorageDirectory().toString() + 44 "/Pictures/Screenshots"); 45 46 private static final Path[] CAMERA_PATHS = { 47 Path.fromString("/local/all/" + CAMERA_BUCKET_ID), 48 Path.fromString("/local/image/" + CAMERA_BUCKET_ID), 49 Path.fromString("/local/video/" + CAMERA_BUCKET_ID)}; 50 51 public static boolean isCameraSource(Path path) { 52 return CAMERA_PATHS[0] == path || CAMERA_PATHS[1] == path 53 || CAMERA_PATHS[2] == path; 54 } 55 56 // Sort MediaSets by name 57 public static class NameComparator implements Comparator<MediaSet> { 58 @Override 59 public int compare(MediaSet set1, MediaSet set2) { 60 int result = set1.getName().compareToIgnoreCase(set2.getName()); 61 if (result != 0) return result; 62 return set1.getPath().toString().compareTo(set2.getPath().toString()); 63 } 64 } 65} 66