本文整理汇总了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;
}
示例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);
}
示例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));
}
}
示例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();
}
}
示例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;
}
示例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));//第一次进入应用时
}
}
示例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));
}
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}