本文整理汇总了Java中io.realm.RealmQuery.findAllSorted方法的典型用法代码示例。如果您正苦于以下问题:Java RealmQuery.findAllSorted方法的具体用法?Java RealmQuery.findAllSorted怎么用?Java RealmQuery.findAllSorted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.realm.RealmQuery
的用法示例。
在下文中一共展示了RealmQuery.findAllSorted方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAll
import io.realm.RealmQuery; //导入方法依赖的package包/类
@NonNull
public static List<Folder> getAll(Realm realm, boolean onlyUnread) {
RealmQuery<Folder> query = null;
if(onlyUnread) {
RealmResults<Feed> unreadFeeds = realm.where(Feed.class).greaterThan(Feed.UNREAD_COUNT, 0).notEqualTo(Feed.FOLDER_ID, 0).findAll();
if(unreadFeeds.size() > 0) {
Iterator<Feed> feedIterator = unreadFeeds.iterator();
query = realm.where(Folder.class)
.equalTo(Folder.ID, feedIterator.next().getFolderId());
while (feedIterator.hasNext()) {
query.or().equalTo(Folder.ID, feedIterator.next().getFolderId());
}
}
} else {
query = realm.where(Folder.class);
}
return query != null ? query.findAllSorted(Folder.NAME, Sort.ASCENDING) : Collections.emptyList();
}
示例2: onCreate
import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState!=null) {
selectedSensor = savedInstanceState.getInt(Constants.SELECTED_SENSOR);
} else {
Bundle args = getArguments();
selectedSensor = args.getInt(Constants.SELECTED_SENSOR);
}
realm = Realm.getInstance(getActivity());
RealmQuery<SensorModel> query = realm.where(SensorModel.class);
query.equalTo("sensorType",selectedSensor);
RealmResults<SensorModel> result = query.findAllSorted("timestamp",RealmResults.SORT_ORDER_DESCENDING);
if(result.size() > 0) {
recordData = result.subList(0,result.size());
} else {
recordData = new ArrayList<SensorModel>(0);
}
}
示例3: getArticles
import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public RealmResults<Article> getArticles() {
RealmQuery<Article> a = Realm.getDefaultInstance().where(Article.class);
for(Feed f : feeds){
a.equalTo("feed", f.getTitle()).or();
}
return a.findAllSorted("published", Sort.DESCENDING);
}
示例4: getFeeds
import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public List<Feed> getFeeds(Realm realm, boolean onlyUnread) {
final RealmQuery<Feed> query = realm.where(Feed.class).equalTo(Feed.FOLDER_ID, getId());
if(onlyUnread)
query.greaterThan(Feed.UNREAD_COUNT, 0);
return query.findAllSorted(Feed.NAME, Sort.ASCENDING);
}
示例5: getFeeds
import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public List<Feed> getFeeds(Realm realm, boolean onlyUnread) {
final RealmQuery<Feed> query = realm.where(Feed.class);
if(onlyUnread)
query.greaterThan(Feed.UNREAD_COUNT, 0);
return query.findAllSorted(Feed.NAME, Sort.ASCENDING);
}
示例6: getFeedsWithoutFolder
import io.realm.RealmQuery; //导入方法依赖的package包/类
@NonNull
public static RealmResults<Feed> getFeedsWithoutFolder(Realm realm, boolean onlyUnread) {
RealmQuery<Feed> query = realm.where(Feed.class).equalTo(Feed.FOLDER_ID, 0);
if(onlyUnread) {
query.greaterThan(Feed.UNREAD_COUNT, 0);
}
return query.findAllSorted(Feed.NAME, Sort.ASCENDING);
}
示例7: buildUpQuery
import io.realm.RealmQuery; //导入方法依赖的package包/类
public static RealmResults<Launch> buildUpQuery(Context context, Realm realm) {
SwitchPreferences switchPreferences = SwitchPreferences.getInstance(context);
Date date = new Date();
RealmQuery<Launch> query = realm.where(Launch.class).greaterThanOrEqualTo("net", date).findAll().where();
Integer[] countryFilter = switchPreferences.getUpCountryFiltered();
Integer[] agencyFilter = switchPreferences.getUpAgencyFiltered();
Integer[] locationFilter = switchPreferences.getUpLocationFiltered();
Integer[] vehicleFilter = switchPreferences.getUpVehicleFiltered();
if (countryFilter != null && countryFilter.length > 0) {
ArrayList<String> array = switchPreferences.getUpCountryFilteredArray();
if (array != null && array.size() > 0) {
query = filterCountry(query, array).findAll().where();
} else {
Crashlytics.logException(new Throwable("Error - array is null."));
}
}
if (agencyFilter != null && agencyFilter.length > 0) {
query = filterAgency(query, switchPreferences.getUpAgencyFilteredArray()).findAll().where();
}
if (locationFilter != null && locationFilter.length > 0) {
query = filterLocation(query, switchPreferences.getUpLocationFilteredArray()).findAll().where();
}
if (vehicleFilter != null && vehicleFilter.length > 0) {
query = filterVehicle(query, switchPreferences.getUpVehicleFilteredArray());
}
Timber.v("Returning Query");
return query.findAllSorted("net", Sort.ASCENDING);
}
示例8: getLaunch
import io.realm.RealmQuery; //导入方法依赖的package包/类
private Launch getLaunch() {
Date date = new Date();
switchPreferences = SwitchPreferences.getInstance(context);
Realm mRealm = Realm.getDefaultInstance();
RealmResults<Launch> launchRealms;
if (switchPreferences.getAllSwitch()) {
RealmQuery<Launch> query = mRealm.where(Launch.class)
.greaterThanOrEqualTo("net", date);
if (switchPreferences.getNoGoSwitch()) {
query.equalTo("status", 1);
}
launchRealms = query.findAllSorted("net", Sort.ASCENDING);
Timber.v("loadLaunches - Realm query created.");
} else {
launchRealms = QueryBuilder.buildSwitchQuery(context, mRealm);
Timber.v("loadLaunches - Filtered Realm query created.");
}
for (Launch launch : launchRealms) {
if (launch.getNet() != null) {
return launch;
}
}
return null;
}
示例9: getLaunch
import io.realm.RealmQuery; //导入方法依赖的package包/类
private Launch getLaunch(Context context) {
Date date = new Date();
switchPreferences = SwitchPreferences.getInstance(context);
Realm mRealm = Realm.getDefaultInstance();
RealmResults<Launch> launchRealms;
if (switchPreferences.getAllSwitch()) {
RealmQuery<Launch> query = mRealm.where(Launch.class)
.greaterThanOrEqualTo("net", date);
if (switchPreferences.getNoGoSwitch()) {
query.equalTo("status", 1);
}
launchRealms = query.findAllSorted("net", Sort.ASCENDING);
Timber.v("loadLaunches - Realm query created.");
} else {
launchRealms = QueryBuilder.buildSwitchQuery(context, mRealm);
Timber.v("loadLaunches - Filtered Realm query created.");
}
for (Launch launch : launchRealms) {
if (launch.getNet() != null) {
return launch;
}
}
return null;
}
示例10: getLaunches
import io.realm.RealmQuery; //导入方法依赖的package包/类
private List<Launch> getLaunches(Realm mRealm) {
Timber.d("Getting launches.");
Date date = new Date();
RealmResults<Launch> launchRealms;
if (switchPreferences.getAllSwitch()) {
RealmQuery<Launch> query = mRealm.where(Launch.class)
.greaterThanOrEqualTo("net", date);
if (switchPreferences.getNoGoSwitch()) {
query.equalTo("status", 1);
}
launchRealms = query.findAllSorted("net", Sort.ASCENDING);
Timber.v("loadLaunches - Realm query created.");
} else {
launchRealms = QueryBuilder.buildSwitchQuery(context, mRealm);
Timber.v("loadLaunches - Filtered Realm query created - size: %s", launchRealms.size());
}
for (Launch launch : launchRealms) {
Timber.v("Launch: %s", launch.getName());
if (launches.size() <= 20) {
launches.add(launch);
}
}
Timber.v("Final Launches size: %s", launches.size());
return mRealm.copyFromRealm(launches);
}
示例11: getMessages
import io.realm.RealmQuery; //导入方法依赖的package包/类
public synchronized RealmResults<Message> getMessages(long timestamp) {
Realm realmDb = RealmDb.realm();
RealmQuery<Message> realmQuery;
if (timestamp == 0) {
realmQuery = realmDb.where(Message.class).equalTo("contactId", uniqueUserId);
} else {
realmQuery = realmDb.where(Message.class).equalTo("contactId", uniqueUserId).lessThan("date", timestamp);
}
final RealmResults<Message> messages = realmQuery.findAllSorted("date", Sort.DESCENDING);
realmDb.close();
return messages;
}
示例12: generateResults
import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public RealmResults<SearchHistoryModel> generateResults(Realm realm) {
RealmQuery<SearchHistoryModel> query = realm.where(SearchHistoryModel.class);
query = query.equalTo("searchText", text, Case.INSENSITIVE);
return query.findAllSorted("searchCount", Sort.DESCENDING);
}
示例13: getStartNextLessonInWeek
import io.realm.RealmQuery; //导入方法依赖的package包/类
/**
* Sucht nach der ersten passenden Lehrveranstaltung die als nächstes in der aktuellen Woche stattfindet
*
* @param realm aktuelle Datenbankverbindung
* @param calendar aktuelle Zeitpunkt ab welchem gesucht werden soll
* @return erste passende {@link LessonUser} oder null
*/
@Nullable
private static LessonUser getStartNextLessonInWeek(@NonNull final Realm realm, @NonNull final Calendar calendar) {
final long currentTime = getMinutesSinceMidnight(calendar);
final int currentDs = getCurrentDS(currentTime);
// Nur Lehrveranstaltungen suchen die nicht ausgeblendet werden sollen
final RealmQuery<LessonUser> realmQuery = realm.where(LessonUser.class).equalTo(Const.database.Lesson.HIDE_LESSON, false);
// Lehrveranstaltungen auf aktuelle Woche einschränken
realmQuery.beginGroup()
.equalTo(Const.database.Lesson.WEEK, getWeekTyp(calendar.get(Calendar.WEEK_OF_YEAR)))
.or()
.equalTo(Const.database.Lesson.WEEK, 0)
.endGroup()
.beginGroup()
.isEmpty(Const.database.Lesson.WEEKS_ONLY)
.or().equalTo(Const.database.Lesson.WEEKS_ONLY + ".weekOfYear", calendar.get(Calendar.WEEK_OF_YEAR))
.endGroup();
// Veranstaltungen in der restlichen Woche
realmQuery.beginGroup()
// Veranstaltungen in der restlichen Woche
.greaterThan(Const.database.Lesson.DAY, calendar.get(Calendar.DAY_OF_WEEK) - 1);
// Heutige Lehrveranstaltungen innerhalb der Vorlesungszeit mit berücksichtigen
if (currentDs > 0) {
realmQuery.or()
// Veranstaltungen die noch heute stattfinden, aber...
.beginGroup()
.equalTo(Const.database.Lesson.DAY, calendar.get(Calendar.DAY_OF_WEEK) - 1)
.beginGroup()
// ... erst nach dieser Stunde anfangen ...
.greaterThan(Const.database.Lesson.BEGIN_TIME, endDS[currentDs - 1])
.or()
// ... oder erst nach dieser Stunde enden
.beginGroup()
.greaterThan(Const.database.Lesson.END_TIME, endDS[currentDs - 1])
.lessThan(Const.database.Lesson.END_TIME, currentTime)
.endGroup()
.endGroup()
.endGroup();
}
// Heutige Lehrveranstaltungen vor der der Vorlesungszeit berücksichtigen
else if (currentDs == 0) {
realmQuery.or()
.equalTo(Const.database.Lesson.DAY, calendar.get(Calendar.DAY_OF_WEEK) - 1);
}
realmQuery.endGroup();
// Ergebnisse sortieren und erste Stunde bestimmen
final RealmResults<LessonUser> results = realmQuery.findAllSorted(Const.database.Lesson.DAY, Sort.ASCENDING, Const.database.Lesson.BEGIN_TIME, Sort.ASCENDING);
return results.size() > 0 ? results.first() : null;
}
示例14: buildPrevQuery
import io.realm.RealmQuery; //导入方法依赖的package包/类
public static RealmResults<Launch> buildPrevQuery(Context context, Realm realm) throws ParseException {
SwitchPreferences switchPreferences = SwitchPreferences.getInstance(context);
ListPreferences listPreferences = ListPreferences.getInstance(context);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String start = listPreferences.getStartDate();
String end = listPreferences.getEndDate();
Date sDate;
Date eDate;
sDate = df.parse(start);
eDate = df.parse(end);
RealmQuery<Launch> query = realm.where(Launch.class).between("net", sDate, eDate).findAll().where();
Integer[] countryFilter = switchPreferences.getPrevCountryFiltered();
Integer[] agencyFilter = switchPreferences.getPrevAgencyFiltered();
Integer[] locationFilter = switchPreferences.getPrevLocationFiltered();
Integer[] vehicleFilter = switchPreferences.getPrevVehicleFiltered();
if (countryFilter != null && countryFilter.length > 0) {
query = filterCountry(query, switchPreferences.getPrevCountryFilteredArray()).findAll().where();
}
if (agencyFilter != null && agencyFilter.length > 0) {
query = filterAgency(query, switchPreferences.getPrevAgencyFilteredArray()).findAll().where();
}
if (locationFilter != null && locationFilter.length > 0) {
query = filterLocation(query, switchPreferences.getPrevLocationFilteredArray()).findAll().where();
}
if (vehicleFilter != null && vehicleFilter.length > 0) {
query = filterVehicle(query, switchPreferences.getPrevVehicleFilteredArray());
}
Timber.v("Returning Query");
return query.findAllSorted("net", Sort.DESCENDING);
}