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 @Override 66 protected IContentProvider acquireUnstableProvider(Context c, String name) { 67 return acquireProvider(c, name); 68 } 69 70 @Override 71 public boolean releaseUnstableProvider(IContentProvider icp) { 72 return releaseProvider(icp); 73 } 74 75 /** @hide */ 76 @Override 77 public void unstableProviderDied(IContentProvider icp) { 78 } 79 80 /** 81 * Stub for the layoutlib bridge content resolver. 82 */ 83 @Override 84 public void registerContentObserver(Uri uri, boolean notifyForDescendents, 85 ContentObserver observer) { 86 // pass 87 } 88 89 /** 90 * Stub for the layoutlib bridge content resolver. 91 */ 92 @Override 93 public void unregisterContentObserver(ContentObserver observer) { 94 // pass 95 } 96 97 /** 98 * Stub for the layoutlib bridge content resolver. 99 */ 100 @Override 101 public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { 102 // pass 103 } 104 105 /** 106 * Stub for the layoutlib bridge content resolver. 107 */ 108 @Override 109 public void startSync(Uri uri, Bundle extras) { 110 // pass 111 } 112 113 /** 114 * Stub for the layoutlib bridge content resolver. 115 */ 116 @Override 117 public void cancelSync(Uri uri) { 118 // pass 119 } 120 } 121