• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OrderedRealmCollectionChangeListener类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中io.realm.OrderedRealmCollectionChangeListener的典型用法代码示例。如果您正苦于以下问题:Java OrderedRealmCollectionChangeListener类的具体用法?Java OrderedRealmCollectionChangeListener怎么用?Java OrderedRealmCollectionChangeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OrderedRealmCollectionChangeListener类属于io.realm包,在下文中一共展示了OrderedRealmCollectionChangeListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addListener

点赞 2

import io.realm.OrderedRealmCollectionChangeListener; //导入依赖的package包/类
public <T> void addListener(T observer, OrderedRealmCollectionChangeListener<T> listener) {
    if (observerPairs.isEmpty()) {
        nativeStartListening(nativePtr);
    }
    CollectionObserverPair<T> collectionObserverPair = new CollectionObserverPair<T>(observer, listener);
    observerPairs.add(collectionObserverPair);
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:8,
代码来源:OsList.java

示例2: onChange

点赞 2

import io.realm.OrderedRealmCollectionChangeListener; //导入依赖的package包/类
public void onChange(T observer, @Nullable OrderedCollectionChangeSet changes) {
    if (listener instanceof OrderedRealmCollectionChangeListener) {
        //noinspection unchecked
        ((OrderedRealmCollectionChangeListener<T>) listener).onChange(observer, changes);
    } else if (listener instanceof RealmChangeListener) {
        //noinspection unchecked
        ((RealmChangeListener<T>) listener).onChange(observer);
    } else {
        throw new RuntimeException("Unsupported listener type: " + listener);
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:12,
代码来源:ObservableCollection.java

示例3: changesetsFrom

点赞 2

import io.realm.OrderedRealmCollectionChangeListener; //导入依赖的package包/类
@Override
public <E> Observable<CollectionChange<RealmResults<E>>> changesetsFrom(Realm realm, final RealmResults<E> results) {
    final RealmConfiguration realmConfig = realm.getConfiguration();
    return Observable.create(new ObservableOnSubscribe<CollectionChange<RealmResults<E>>>() {
        @Override
        public void subscribe(final ObservableEmitter<CollectionChange<RealmResults<E>>> emitter) throws Exception {
            // Gets instance to make sure that the Realm is open for as long as the
            // Observable is subscribed to it.
            final Realm observableRealm = Realm.getInstance(realmConfig);
            resultsRefs.get().acquireReference(results);
            final OrderedRealmCollectionChangeListener<RealmResults<E>> listener = new OrderedRealmCollectionChangeListener<RealmResults<E>>() {
                @Override
                public void onChange(RealmResults<E> e, OrderedCollectionChangeSet changeSet) {
                    if (!emitter.isDisposed()) {
                        emitter.onNext(new CollectionChange<RealmResults<E>>(results, changeSet));
                    }
                }
            };
            results.addChangeListener(listener);

            // Cleanup when stream is disposed
            emitter.setDisposable(Disposables.fromRunnable(new Runnable() {
                @Override
                public void run() {
                    results.removeChangeListener(listener);
                    observableRealm.close();
                    resultsRefs.get().releaseReference(results);
                }
            }));

            // Emit current value immediately
            emitter.onNext(new CollectionChange<>(results, null));
        }
    });
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:36,
代码来源:RealmObservableFactory.java

示例4: removeListener

点赞 2

import io.realm.OrderedRealmCollectionChangeListener; //导入依赖的package包/类
public <T> void removeListener(T observer, OrderedRealmCollectionChangeListener<T> listener) {
    observerPairs.remove(observer, listener);
    if (observerPairs.isEmpty()) {
        nativeStopListening(nativePtr);
    }
}
 

开发者ID:weiwenqiang,
项目名称:GitHub,
代码行数:7,
代码来源:OsList.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)