2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.camera.data;
19 import android.content.Context;
22 * A helper class to load the metadata of
23 * {@link FilmstripItem}.
25 public class MetadataLoader {
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.
33 * TODO: Replace with more explicit polymorphism.
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.
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);
49 data.getMetadata().setLoaded(true);