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