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