本文整理汇总了Java中android.database.ContentObserver类的典型用法代码示例。如果您正苦于以下问题:Java ContentObserver类的具体用法?Java ContentObserver怎么用?Java ContentObserver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentObserver类属于android.database包,在下文中一共展示了ContentObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UserDictionary
import android.database.ContentObserver; //导入依赖的package包/类
public UserDictionary(Context context, String locale) {
super(context, Suggest.DIC_USER);
mLocale = locale;
// Perform a managed query. The Activity will handle closing and requerying the cursor
// when needed.
ContentResolver cres = context.getContentResolver();
cres.registerContentObserver(Words.CONTENT_URI, true, mObserver = new ContentObserver(null) {
@Override
public void onChange(boolean self) {
setRequiresReload(true);
}
});
loadDictionary();
}
示例2: initializeContactUpdatesReceiver
import android.database.ContentObserver; //导入依赖的package包/类
private void initializeContactUpdatesReceiver() {
observer = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.w(TAG, "Detected android contact data changed, refreshing cache");
RecipientFactory.clearCache(ConversationListActivity.this);
ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
chatsFragment.getListAdapter().notifyDataSetChanged();
}
});
}
};
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI,
true, observer);
}
示例3: initializeContactUpdatesReceiver
import android.database.ContentObserver; //导入依赖的package包/类
private void initializeContactUpdatesReceiver() {
observer = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.w(TAG, "Detected android contact data changed, refreshing cache");
RecipientFactory.clearCache(ConversationListActivity.this);
ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
fragment.getListAdapter().notifyDataSetChanged();
}
});
}
};
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI,
true, observer);
}
示例4: registerObserver
import android.database.ContentObserver; //导入依赖的package包/类
public void registerObserver(final ContactsChangedListener listener) {
if (!PermissionsUtil.checkAllPermissionsGranted(
mContext, Manifest.permission.READ_CONTACTS)) {
Log.i(TAG, "No permission to read contacts. Not registering the observer.");
// do nothing if we do not have the permission to read contacts.
return;
}
if (DebugFlags.DEBUG_ENABLED) {
Log.d(TAG, "registerObserver()");
}
mContactsChangedListener = listener;
mContentObserver = new ContentObserver(null /* handler */) {
@Override
public void onChange(boolean self) {
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD)
.execute(ContactsContentObserver.this);
}
};
final ContentResolver contentResolver = mContext.getContentResolver();
contentResolver.registerContentObserver(Contacts.CONTENT_URI, true, mContentObserver);
}
示例5: ChannelDataManager
import android.database.ContentObserver; //导入依赖的package包/类
@VisibleForTesting
ChannelDataManager(Context context, TvInputManagerHelper inputManager,
ContentResolver contentResolver) {
mContext = context;
mInputManager = inputManager;
mContentResolver = contentResolver;
mChannelComparator = new Channel.DefaultComparator(context, inputManager);
// Detect duplicate channels while sorting.
mChannelComparator.setDetectDuplicatesEnabled(true);
mHandler = new ChannelDataManagerHandler(this);
mChannelObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
if (!mHandler.hasMessages(MSG_UPDATE_CHANNELS)) {
mHandler.sendEmptyMessage(MSG_UPDATE_CHANNELS);
}
}
};
mStoreBrowsableInSharedPreferences = !PermissionUtils.hasAccessAllEpg(mContext);
mBrowsableSharedPreferences = context.getSharedPreferences(
SharedPreferencesUtils.SHARED_PREF_BROWSABLE, Context.MODE_PRIVATE);
}
示例6: notifyChange
import android.database.ContentObserver; //导入依赖的package包/类
@Override
public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
super.notifyChange(uri, observer, syncToNetwork);
if (DEBUG) {
Log.d(TAG, "onChanged(uri=" + uri + ", observer=" + observer + ") - Notification "
+ (mNotifyDisabled ? "disabled" : "enabled"));
}
if (mNotifyDisabled) {
return;
}
// Do not call {@link ContentObserver#onChange} directly to run it on the correct
// thread.
if (observer != null) {
observer.dispatchChange(false, uri);
} else {
mChannelDataManager.getContentObserver().dispatchChange(false, uri);
}
}
示例7: BaseResolverContentObserver
import android.database.ContentObserver; //导入依赖的package包/类
public BaseResolverContentObserver(Context context,
final Resolver<R, Uri, FSContentValues, ?, ?, ?, ?> resolver,
Handler handler,
final boolean deliverSelfNotifications) {
this.context = context;
this.tableUris = UriEvaluator.tableReferences(resolver.currentLocator());
for (final Uri tableUri : tableUris) {
contentObservers.put(tableUri, new ContentObserver(handler) {
@Override
public boolean deliverSelfNotifications() {
return deliverSelfNotifications;
}
@Override
public void onChange(boolean selfChange) {
BaseResolverContentObserver.this.onChange(selfChange, tableUri, resolver);
}
});
}
}
示例8: initializeContactUpdatesReceiver
import android.database.ContentObserver; //导入依赖的package包/类
private void initializeContactUpdatesReceiver() {
observer = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.w("ConversationListActivity", "detected android contact data changed, refreshing cache");
// TODO only clear updated recipients from cache
RecipientFactory.clearCache();
ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
((ConversationListAdapter)fragment.getListAdapter()).notifyDataSetChanged();
}
});
}
};
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI,
true, observer);
}
示例9: onStart
import android.database.ContentObserver; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
if (isCameraOnly) {
return;
}
if (handler == null) {
handler = new Handler();
}
observer = new ContentObserver(handler) {
@Override
public void onChange(boolean selfChange) {
getData();
}
};
getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer);
}
示例10: registerObserver
import android.database.ContentObserver; //导入依赖的package包/类
public <T> void registerObserver(@NonNull Context context, @NonNull Table<T> table,
@NonNull final BasicTableObserver observer) {
ContentObserver contentObserver = new DatabaseObserver() {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
MainHandler.getHandler().post(new Runnable() {
@Override
public void run() {
observer.onTableChanged();
}
});
}
};
context.getContentResolver().registerContentObserver(table.getUri(), false, contentObserver);
mObservers.add(new Pair<Object, ContentObserver>(observer, contentObserver));
}
示例11: DownloadManagerLegacyImpl
import android.database.ContentObserver; //导入依赖的package包/类
protected DownloadManagerLegacyImpl(Context paramContext)
{
this.mContentResolver = paramContext.getContentResolver();
HandlerThread localHandlerThread = BackgroundThreadFactory.createHandlerThread("download-manager-thread");
localHandlerThread.start();
this.mHandler = new Handler(localHandlerThread.getLooper());
this.mContentObserver = new ContentObserver(this.mHandler)
{
public final boolean deliverSelfNotifications()
{
return false;
}
public final void onChange(boolean paramAnonymousBoolean)
{
DownloadManagerLegacyImpl.access$000(DownloadManagerLegacyImpl.this);
}
};
}
示例12: initializeContactUpdatesReceiver
import android.database.ContentObserver; //导入依赖的package包/类
private void initializeContactUpdatesReceiver() {
observer = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.w(TAG, "detected android contact data changed, refreshing cache");
// TODO only clear updated recipients from cache
RecipientFactory.clearCache();
ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
fragment.getListAdapter().notifyDataSetChanged();
}
});
}
};
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI,
true, observer);
}
示例13: initializeContactUpdatesReceiver
import android.database.ContentObserver; //导入依赖的package包/类
private void initializeContactUpdatesReceiver() {
observer = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.w(TAG, "Detected android contact data changed, refreshing cache");
RecipientFactory.clearCache();
ConversationListActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
fragment.getListAdapter().notifyDataSetChanged();
}
});
}
};
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI,
true, observer);
}
示例14: ReadingListHelper
import android.database.ContentObserver; //导入依赖的package包/类
public ReadingListHelper(Context context, GeckoProfile profile, OnReadingListEventListener listener) {
this.context = context;
this.db = profile.getDB();
this.readingListAccessor = db.getReadingListAccessor();
EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this,
"Reader:AddToList", "Reader:UpdateList", "Reader:FaviconRequest", "Reader:ListStatusRequest", "Reader:RemoveFromList");
contentObserver = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
if (fetchInBackground) {
fetchContent();
}
}
};
this.readingListAccessor.registerContentObserver(context, contentObserver);
onReadingListEventListener = listener;
}
示例15: onActivityCreated
import android.database.ContentObserver; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
log.fine("On activity created");
adapter = createListAdapter();
setListAdapter(adapter);
refreshContentObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
adapter.setRefreshRequired(isResumed());
}
};
long id = stateProvider.getFeedReader().feedId;
Uri uri = id == -1
? FeedConfig.CONTENT_URI
: Uri.withAppendedPath(FeedConfig.CONTENT_URI, Long.toString(id));
log.fine("On create, registering content observer: " + uri);
getActivity().getContentResolver().registerContentObserver(
uri, true, refreshContentObserver
);
}