18ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde/* 28ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Copyright (C) 2013 The Android Open Source Project 38ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 48ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Licensed under the Apache License, Version 2.0 (the "License"); 58ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * you may not use this file except in compliance with the License. 68ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * You may obtain a copy of the License at 78ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 88ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * http://www.apache.org/licenses/LICENSE-2.0 98ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 108ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Unless required by applicable law or agreed to in writing, software 118ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * distributed under the License is distributed on an "AS IS" BASIS, 128ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * See the License for the specific language governing permissions and 148ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * limitations under the License. 158ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 168ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 178ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdepackage com.android.camera.data; 188ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 198ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdeimport android.graphics.Bitmap; 208ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdeimport android.net.Uri; 218ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdeimport android.view.View; 228ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 238ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdeimport com.android.camera.debug.Log; 2451cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newbergerimport com.android.camera.util.Size; 258ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdeimport com.google.common.base.Optional; 268ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 2777d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohdeimport javax.annotation.Nonnull; 2877d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde 298ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde/** 308ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * An abstract interface that represents the Local filmstrip items. 318ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 328ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohdepublic interface FilmstripItem { 338ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde static final Log.Tag TAG = new Log.Tag("FilmstripItem"); 348ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 358ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 368ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * An action callback to be used for actions on the filmstrip items. 378ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 388ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public static interface VideoClickedCallback { 398ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 408ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 418ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Plays the video with the given URI and title. 428ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 438ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public void playVideo(Uri uri, String title); 448ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde } 458ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 468ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 478ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Returns the backing data for this filmstrip item. 488ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 498ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public FilmstripItemData getData(); 508ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 518ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 528ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Returns the UI attributes of this filmstrip item. 538ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 548ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public FilmstripItemAttributes getAttributes(); 558ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 568ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 578ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Returns the generic filmstrip item type. 588ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 598ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public FilmstripItemType getItemViewType(); 608ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 618ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 628ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @return The media details (such as EXIF) for the data. {@code null} if not 638ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * available for the data. 648ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 658ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public Optional<MediaDetails> getMediaDetails(); 668ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 678ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 688ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @return the metadata. 698ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 708ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public Metadata getMetadata(); 718ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 728ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 738ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Gives the data a hint when its view is going to be removed from the view 748ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * hierarchy. {@code FilmStripView} should always call this function after its 758ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * corresponding view is removed from the view hierarchy. 768ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 7777d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public void recycle(@Nonnull View view); 788ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 798ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 808ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Create or recycle an existing view (if provided) to render this item. 818ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 828ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @param adapter Data adapter for this data item. 838ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 8477d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public View getView(Optional<View> view, 85005bb2f26e73c4c9daad41b615f6dd414396f625Alan Newberger LocalFilmstripDataAdapter adapter, boolean isInProgress, 868ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde VideoClickedCallback videoClickedCallback); 878ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 888ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 8977d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * Configure the suggested width and height in pixels for this view to render at. 9077d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * 9177d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * @param widthPx Suggested width in pixels. 9277d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * @param heightPx Suggested height in pixels. 9377d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde */ 9477d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public void setSuggestedSize(int widthPx, int heightPx); 9577d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde 9677d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde /** 9777d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * Request to load a tiny preview image into the view as fast as possible. 9877d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * 9977d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * @param view View created by getView(); 10077d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde */ 10177d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public void renderTiny(@Nonnull View view); 10277d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde 10377d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde /** 10477d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * Request to load screen sized version of the image into the view. 10577d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * 10677d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * @param view View created by getView(); 10777d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde */ 10877d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public void renderThumbnail(@Nonnull View view); 10977d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde 11077d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde /** 11177d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde * Request to load the highest possible resolution image supported. 1128ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 1138ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @param view View created by getView(); 1148ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 11577d9f023e76816e5da7bd067ad46cc0e9c98623fPaul Rohde public void renderFullRes(@Nonnull View view); 1168ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 1178ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 1188ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Removes the data from the storage if possible. 1198ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 1208ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public boolean delete(); 1218ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 1228ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 1238ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * Refresh the data content. 1248ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * 1258ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @return A new LocalData object if success, null otherwise. 1268ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 1278ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public FilmstripItem refresh(); 1288ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde 1298ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde /** 1308ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde * @return a bitmap thumbnail for this item. 1318ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde */ 1328ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde public Optional<Bitmap> generateThumbnail(int boundingWidthPx, int boundingHeightPx); 13351cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger 13451cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger /** 13551cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger * Dimensions of this item. 13651cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger * 13751cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger * @return physical width and height in pixels. 13851cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger */ 13951cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger public Size getDimensions(); 14051cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger 14151cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger /** 14251cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger * Returns the rotation of the image in degrees clockwise. The valid values 14351cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger * are 0, 90, 180, and 270. 14451cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger */ 14551cafa0a35546a42c573357aa7a031a79cf9ba1bAlan Newberger public int getOrientation(); 1468ee16b8a323ffa20e6fb1270d498ec445f64defcPaul Rohde} 147