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 21 /** 22 * A helper class to load the metadata of 23 * {@link FilmstripItem}. 24 */ 25 public class MetadataLoader { 26 27 /** 28 * Adds information to the data's metadata bundle if any is available and returns 29 * true if metadata was added and false otherwise. In either case, sets 30 * a flag indicating that we've cached any available metadata and don't need to 31 * load metadata again for this particular item. 32 * 33 * TODO: Replace with more explicit polymorphism. 34 * 35 * @param context A context. 36 * @param data The data to update metadata for. 37 * @return true if any metadata was added to the data, false otherwise. 38 */ loadMetadata(final Context context, final FilmstripItem data)39 public static boolean loadMetadata(final Context context, final FilmstripItem data) { 40 boolean metadataAdded = false; 41 if (data.getAttributes().isImage()) { 42 metadataAdded |= PanoramaMetadataLoader.loadPanoramaMetadata( 43 context, data.getData().getUri(), data.getMetadata()); 44 metadataAdded |= RgbzMetadataLoader.loadRgbzMetadata( 45 context, data.getData().getUri(), data.getMetadata()); 46 } else if (data.getAttributes().isVideo()) { 47 metadataAdded = VideoRotationMetadataLoader.loadRotationMetadata(data); 48 } 49 data.getMetadata().setLoaded(true); 50 return metadataAdded; 51 } 52 } 53 54