Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2009 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.layoutlib.bridge.android;
     18 
     19 import android.content.ContentResolver;
     20 import android.content.Context;
     21 import android.content.IContentProvider;
     22 import android.database.ContentObserver;
     23 import android.net.Uri;
     24 import android.os.Bundle;
     25 
     26 /**
     27  * A mock content resolver for the LayoutLib Bridge.
     28  * <p/>
     29  * It won't serve any actual data but it's good enough for all
     30  * the widgets which expect to have a content resolver available via
     31  * {@link BridgeContext#getContentResolver()}.
     32  */
     33 public class BridgeContentResolver extends ContentResolver {
     34 
     35     private BridgeContentProvider mProvider = null;
     36 
     37     public BridgeContentResolver(Context context) {
     38         super(context);
     39     }
     40 
     41     @Override
     42     public IContentProvider acquireProvider(Context c, String name) {
     43         if (mProvider == null) {
     44             mProvider = new BridgeContentProvider();
     45         }
     46 
     47         return mProvider;
     48     }
     49 
     50     @Override
     51     public IContentProvider acquireExistingProvider(Context c, String name) {
     52         if (mProvider == null) {
     53             mProvider = new BridgeContentProvider();
     54         }
     55 
     56         return mProvider;
     57     }
     58 
     59     @Override
     60     public boolean releaseProvider(IContentProvider icp) {
     61         // ignore
     62         return false;
     63     }
     64 
     65     /**
     66      * Stub for the layoutlib bridge content resolver.
     67      */
     68     @Override
     69     public void registerContentObserver(Uri uri, boolean notifyForDescendents,
     70             ContentObserver observer) {
     71         // pass
     72     }
     73 
     74     /**
     75      * Stub for the layoutlib bridge content resolver.
     76      */
     77     @Override
     78     public void unregisterContentObserver(ContentObserver observer) {
     79         // pass
     80     }
     81 
     82     /**
     83      * Stub for the layoutlib bridge content resolver.
     84      */
     85     @Override
     86     public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
     87         // pass
     88     }
     89 
     90     /**
     91      * Stub for the layoutlib bridge content resolver.
     92      */
     93     @Override
     94     public void startSync(Uri uri, Bundle extras) {
     95         // pass
     96     }
     97 
     98     /**
     99      * Stub for the layoutlib bridge content resolver.
    100      */
    101     @Override
    102     public void cancelSync(Uri uri) {
    103         // pass
    104     }
    105 }
    106