當前位置: 首頁>>代碼示例>>Java>>正文


Java RealmResults.size方法代碼示例

本文整理匯總了Java中io.realm.RealmResults.size方法的典型用法代碼示例。如果您正苦於以下問題:Java RealmResults.size方法的具體用法?Java RealmResults.size怎麽用?Java RealmResults.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.realm.RealmResults的用法示例。


在下文中一共展示了RealmResults.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: complexQuery

import io.realm.RealmResults; //導入方法依賴的package包/類
private String complexQuery() {
    String status = "\n\nPerforming complex Query operation...";

    Realm realm = Realm.getDefaultInstance();
    status += "\nNumber of people in the DB: " + realm.where(Person.class).count();

    // Find all persons where age between 1 and 99 and name begins with "J".
    RealmResults<Person> results = realm.where(Person.class)
            .between("age", 1, 99)       // Notice implicit "and" operation
            .beginsWith("name", "J")
            .findAll();
    status += "\nNumber of people aged between 1 and 99 who's name start with 'J': " + results.size();

    realm.close();
    return status;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ExampleActivity.java

示例2: init

import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public void init(long taskId) {
    RealmResults<Task> taskResults = repository.queryTask(taskId);
    if (taskResults.size() > 0) {
        task = taskResults.get(0);
    }
    task.addChangeListener(new RealmChangeListener<RealmModel>() {
        @Override
        public void onChange(RealmModel element) {
            task.getId();
            view.updateViews(task);
        }
    });
    view.initViews();
    view.updateViews(task);
}
 
開發者ID:mengdd,項目名稱:TodoRealm,代碼行數:17,代碼來源:TaskDetailPresenter.java

示例3: updateList

import io.realm.RealmResults; //導入方法依賴的package包/類
private void updateList(RealmResults<TaskList> results)
{
    // Use `findAllAsync` because change listeners are not called when items are deleted and using `findFirst()`
    // See https://github.com/realm/realm-java/issues/3138
    if (results.size() > 0)
    {
        TaskList element = results.first();
        setTitle(element.getText());
        if (adapter == null)
        {
            adapter = new TaskAdapter(TaskActivity.this, element.getItems());
            touchHelper = new TouchHelper(new Callback(), adapter);
            touchHelper.attachToRecyclerView(recyclerView);
        }
    }
    else
    {
        setTitle(getString(R.string.title_deleted));
    }
}
 
開發者ID:WangZhiYao,項目名稱:RealmTasks,代碼行數:21,代碼來源:TaskActivity.java

示例4: getMissingConfirmTrips

import io.realm.RealmResults; //導入方法依賴的package包/類
public static RealmResults<Trip> getMissingConfirmTrips(Realm realm) {
    RealmResults<StationUse> uses = realm.where(StationUse.class)
            .greaterThan("entryDate", new Date(new Date().getTime() - TimeUnit.DAYS.toMillis(7))).findAll().where()
            .equalTo("type", "NETWORK_ENTRY").or().equalTo("type", "VISIT").findAll();

    // now we have all station uses that **might** be part of editable trips
    // get all trips that contain these uses and which are yet to be confirmed
    RealmQuery<Trip> tripsQuery = realm.where(Trip.class);
    if (uses.size() > 0) {
        // first item detached from the others because otherwise "Missing left-hand side of OR" might happen
        // https://github.com/realm/realm-java/issues/1014#issuecomment-107235374
        tripsQuery = tripsQuery.equalTo("userConfirmed", false).equalTo("path.station.id", uses.get(0).getStation().getId()).equalTo("path.entryDate", uses.get(0).getEntryDate());
        for (int i = 1; i < uses.size(); i++) {
            tripsQuery = tripsQuery.or().equalTo("userConfirmed", false).equalTo("path.station.id", uses.get(i).getStation().getId()).equalTo("path.entryDate", uses.get(i).getEntryDate());
        }
        return tripsQuery.findAll();
    } else {
        // realm is just terrible. not only is it hard to do a proper WHERE ... IN ... query, it's also hard to generate an empty result set.
        // https://github.com/realm/realm-java/issues/1862
        // https://github.com/realm/realm-java/issues/1575
        // https://github.com/realm/realm-java/issues/4011
        return tripsQuery.equalTo("id", "NEVER_BE_TRUE").findAll();
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:25,代碼來源:Trip.java

示例5: getAll

import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public Iterable<Preview> getAll(ItemsPerPreview itemsPerPreview) {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListDAO> allTodoListDAO = realm.where(TodoListDAO.class).findAllSorted("position", Sort.DESCENDING);
    RealmResults<NoteDAO> allNoteDAO = realm.where(NoteDAO.class).findAllSorted("position", Sort.DESCENDING);

    List<Preview> previews = new ArrayList<>(allTodoListDAO.size() + allNoteDAO.size());

    for (TodoListDAO todoListDAO : allTodoListDAO) {
        previews.add(constructPreview(realm, todoListDAO, itemsPerPreview));
    }
    for (NoteDAO noteDAO : allNoteDAO) {
        previews.add(new NotePreview(RealmConverter.convert(noteDAO)));
    }
    realm.close();
    return previews;
}
 
開發者ID:djuelg,項目名稱:Neuronizer,代碼行數:18,代碼來源:PreviewRepositoryImpl.java

示例6: saveData

import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Content> data) {
    RealmResults<Content> all = mRealm.where(Content.class).findAll();
    if (all.size() > 0) {
        Content content = all.get(0);
        if (content != null) {
            if (!(content.content).equals(data.get(0).content)) {
                mRealm.executeTransaction(realm -> {
                    realm.delete(Android.class);
                    mList.clear();
                    mList.addAll(data);
                    realm.copyToRealmOrUpdate(data);
                });
            } else {//數據一樣不保存,同時不做 Adapter 刷新
                mPage = mPageIndex;
                AppUtils.toast(R.string.tip_no_new_data);
                mView.hideLoading();
            }
        }
    } else {
        mList.addAll(data);
        mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));//第一次進入應用時
    }
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:24,代碼來源:ImagePresenter.java

示例7: saveData

import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Android> data) {//刷新時才調用到
    RealmResults<Android> all = mRealm.where(Android.class).findAll();
    if (all.size() > 0) {
        Android android = all.get(0);
        if (android != null) {
            if (!(android.content).equals(data.get(0).content)) {
                mRealm.executeTransaction(realm -> {
                    items.clear();
                    time2 = "";
                    realm.delete(Android.class);
                    realm.copyToRealmOrUpdate(data);
                });
            } else {//數據一樣不保存,同時不做 Adapter 刷新
                mPage = mPageIndex;
                AppUtils.toast(R.string.tip_no_new_data);
                mView.hideLoading();
            }
        }
    } else {
        mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));
    }
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:23,代碼來源:AndroidPresenter.java

示例8: setupUi

import io.realm.RealmResults; //導入方法依賴的package包/類
public void setupUi(View view) {
    Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
    RealmResults<SensorData> sensorDataResults = realmProcessedData.where(SensorData.class).
            findAllSorted(START_DATE, Sort.DESCENDING);

    TextView sensorId = (TextView) view.findViewById(R.id.tv_sensor_id_value);
    TextView sensorStartDate = (TextView) view.findViewById(R.id.tv_sensor_start_date_value);
    TextView sensorEndsIn = (TextView) view.findViewById(R.id.tv_sensor_ends_in_value);

    if (sensorDataResults.size() == 0) {
        sensorId.setText(getResources().getString(R.string.no_sensor_registered));
        sensorStartDate.setText("");
        sensorEndsIn.setText("");
    } else {
        SensorData sensorData = sensorDataResults.first();
        sensorId.setText(sensorData.getTagId());
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
        sensorStartDate.setText(dateFormat.format(new Date(sensorData.getStartDate())));
        long timeLeft = sensorData.getTimeLeft();
        if (timeLeft >= TimeUnit.MINUTES.toMillis(1L)) {
            sensorEndsIn.setText(getDurationBreakdown(getResources(), sensorData.getTimeLeft()));
        } else {
            sensorEndsIn.setText(getResources().getString(R.string.sensor_expired));
        }
    }
    realmProcessedData.close();
}
 
開發者ID:DorianScholz,項目名稱:OpenLibre,代碼行數:28,代碼來源:SensorStatusFragment.java

示例9: getAll

import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public List<TodoList> getAll() {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListDAO> todoListDAOs = realm.where(TodoListDAO.class).findAll();
    List<TodoList> todoLists = new ArrayList<>(todoListDAOs.size());
    for (TodoListDAO dao : todoListDAOs) {
        todoLists.add(RealmConverter.convert(dao));
    }
    realm.close();
    return todoLists;
}
 
開發者ID:djuelg,項目名稱:Neuronizer,代碼行數:12,代碼來源:TodoListRepositoryImpl.java

示例10: mapFrom

import io.realm.RealmResults; //導入方法依賴的package包/類
private List<Task> mapFrom(RealmResults<DbTask> dbTasks) {
    List<Task> tasks = new ArrayList<>(dbTasks.size());
    for(DbTask dbTask : dbTasks) {
        tasks.add(taskMapper.fromRealm(dbTask));
    }
    return tasks;
}
 
開發者ID:Zhuinden,項目名稱:simple-stack,代碼行數:8,代碼來源:TaskRepository.java

示例11: updateList

import io.realm.RealmResults; //導入方法依賴的package包/類
private void updateList(RealmResults<TaskListList> results)
{
    if (results.size() > 0 && adapter == null)
    {
        // The default list is being added on all devices, so according to the merge rules the default list might
        // be added multiple times. This is just a temporary fix. Proper ordered sets are being tracked here:
        // https://github.com/realm/realm-core/issues/1206
        realm.beginTransaction();
        Set<String> seen = new HashSet<>();
        Iterator<TaskList> it = results.first().getItems().iterator();
        while (it.hasNext())
        {
            TaskList list = it.next();
            String id = list.getId();
            if (seen.contains(id))
            {
                it.remove();
            }
            seen.add(id);
        }
        realm.commitTransaction();

        // Create Adapter
        adapter = new TaskListAdapter(TaskListActivity.this, results.first().getItems());
        touchHelper = new TouchHelper(new Callback(), adapter);
        touchHelper.attachToRecyclerView(recyclerView);
    }
}
 
開發者ID:WangZhiYao,項目名稱:RealmTasks,代碼行數:29,代碼來源:TaskListActivity.java

示例12: getCholesterolReadings

import io.realm.RealmResults; //導入方法依賴的package包/類
public ArrayList<CholesterolReading> getCholesterolReadings() {
    RealmResults<CholesterolReading> results =
            realm.where(CholesterolReading.class)
                    .findAllSorted("created", Sort.DESCENDING);
    ArrayList<CholesterolReading> readingList = new ArrayList<>();
    for (int i = 0; i < results.size(); i++) {
        readingList.add(results.get(i));
    }
    return readingList;
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:11,代碼來源:DatabaseHandler.java

示例13: onLoadTagsEvent

import io.realm.RealmResults; //導入方法依賴的package包/類
@Subscribe
public void onLoadTagsEvent(LoadTagsEvent event) {
    RealmResults<Tag> tags = mRealm.where(Tag.class).findAllSorted("name");
    List<Tag> tagsCopy = new ArrayList<>(tags.size());
    for (Tag tag : tags) {
        tagsCopy.add(new Tag(tag.getName()));
    }
    getBus().post(new TagsLoadedEvent(tagsCopy));
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:10,代碼來源:NetworkService.java

示例14: getReminders

import io.realm.RealmResults; //導入方法依賴的package包/類
public List<Reminder> getReminders() {
    RealmResults<Reminder> results =
            realm.where(Reminder.class)
                    .findAllSorted("alarmTime", Sort.DESCENDING);
    List<Reminder> reminders = new ArrayList<>(results.size());
    for (int i = 0; i < results.size(); i++) {
        reminders.add(results.get(i));
    }
    return reminders;
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:11,代碼來源:DatabaseHandler.java

示例15: getGlucoseReadings

import io.realm.RealmResults; //導入方法依賴的package包/類
public ArrayList<GlucoseReading> getGlucoseReadings(Date from, Date to) {
    RealmResults<GlucoseReading> results =
            realm.where(GlucoseReading.class)
                    .between("created", from, to)
                    .findAllSorted("created", Sort.DESCENDING);
    ArrayList<GlucoseReading> readingList = new ArrayList<>();
    for (int i = 0; i < results.size(); i++) {
        readingList.add(results.get(i));
    }
    return readingList;
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:12,代碼來源:DatabaseHandler.java


注:本文中的io.realm.RealmResults.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。