当前位置: 首页>>代码示例>>Java>>正文


Java ContentObserver类代码示例

本文整理汇总了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();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:17,代码来源:UserDictionary.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:ConversationListActivity.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:ConversationListActivity.java

示例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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:23,代码来源:ContactsContentObserver.java

示例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);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:23,代码来源:ChannelDataManager.java

示例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);
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:19,代码来源:ChannelDataManagerTest.java

示例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);
            }
        });
    }
}
 
开发者ID:ryansgot,项目名称:forsuredbandroid,代码行数:22,代码来源:BaseResolverContentObserver.java

示例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);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:21,代码来源:ConversationListActivity.java

示例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);
}
 
开发者ID:esafirm,项目名称:android-image-picker,代码行数:20,代码来源:ImagePickerActivity.java

示例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));
}
 
开发者ID:ArturVasilov,项目名称:SQLite,代码行数:18,代码来源:Observers.java

示例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);
    }
  };
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:20,代码来源:DownloadManagerLegacyImpl.java

示例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);
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:21,代码来源:ConversationListActivity.java

示例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);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:20,代码来源:ConversationListActivity.java

示例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;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:23,代码来源:ReadingListHelper.java

示例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
    );
}
 
开发者ID:4thline,项目名称:feeds,代码行数:25,代码来源:FeedEntryListFragment.java


注:本文中的android.database.ContentObserver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。