Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2013 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.camera.data;
     18 
     19 import java.util.EnumSet;
     20 
     21 /**
     22  * Represents an immutable set of item attributes
     23  */
     24 public class FilmstripItemAttributes {
     25     public enum Attributes {
     26         HAS_DETAILED_CAPTURE_INFO,
     27         CAN_SHARE,
     28         CAN_EDIT,
     29         CAN_DELETE,
     30         CAN_PLAY,
     31         CAN_OPEN_VIEWER,
     32         CAN_SWIPE_AWAY,
     33         CAN_ZOOM_IN_PLACE,
     34         IS_RENDERING,
     35         IS_IMAGE,
     36         IS_VIDEO,
     37     }
     38 
     39     private final EnumSet<Attributes> mAttributes;
     40 
     41     public static final FilmstripItemAttributes DEFAULT =
     42           new Builder().build();
     43 
     44     private FilmstripItemAttributes(EnumSet<Attributes> attributes) {
     45        mAttributes = attributes;
     46     }
     47 
     48     public boolean hasDetailedCaptureInfo() {
     49         return mAttributes.contains(Attributes.HAS_DETAILED_CAPTURE_INFO);
     50     }
     51 
     52     // TODO: Replace this with a command.
     53     public boolean canShare() {
     54         return mAttributes.contains(Attributes.CAN_SHARE);
     55     }
     56 
     57     // TODO: Replace this with a command.
     58     public boolean canEdit() {
     59         return mAttributes.contains(Attributes.CAN_EDIT);
     60     }
     61 
     62     // TODO: Replace this with a command.
     63     public boolean canDelete() {
     64         return mAttributes.contains(Attributes.CAN_DELETE);
     65     }
     66 
     67     public boolean canSwipeAway() {
     68         return mAttributes.contains(Attributes.CAN_SWIPE_AWAY);
     69     }
     70 
     71     public boolean canZoomInPlace() {
     72         return mAttributes.contains(Attributes.CAN_ZOOM_IN_PLACE);
     73     }
     74 
     75     public boolean isRendering() {
     76         return mAttributes.contains(Attributes.IS_RENDERING);
     77     }
     78 
     79     // TODO: Consider replacing video / image with an enum.
     80     public boolean isImage() {
     81         return mAttributes.contains(Attributes.IS_IMAGE);
     82     }
     83 
     84     public boolean isVideo() {
     85         return mAttributes.contains(Attributes.IS_VIDEO);
     86     }
     87 
     88     /**
     89      * Builder for {@code FilmstripItemAttributes}.
     90      */
     91     public static class Builder {
     92         EnumSet<Attributes> mAttributes = EnumSet.noneOf(Attributes.class);
     93         public Builder with(Attributes attribute) {
     94             mAttributes.add(attribute);
     95             return this;
     96         }
     97 
     98         public FilmstripItemAttributes build() {
     99             return new FilmstripItemAttributes(EnumSet.copyOf(mAttributes));
    100         }
    101     }
    102 }