com.j256.ormlite.dao.Dao.unregisterObserver()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中com.j256.ormlite.dao.Dao.unregisterObserver()方法的一些代码示例,展示了Dao.unregisterObserver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.unregisterObserver()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:unregisterObserver

Dao.unregisterObserver介绍

[英]Remove the observer from the registered list.
[中]从注册列表中删除观察者。

代码示例

代码示例来源:origin: j256/ormlite-core

@Override
public void unregisterObserver(DaoObserver observer) {
  dao.unregisterObserver(observer);
}

代码示例来源:origin: com.j256.ormlite/ormlite-core

@Override
public void unregisterObserver(DaoObserver observer) {
  dao.unregisterObserver(observer);
}

代码示例来源:origin: com.j256.ormlite/ormlite-android

@Override
protected void onReset() {
  super.onReset();
  // ensure the loader is stopped
  onStopLoading();
  if (cachedResults != null) {
    cachedResults.clear();
    cachedResults = null;
  }
  // stop watching for changes
  dao.unregisterObserver(this);
}

代码示例来源:origin: com.j256.ormlite/ormlite-android

@Override
protected void onReset() {
  super.onReset();
  onStopLoading();
  if (cursor != null) {
    if (!cursor.isClosed()) {
      cursor.close();
    }
    cursor = null;
  }
  // stop watching for changes
  dao.unregisterObserver(this);
}

代码示例来源:origin: com.j256.ormlite/ormlite-android

@Override
protected void onReset() {
  super.onReset();
  onStopLoading();
  if (cursor != null) {
    if (!cursor.isClosed()) {
      cursor.close();
    }
    cursor = null;
  }
  // stop watching for changes
  dao.unregisterObserver(this);
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testDaoObserver() throws Exception {
  Dao<Foo, Integer> dao = createDao(Foo.class, true);
  final AtomicInteger changeCount = new AtomicInteger();
  DaoObserver obverver = new DaoObserver() {
    @Override
    public void onChange() {
      changeCount.incrementAndGet();
    }
  };
  dao.registerObserver(obverver);
  assertEquals(0, changeCount.get());
  Foo foo = new Foo();
  foo.val = 21312313;
  assertEquals(1, dao.create(foo));
  assertEquals(1, changeCount.get());
  foo.val = foo.val + 1;
  assertEquals(1, dao.create(foo));
  assertEquals(2, changeCount.get());
  // shouldn't change anything
  dao.queryForAll();
  assertEquals(2, changeCount.get());
  assertEquals(1, dao.delete(foo));
  assertEquals(3, changeCount.get());
  dao.unregisterObserver(obverver);
  assertEquals(1, dao.create(foo));
  // shouldn't change not that we have removed the observer
  assertEquals(3, changeCount.get());
}

相关文章