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
17package com.android.camera.data;
18
19import android.content.Context;
20import android.graphics.drawable.Drawable;
21import android.net.Uri;
22import android.os.Bundle;
23import android.view.View;
24
25import com.android.camera.debug.Log;
26import com.android.camera.filmstrip.ImageData;
27
28import java.util.UUID;
29
30/**
31 * A LocalData that does nothing but only shows a view.
32 */
33public class SimpleViewData implements LocalData {
34    private static final Log.Tag TAG = new Log.Tag("SimpleViewData");
35    private static final String SIMPLE_VIEW_URI_SCHEME = "simple_view_data";
36
37    private final int mWidth;
38    private final int mHeight;
39    private final View mView;
40    private final long mDateTaken;
41    private final long mDateModified;
42    private final Bundle mMetaData;
43    private final Uri mUri;
44    private final LocalDataViewType mItemViewType;
45
46    public SimpleViewData(
47            View v, LocalDataViewType viewType, int width, int height,
48            int dateTaken, int dateModified) {
49        mView = v;
50        mItemViewType = viewType;
51        mWidth = width;
52        mHeight = height;
53        mDateTaken = dateTaken;
54        mDateModified = dateModified;
55        mMetaData = new Bundle();
56        Uri.Builder builder = new Uri.Builder();
57        String uuid = UUID.randomUUID().toString();
58        builder.scheme(SIMPLE_VIEW_URI_SCHEME).appendPath(uuid);
59        mUri = builder.build();
60    }
61
62    @Override
63    public long getDateTaken() {
64        return mDateTaken;
65    }
66
67    @Override
68    public long getDateModified() {
69        return mDateModified;
70    }
71
72    @Override
73    public String getTitle() {
74        return "";
75    }
76
77    @Override
78    public int getWidth() {
79        return mWidth;
80    }
81
82    @Override
83    public int getHeight() {
84        return mHeight;
85    }
86
87    @Override
88    public int getRotation() {
89        return 0;
90    }
91
92    @Override
93    public int getViewType() {
94        return ImageData.VIEW_TYPE_REMOVABLE;
95    }
96
97    @Override
98    public LocalDataViewType getItemViewType() {
99        return mItemViewType;
100    }
101
102    @Override
103    public String getPath() {
104        return "";
105    }
106
107    @Override
108    public Uri getUri() {
109        return mUri;
110    }
111
112    @Override
113    public int getLocalDataType() {
114        return LOCAL_VIEW;
115    }
116
117    @Override
118    public LocalData refresh(Context context) {
119        return this;
120    }
121
122    @Override
123    public boolean isUIActionSupported(int action) {
124        return false;
125    }
126
127    @Override
128    public boolean isDataActionSupported(int action) {
129        return false;
130    }
131
132    @Override
133    public boolean delete(Context c) {
134        return false;
135    }
136
137    @Override
138    public View getView(Context context, View recycled, int width, int height, int placeHolderResourceId,
139            LocalDataAdapter adapter, boolean isInProgressSession) {
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