Пример #1
0
  private RealmResults(BaseRealm realm, TableOrView table, Class<E> classSpec) {
    this.realm = realm;
    this.classSpec = classSpec;
    this.table = table;

    this.pendingQuery = null;
    this.query = null;
    this.currentTableViewVersion = table.sync();
  }
Пример #2
0
  /** Notifies all registered listeners. */
  void notifyChangeListeners() {
    if (listeners != null && !listeners.isEmpty()) {
      // table might be null (if the async query didn't complete
      // but we have already registered listeners for it)
      if (pendingQuery != null && !isCompleted) return;

      // FIXME: still waiting for Core to provide a fix
      //       for crash when calling _sync_if_needed on a cleared View.
      //       https://github.com/realm/realm-core/pull/1390
      long version = table.sync();
      if (currentTableViewVersion != version) {
        currentTableViewVersion = version;
        for (RealmChangeListener listener : listeners) {
          listener.onChange();
        }
      }
    }
  }