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.app.Activity; 20 import android.content.ContentResolver; 21 import android.content.Context; 22 import android.graphics.drawable.Drawable; 23 import android.net.Uri; 24 import android.view.View; 25 import android.widget.FrameLayout; 26 27 import com.android.camera.util.PhotoSphereHelper; 28 import com.android.camera2.R; 29 30 /** 31 * A wrapper class for in-progress data. Data that's still being processed 32 * should not supporting any actions. Only methods related to actions like 33 * {@link #isDataActionSupported(int)} and 34 * {@link #isUIActionSupported(int)} are implemented by this class. 35 */ 36 public class InProgressDataWrapper implements LocalData { 37 38 final LocalData mLocalData; 39 private boolean mHasProgressBar; 40 41 public InProgressDataWrapper(LocalData wrappedData) { 42 mLocalData = wrappedData; 43 } 44 45 public InProgressDataWrapper(LocalData wrappedData, boolean hasProgressBar) { 46 this(wrappedData); 47 mHasProgressBar = hasProgressBar; 48 } 49 50 @Override 51 public View getView( 52 Activity a, int width, int height, 53 Drawable placeHolder, LocalDataAdapter adapter) { 54 View v = mLocalData.getView(a, width, height, placeHolder, adapter); 55 56 if (mHasProgressBar) { 57 // Return a framelayout with the progressbar and imageview. 58 FrameLayout frame = new FrameLayout(a); 59 frame.setLayoutParams(new FrameLayout.LayoutParams(width, height)); 60 frame.addView(v); 61 a.getLayoutInflater() 62 .inflate(R.layout.placeholder_progressbar, frame); 63 return frame; 64 } 65 66 return v; 67 } 68 69 @Override 70 public long getDateTaken() { 71 return mLocalData.getDateTaken(); 72 } 73 74 @Override 75 public long getDateModified() { 76 return mLocalData.getLocalDataType(); 77 } 78 79 @Override 80 public String getTitle() { 81 return mLocalData.getTitle(); 82 } 83 84 @Override 85 public boolean isDataActionSupported(int actions) { 86 return false; 87 } 88 89 @Override 90 public boolean delete(Context c) { 91 // No actions are allowed to modify the wrapped data. 92 return false; 93 } 94 95 @Override 96 public boolean rotate90Degrees( 97 Context context, LocalDataAdapter adapter, 98 int currentDataId, boolean clockwise) { 99 // No actions are allowed to modify the wrapped data. 100 return false; 101 } 102 103 @Override 104 public void onFullScreen(boolean fullScreen) { 105 mLocalData.onFullScreen(fullScreen); 106 } 107 108 @Override 109 public boolean canSwipeInFullScreen() { 110 return mLocalData.canSwipeInFullScreen(); 111 } 112 113 @Override 114 public String getPath() { 115 return mLocalData.getPath(); 116 } 117 118 @Override 119 public String getMimeType() { 120 return mLocalData.getMimeType(); 121 } 122 123 @Override 124 public MediaDetails getMediaDetails(Context context) { 125 return mLocalData.getMediaDetails(context); 126 } 127 128 @Override 129 public int getLocalDataType() { 130 // Force the data type to be in-progress data. 131 return LOCAL_IN_PROGRESS_DATA; 132 } 133 134 @Override 135 public long getSizeInBytes() { 136 return mLocalData.getSizeInBytes(); 137 } 138 139 @Override 140 public LocalData refresh(ContentResolver resolver) { 141 return mLocalData.refresh(resolver); 142 } 143 144 @Override 145 public long getContentId() { 146 return mLocalData.getContentId(); 147 } 148 149 @Override 150 public int getWidth() { 151 return mLocalData.getWidth(); 152 } 153 154 @Override 155 public int getHeight() { 156 return mLocalData.getHeight(); 157 } 158 159 @Override 160 public int getOrientation() { 161 return mLocalData.getOrientation(); 162 } 163 164 @Override 165 public int getViewType() { 166 return mLocalData.getViewType(); 167 } 168 169 @Override 170 public double[] getLatLong() { 171 return mLocalData.getLatLong(); 172 } 173 174 @Override 175 public boolean isUIActionSupported(int action) { 176 return false; 177 } 178 179 @Override 180 public void prepare() { 181 mLocalData.prepare(); 182 } 183 184 @Override 185 public void recycle() { 186 mLocalData.recycle(); 187 } 188 189 @Override 190 public void isPhotoSphere(Context context, PanoramaSupportCallback callback) { 191 mLocalData.isPhotoSphere(context, callback); 192 } 193 194 @Override 195 public void viewPhotoSphere(PhotoSphereHelper.PanoramaViewHelper helper) { 196 mLocalData.viewPhotoSphere(helper); 197 } 198 199 @Override 200 public boolean isPhoto() { 201 return mLocalData.isPhoto(); 202 } 203 204 @Override 205 public Uri getContentUri() { 206 return mLocalData.getContentUri(); 207 } 208 } 209