BridgeContentResolver.java revision 652b6d1e591f6684cda4b93d4712920f287991b4
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 17package com.android.layoutlib.bridge.android; 18 19import android.content.ContentResolver; 20import android.content.Context; 21import android.content.IContentProvider; 22import android.database.ContentObserver; 23import android.net.Uri; 24import 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 */ 33public 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 /** 76 * Stub for the layoutlib bridge content resolver. 77 */ 78 @Override 79 public void registerContentObserver(Uri uri, boolean notifyForDescendents, 80 ContentObserver observer) { 81 // pass 82 } 83 84 /** 85 * Stub for the layoutlib bridge content resolver. 86 */ 87 @Override 88 public void unregisterContentObserver(ContentObserver observer) { 89 // pass 90 } 91 92 /** 93 * Stub for the layoutlib bridge content resolver. 94 */ 95 @Override 96 public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { 97 // pass 98 } 99 100 /** 101 * Stub for the layoutlib bridge content resolver. 102 */ 103 @Override 104 public void startSync(Uri uri, Bundle extras) { 105 // pass 106 } 107 108 /** 109 * Stub for the layoutlib bridge content resolver. 110 */ 111 @Override 112 public void cancelSync(Uri uri) { 113 // pass 114 } 115} 116