當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。