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


Java RealmResults.addChangeListener方法代码示例

本文整理汇总了Java中io.realm.RealmResults.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java RealmResults.addChangeListener方法的具体用法?Java RealmResults.addChangeListener怎么用?Java RealmResults.addChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.realm.RealmResults的用法示例。


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

示例1: setupAdapter

import io.realm.RealmResults; //导入方法依赖的package包/类
public void setupAdapter(RealmResults<Post> posts) {
    posts.addChangeListener(changeListener);
    adapter = new PostAdapter(posts);
    recyclerView.setLayoutManager(new LinearLayoutManager(App.getAppContext()));
    recyclerView.setEmptyView(emptyView);
    recyclerView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:10,代码来源:PostsFragment.java

示例2: subscribeDataChange

import io.realm.RealmResults; //导入方法依赖的package包/类
@Override
public void subscribeDataChange(Object dataIdentity, final DataChangeListener listener) {
    if (dataIdentity instanceof RealmResults) {
        RealmResults<RealmObject> realmResults = (RealmResults<RealmObject>) dataIdentity;
        realmResults.addChangeListener(new RealmChangeListener<RealmResults<RealmObject>>() {
            @Override
            public void onChange(RealmResults<RealmObject> element) {
                if (listener != null) {
                    listener.onChange();
                }
            }
        });
    }
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:15,代码来源:MassDataServiceImpl.java

示例3: expectSimpleCommit

import io.realm.RealmResults; //导入方法依赖的package包/类
@Test
@RunTestInLooperThread
@RunTestWithRemoteService(remoteService = SimpleCommitRemoteService.class, onLooperThread = true)
public void expectSimpleCommit() {
    looperThread.runAfterTest(remoteService.afterRunnable);
    remoteService.createHandler(Looper.myLooper());

    final SyncUser user = UserFactory.getInstance().createDefaultUser(Constants.AUTH_URL);
    String realmUrl = Constants.SYNC_SERVER_URL;
    final SyncConfiguration syncConfig = new SyncConfiguration.Builder(user,realmUrl)
            .directory(looperThread.getRoot())
            .build();
    final Realm realm = Realm.getInstance(syncConfig);
    final RealmResults<ProcessInfo> all = realm.where(ProcessInfo.class).findAll();
    looperThread.keepStrongReference(all);
    all.addChangeListener(new RealmChangeListener<RealmResults<ProcessInfo>>() {
        @Override
        public void onChange(RealmResults<ProcessInfo> element) {
            assertEquals(1, all.size());
            assertEquals("Background_Process1", all.get(0).getName());
            realm.close();
            user.logout();

            remoteService.triggerServiceStep(SimpleCommitRemoteService.stepB_closeRealmAndLogOut);

            looperThread.testComplete();
        }
    });

    remoteService.triggerServiceStep(SimpleCommitRemoteService.stepA_openRealmAndCreateOneObject);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:ProcessCommitTests.java

示例4: expectALot

import io.realm.RealmResults; //导入方法依赖的package包/类
@Test
@RunTestWithRemoteService(remoteService = ALotCommitsRemoteService.class, onLooperThread = true)
@RunTestInLooperThread
public void expectALot() throws Throwable {
    looperThread.runAfterTest(remoteService.afterRunnable);
    remoteService.createHandler(Looper.myLooper());

    final SyncUser user = UserFactory.getInstance().createDefaultUser(Constants.AUTH_URL);
    String realmUrl = Constants.SYNC_SERVER_URL;
    final SyncConfiguration syncConfig = new SyncConfiguration.Builder(user,realmUrl)
            .directory(looperThread.getRoot())
            .build();
    final Realm realm = Realm.getInstance(syncConfig);
    final RealmResults<TestObject> all = realm.where(TestObject.class).findAllSorted("intProp");
    looperThread.keepStrongReference(all);
    final AtomicInteger listenerCalledCounter = new AtomicInteger(0);
    all.addChangeListener(new RealmChangeListener<RealmResults<TestObject>>() {
        @Override
        public void onChange(RealmResults<TestObject> element) {
            int counter = listenerCalledCounter.incrementAndGet();
            int size = all.size();
            if (size == 0) {
                listenerCalledCounter.decrementAndGet();
                return;
            }
            assertEquals(0, size % 100); // Added 100 objects every time.
            assertEquals(counter * 100 - 1, all.last().getIntProp());
            assertEquals("Str" + (counter * 100 - 1), all.last().getStringProp());
            if (counter == 10) {
                remoteService.triggerServiceStep(ALotCommitsRemoteService.stepC_closeRealm);
                realm.close();
                user.logout();
                looperThread.testComplete();
            } else {
                remoteService.triggerServiceStep(ALotCommitsRemoteService.stepB_createObjects);
            }
        }
    });

    remoteService.triggerServiceStep(ALotCommitsRemoteService.stepA_openRealm);
    remoteService.triggerServiceStep(ALotCommitsRemoteService.stepB_createObjects);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:ProcessCommitTests.java

示例5: setPosts

import io.realm.RealmResults; //导入方法依赖的package包/类
public void setPosts(String criteria) {

        POSTS = criteria;

        //change the title
        Title = (POSTS);


        RealmResults<Post> posts = getPosts();

        posts.addChangeListener(changeListener);

        adapter = new PostAdapter(posts);

        recyclerView.setAdapter(adapter);
    }
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:17,代码来源:PostsFragment.java

示例6: start

import io.realm.RealmResults; //导入方法依赖的package包/类
@Override
public void start() {
    sortOrder = appPreferences.getSortOrder();
    RealmResults<Note> results = noteDataSource.loadNotes();
    results.addChangeListener(callback);
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:7,代码来源:MainPresenter.java


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