• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.graphics.Bitmap;
20 import android.net.Uri;
21 import android.view.View;
22 
23 import com.android.camera.debug.Log;
24 import com.android.camera.util.Size;
25 import com.google.common.base.Optional;
26 
27 import java.util.Date;
28 import java.util.UUID;
29 
30 import javax.annotation.Nonnull;
31 
32 /**
33  * A LocalData that does nothing but only shows a view.
34  */
35 public class PlaceholderItem implements FilmstripItem {
36     private static final Log.Tag TAG = new Log.Tag("PlaceholderItem");
37     private static final String SIMPLE_VIEW_URI_SCHEME = "simple_view_data";
38 
39     private static final FilmstripItemAttributes PLACEHOLDER_ITEM_ATTRIBUTES =
40           new FilmstripItemAttributes.Builder()
41                 .build();
42 
43     private final View mView;
44     private final Metadata mMetaData;
45     private final FilmstripItemType mItemViewType;
46     private final FilmstripItemData mItemData;
47     private final FilmstripItemAttributes mAttributes;
48 
PlaceholderItem( View v, FilmstripItemType viewType, int width, int height)49     public PlaceholderItem(
50           View v, FilmstripItemType viewType, int width, int height) {
51         mView = v;
52         mItemViewType = viewType;
53         Size dimensions = new Size(width, height);
54         Date creationDate = new Date(0);
55         Date lastModifiedDate = new Date(0);
56         mMetaData = new Metadata();
57         mMetaData.setLoaded(true);
58         Uri.Builder builder = new Uri.Builder();
59         String uuid = UUID.randomUUID().toString();
60         builder.scheme(SIMPLE_VIEW_URI_SCHEME).appendPath(uuid);
61         Uri uri = builder.build();
62 
63         mItemData = new FilmstripItemData(
64               -1,
65               uuid,
66               "",
67               creationDate,
68               lastModifiedDate,
69               "" /* path */,
70               uri,
71               dimensions,
72               0,
73               0,
74               Location.UNKNOWN);
75 
76         mAttributes = PLACEHOLDER_ITEM_ATTRIBUTES;
77     }
78 
79     @Override
getData()80     public FilmstripItemData getData() {
81         return mItemData;
82     }
83 
84     @Override
getAttributes()85     public FilmstripItemAttributes getAttributes() {
86         return mAttributes;
87     }
88 
89     @Override
getItemViewType()90     public FilmstripItemType getItemViewType() {
91         return mItemViewType;
92     }
93 
94     @Override
refresh()95     public FilmstripItem refresh() {
96         return this;
97     }
98 
99     @Override
delete()100     public boolean delete() {
101         return false;
102     }
103 
104     @Override
getView(Optional<View> optionalView, LocalFilmstripDataAdapter adapter, boolean isInProgress, VideoClickedCallback videoClickedCallback)105     public View getView(Optional<View> optionalView,
106           LocalFilmstripDataAdapter adapter, boolean isInProgress,
107           VideoClickedCallback videoClickedCallback) {
108         return mView;
109     }
110 
111     @Override
setSuggestedSize(int widthPx, int heightPx)112     public void setSuggestedSize(int widthPx, int heightPx) { }
113 
114     @Override
renderTiny(@onnull View view)115     public void renderTiny(@Nonnull View view) { }
116 
117     @Override
renderThumbnail(@onnull View view)118     public void renderThumbnail(@Nonnull View view) { }
119 
120     @Override
renderFullRes(@onnull View view)121     public void renderFullRes(@Nonnull View view) { }
122 
123     @Override
recycle(@onnull View view)124     public void recycle(@Nonnull View view) {
125         // Do nothing.
126     }
127 
128     @Override
getMediaDetails()129     public Optional<MediaDetails> getMediaDetails() {
130         return Optional.absent();
131     }
132 
133     @Override
getMetadata()134     public Metadata getMetadata() {
135         return mMetaData;
136     }
137 
138     @Override
generateThumbnail(int boundingWidthPx, int boundingHeightPx)139     public Optional<Bitmap> generateThumbnail(int boundingWidthPx, int boundingHeightPx) {
140         return Optional.absent();
141     }
142 
143     @Override
getDimensions()144     public Size getDimensions() {
145         return mItemData.getDimensions();
146     }
147 
148     @Override
getOrientation()149     public int getOrientation() {
150         return mItemData.getOrientation();
151     }
152 }
153