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 android.content.Context;
     20 import android.net.Uri;
     21 import android.os.Bundle;
     22 import android.view.View;
     23 
     24 import com.android.camera.debug.Log;
     25 import com.android.camera.filmstrip.ImageData;
     26 
     27 import java.util.UUID;
     28 
     29 /**
     30  * A LocalData that does nothing but only shows a view.
     31  */
     32 public class SimpleViewData implements LocalData {
     33     private static final Log.Tag TAG = new Log.Tag("SimpleViewData");
     34     private static final String SIMPLE_VIEW_URI_SCHEME = "simple_view_data";
     35 
     36     private final int mWidth;
     37     private final int mHeight;
     38     private final View mView;
     39     private final long mDateTaken;
     40     private final long mDateModified;
     41     private final Bundle mMetaData;
     42     private final Uri mUri;
     43     private final LocalDataViewType mItemViewType;
     44 
     45     public SimpleViewData(
     46             View v, LocalDataViewType viewType, int width, int height,
     47             int dateTaken, int dateModified) {
     48         mView = v;
     49         mItemViewType = viewType;
     50         mWidth = width;
     51         mHeight = height;
     52         mDateTaken = dateTaken;
     53         mDateModified = dateModified;
     54         mMetaData = new Bundle();
     55         Uri.Builder builder = new Uri.Builder();
     56         String uuid = UUID.randomUUID().toString();
     57         builder.scheme(SIMPLE_VIEW_URI_SCHEME).appendPath(uuid);
     58         mUri = builder.build();
     59     }
     60 
     61     @Override
     62     public long getDateTaken() {
     63         return mDateTaken;
     64     }
     65 
     66     @Override
     67     public long getDateModified() {
     68         return mDateModified;
     69     }
     70 
     71     @Override
     72     public String getTitle() {
     73         return "";
     74     }
     75 
     76     @Override
     77     public int getWidth() {
     78         return mWidth;
     79     }
     80 
     81     @Override
     82     public int getHeight() {
     83         return mHeight;
     84     }
     85 
     86     @Override
     87     public int getRotation() {
     88         return 0;
     89     }
     90 
     91     @Override
     92     public int getViewType() {
     93         return ImageData.VIEW_TYPE_REMOVABLE;
     94     }
     95 
     96     @Override
     97     public LocalDataViewType getItemViewType() {
     98         return mItemViewType;
     99     }
    100 
    101     @Override
    102     public String getPath() {
    103         return "";
    104     }
    105 
    106     @Override
    107     public Uri getUri() {
    108         return mUri;
    109     }
    110 
    111     @Override
    112     public int getLocalDataType() {
    113         return LOCAL_VIEW;
    114     }
    115 
    116     @Override
    117     public LocalData refresh(Context context) {
    118         return this;
    119     }
    120 
    121     @Override
    122     public boolean isUIActionSupported(int action) {
    123         return false;
    124     }
    125 
    126     @Override
    127     public boolean isDataActionSupported(int action) {
    128         return false;
    129     }
    130 
    131     @Override
    132     public boolean delete(Context c) {
    133         return false;
    134     }
    135 
    136     @Override
    137     public View getView(Context context, View recycled, int width, int height,
    138             int placeHolderResourceId, LocalDataAdapter adapter, boolean isInProgressSession,
    139             ActionCallback actionCallback) {
    140         return mView;
    141     }
    142 
    143     @Override
    144     public void loadFullImage(Context context, int w, int h, View view, LocalDataAdapter adapter) {
    145         // do nothing.
    146     }
    147 
    148     @Override
    149     public void prepare() {
    150         // do nothing.
    151     }
    152 
    153     @Override
    154     public void recycle(View view) {
    155         // Do nothing.
    156     }
    157 
    158     @Override
    159     public void onFullScreen(boolean fullScreen) {
    160         // do nothing.
    161     }
    162 
    163     @Override
    164     public boolean canSwipeInFullScreen() {
    165         return true;
    166     }
    167 
    168     @Override
    169     public MediaDetails getMediaDetails(Context context) {
    170         return null;
    171     }
    172 
    173     @Override
    174     public double[] getLatLong() {
    175         return null;
    176     }
    177 
    178     @Override
    179     public String getMimeType() {
    180         return null;
    181     }
    182 
    183     @Override
    184     public long getSizeInBytes() {
    185         return 0;
    186     }
    187 
    188     @Override
    189     public long getContentId() {
    190         return -1;
    191     }
    192 
    193     @Override
    194     public Bundle getMetadata() {
    195         return mMetaData;
    196     }
    197 
    198     @Override
    199     public String getSignature() {
    200         return "";
    201     }
    202 
    203     @Override
    204     public boolean isMetadataUpdated() {
    205         return true;
    206     }
    207 }
    208