Home | History | Annotate | Download | only in data
      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.ContentResolver;
     20 import android.content.Context;
     21 import android.net.Uri;
     22 
     23 /**
     24  * An abstract {@link LocalDataAdapter} implementation to wrap another
     25  * {@link LocalDataAdapter}. All implementations related to data id is not
     26  * addressed in this abstract class since wrapping another data adapter
     27  * surely makes things different for data id.
     28  *
     29  * @see FixedFirstDataAdapter
     30  * @see FixedLastDataAdapter
     31  */
     32 public abstract class AbstractLocalDataAdapterWrapper implements LocalDataAdapter {
     33 
     34     protected final LocalDataAdapter mAdapter;
     35     protected int mSuggestedWidth;
     36     protected int mSuggestedHeight;
     37 
     38     /**
     39      * Constructor.
     40      *
     41      * @param wrappedAdapter  The {@link LocalDataAdapter} to be wrapped.
     42      */
     43     AbstractLocalDataAdapterWrapper(LocalDataAdapter wrappedAdapter) {
     44         if (wrappedAdapter == null) {
     45             throw new AssertionError("data adapter is null");
     46         }
     47         mAdapter = wrappedAdapter;
     48     }
     49 
     50     @Override
     51     public void suggestViewSizeBound(int w, int h) {
     52         mSuggestedWidth = w;
     53         mSuggestedHeight = h;
     54         mAdapter.suggestViewSizeBound(w, h);
     55     }
     56 
     57     @Override
     58     public void setListener(Listener listener) {
     59         mAdapter.setListener(listener);
     60     }
     61 
     62     @Override
     63     public void requestLoad(ContentResolver resolver) {
     64         mAdapter.requestLoad(resolver);
     65     }
     66 
     67     @Override
     68     public void addNewVideo(ContentResolver resolver, Uri uri) {
     69         mAdapter.addNewVideo(resolver, uri);
     70     }
     71 
     72     @Override
     73     public void addNewPhoto(ContentResolver resolver, Uri uri) {
     74         mAdapter.addNewPhoto(resolver, uri);
     75     }
     76 
     77     @Override
     78     public void insertData(LocalData data) {
     79         mAdapter.insertData(data);
     80     }
     81 
     82     @Override
     83     public void flush() {
     84         mAdapter.flush();
     85     }
     86 
     87     @Override
     88     public boolean executeDeletion(Context context) {
     89         return mAdapter.executeDeletion(context);
     90     }
     91 
     92     @Override
     93     public boolean undoDataRemoval() {
     94         return mAdapter.undoDataRemoval();
     95     }
     96 
     97     @Override
     98     public void refresh(ContentResolver resolver, Uri uri) {
     99         mAdapter.refresh(resolver, uri);
    100     }
    101 }
    102