Home | History | Annotate | Download | only in data
      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.data;
     18 
     19 import com.android.gallery3d.util.MediaSetUtils;
     20 
     21 public final class DataSourceType {
     22     public static final int TYPE_NOT_CATEGORIZED = 0;
     23     public static final int TYPE_LOCAL = 1;
     24     public static final int TYPE_PICASA = 2;
     25     public static final int TYPE_CAMERA = 3;
     26 
     27     private static final Path PICASA_ROOT = Path.fromString("/picasa");
     28     private static final Path LOCAL_ROOT = Path.fromString("/local");
     29 
     30     public static int identifySourceType(MediaSet set) {
     31         if (set == null) {
     32             return TYPE_NOT_CATEGORIZED;
     33         }
     34 
     35         Path path = set.getPath();
     36         if (MediaSetUtils.isCameraSource(path)) return TYPE_CAMERA;
     37 
     38         Path prefix = path.getPrefixPath();
     39 
     40         if (prefix == PICASA_ROOT) return TYPE_PICASA;
     41         if (prefix == LOCAL_ROOT) return TYPE_LOCAL;
     42 
     43         return TYPE_NOT_CATEGORIZED;
     44     }
     45 }
     46