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


Java RealmQuery.findAll方法代码示例

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


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

示例1: searchContacts

import io.realm.RealmQuery; //导入方法依赖的package包/类
private RealmResults<Contact> searchContacts() {
  Contact c = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_SEARCH_FILTERS));
  realm = Realm.getDefaultInstance();
  RealmQuery<Contact> query = realm.where(Contact.class);

  query.contains(LASTNAME, c.lastName, Case.INSENSITIVE)
      .or()
      .contains(FIRSTNAME, c.lastName, Case.INSENSITIVE);

  if (!c.owner) {
    query.equalTo(OWNER, false);
  }

  if (!c.cornac) {
    query.equalTo(CORNAC, false);
  }

  if (!c.vet) {
    query.equalTo(VET, false);
  }

  return query.findAll();
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:24,代码来源:SearchContactResultActivity.java

示例2: getAll

import io.realm.RealmQuery; //导入方法依赖的package包/类
/**
 * Get all for a specific filters
 * @return
 */
@Override
public Flowable<Optional<List<T>>> getAll(Filter filter, SortingMode sortingMode) {
    Realm realm = Realm.getDefaultInstance();
    RealmQuery<T> query = realm.where(clazz);
    query = filterToQuery(filter, query);

    RealmResults<T> items;
    if(sortingMode != null && sortingMode.entries.size() > 0) {
        items = applySortingMode(sortingMode, query);
    } else {
        items = query.findAll();
    }
    List<T> copies = realm.copyFromRealm(items);
    realm.close();

    return Flowable.just(Optional.wrap(copies));
}
 
开发者ID:playmoweb,项目名称:store2realm,代码行数:22,代码来源:RealmDao.java

示例3: searchElephants

import io.realm.RealmQuery; //导入方法依赖的package包/类
private RealmResults<Elephant> searchElephants() {
  Elephant e = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_SEARCH_ELEPHANT));
  RealmQuery<Elephant> query = realm.where(Elephant.class);

  query.contains(NAME, e.name, Case.INSENSITIVE);

  if (e.chips1 != null) {
    query.contains(CHIPS1, e.chips1, Case.INSENSITIVE);
  }

  if (!e.male) {
    query.equalTo(MALE, false);
  }

  if (!e.female) {
    query.equalTo(FEMALE, false);
  }
  return query.findAll();
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:20,代码来源:SearchElephantResultActivity.java

示例4: getMissingConfirmTrips

import io.realm.RealmQuery; //导入方法依赖的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: selectData

import io.realm.RealmQuery; //导入方法依赖的package包/类
void selectData(String name, String phoneNum, String sex, String education, final MaterialDialog materialDialog) {

        Logger.t(TAG).i("name=" + name + "\nphoneNum=" + phoneNum + "\nsex=" + sex + "\neducation=" + education);

        Realm realm = RealmManager.getRealm();

        RealmResults<User> userRealmResults;

        RealmQuery<User> realmQuery = realm.where(User.class)
                .contains("name", name)
                .contains("phoneNum", phoneNum);

        if (!TextUtils.isEmpty(sex)) {
            realmQuery.equalTo("sex", sex);
        }

        if (!TextUtils.isEmpty(education)) {
            realmQuery.equalTo("mExtendBeanRealmList.value", education);
        }
        userRealmResults = realmQuery.findAll();
        loadLatestData(userRealmResults);

        materialDialog.dismiss();
    }
 
开发者ID:chenzj-king,项目名称:RealmSample,代码行数:25,代码来源:SelectFragment.java

示例6: queryDatabaseSingle

import io.realm.RealmQuery; //导入方法依赖的package包/类
/**
 * Query the database
 *
 * @param passedQuery The query to search with. If null is passed here, it will build a default
 *                    query in which it searches everything.
 * @param myClass     Class (table) that is being searched
 * @param <T>         T extends RealmModel (RealmResults)
 * @return An object from the database (one from that table)
 */
public <T extends RealmModel> Object queryDatabaseSingle(RealmQuery<T> passedQuery,
                                                         Class myClass) {

    Realm realm = DatabaseUtilities.buildRealm(this.realmConfiguration);
    if (passedQuery == null) {
        passedQuery = this.buildRealmQuery(realm, myClass);
    }

    //Start transaction
    RealmResults<T> results = passedQuery.findAll();

    if (results != null) {
        Object object = results.get(0);
        return object;
    }

    return null;
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:28,代码来源:DatabaseUtilities.java

示例7: queryDatabaseList

import io.realm.RealmQuery; //导入方法依赖的package包/类
/**
 * Query the database
 *
 * @param passedQuery The query to search with. If null is passed here, it will build a default
 *                    query in which it searches everything.
 * @param myClass     Class (table) that is being searched
 * @param <T>         T extends RealmModel (RealmResults)
 * @return An list of objects from the database (all in that table)
 */
public <T extends RealmModel> List<Object> queryDatabaseList(RealmQuery<T> passedQuery,
                                                             Class myClass) {
    Realm realm = DatabaseUtilities.buildRealm(this.realmConfiguration);
    if (passedQuery == null) {
        passedQuery = this.buildRealmQuery(realm, myClass);
    }

    //Start transaction
    RealmResults<T> results = passedQuery.findAll();
    List<Object> objects = new ArrayList<>();
    //<T extends RealmModel>
    if (results != null) {
        for (T t : results) {
            Object object = (Object) t;
            if (object != null) {
                objects.add(object);
            }
        }
    }
    return objects;
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:31,代码来源:DatabaseUtilities.java

示例8: getStoreInBounds

import io.realm.RealmQuery; //导入方法依赖的package包/类
public static List<Store> getStoreInBounds(double minLat, double minLng, double maxLat, double maxLng) {
    Realm realm = Realm.getDefaultInstance();
    List<Store> storeList = new ArrayList<>();
    // Build the query looking at all users:
    RealmQuery<StoreEntity> query = realm.where(StoreEntity.class);

    // Add query conditions:
    query.between("latitude", minLat, maxLat);
    query.between("longitude", minLng, maxLng);

    // Execute the query:
    RealmResults<StoreEntity> result = query.findAll();

    for (int i = 0; i < result.size(); i++) {
        Store store = new Store(result.get(i));
        storeList.add(store);
    }

    realm.close();

    return storeList;
}
 
开发者ID:HCMUS-AssignmentWarehouse,项目名称:FastFoodFinder,代码行数:23,代码来源:StoreDataSource.java

示例9: queryStoredBeaconEvents

import io.realm.RealmQuery; //导入方法依赖的package包/类
private RealmResults<BeaconEventRealm> queryStoredBeaconEvents(Realm realm,
    List<OrchextraBeacon> beacons) {
  RealmQuery<BeaconEventRealm> query = realm.where(BeaconEventRealm.class);

  for (int i = 0; i < beacons.size(); i++) {

    if (i > 0) {
      query = query.or();
    }

    query = query.equalTo(BeaconEventRealm.CODE_FIELD_NAME, beacons.get(i).getCode())
        .equalTo(BeaconEventRealm.DISTANCE_FIELD_NAME,
            beacons.get(i).getBeaconDistance().getStringValue());
  }

  return query.findAll();
}
 
开发者ID:Orchextra,项目名称:orchextra-android-sdk,代码行数:18,代码来源:ProximityEventsUpdater.java

示例10: testSave1

import io.realm.RealmQuery; //导入方法依赖的package包/类
public void testSave1() {
    // 1. Realm Setup
    RealmConfiguration realmConfig1 = new RealmConfiguration.Builder(getContext()).name("1testSave1.realm").build();
    Realm.deleteRealm(realmConfig1);
    Realm realm1 = Realm.getInstance(realmConfig1);

    // 2. Object Setup
    Dog dog1 = new Dog();
    dog1.setName("Kitty1");

    // 3. RoyalTransaction.save()
    RoyalTransaction.save(realm1, dog1);

    // 4. Query
    RealmQuery<Dog> query = realm1.where(Dog.class);
    RealmResults<Dog> dogs = query.findAll();

    // 5. Assert
    assertNotNull(dogs);
    assertEquals(1, dogs.size());
    assertEquals("Kitty1", dogs.get(0).getName());

    // 6. Realm Close
    realm1.close();
}
 
开发者ID:TheFinestArtist,项目名称:Royal-Android,代码行数:26,代码来源:RoyalTransactionTest.java

示例11: testSave5

import io.realm.RealmQuery; //导入方法依赖的package包/类
public void testSave5() {
    // 1. Realm Setup
    RealmConfiguration realmConfig1 = new RealmConfiguration.Builder(getContext()).name("1testSave5.realm").build();
    Realm.deleteRealm(realmConfig1);
    Realm realm1 = Realm.getInstance(realmConfig1);

    // 2. Object Setup
    Dog dog1 = new Dog();
    dog1.setName("Kitty1");

    // 3. RoyalTransaction.save()
    RoyalTransaction.save(realm1);

    // 4. Query
    RealmQuery<Dog> query = realm1.where(Dog.class);
    RealmResults<Dog> dogs = query.findAll();

    // 5. Assert
    assertNotNull(dogs);
    assertEquals(0, dogs.size());

    // 6. Realm Close
    realm1.close();
}
 
开发者ID:TheFinestArtist,项目名称:Royal-Android,代码行数:25,代码来源:RoyalTransactionTest.java

示例12: fetch

import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public List<Record> fetch() {
    List<Record> records = new ArrayList<>();
    Realm realm = null;
    try {
        realm = Realm.getInstance(realmConfig);
        RealmQuery<RecordObject> query = realm.where(RecordObject.class);
        RealmResults<RecordObject> results = query.findAll();
        for (RecordObject obj : results) {
            records.add(new Record(Utils.forName(obj.getClassName()), obj.getBody()));
        }
        return records;
    } finally {
        if (realm != null)
            realm.close();
    }
}
 
开发者ID:Drivemode,项目名称:TimberLorry,代码行数:18,代码来源:RealmBufferResolver.java

示例13: getPersonFromPersonPOJO

import io.realm.RealmQuery; //导入方法依赖的package包/类
@Override
public RealmList<Person> getPersonFromPersonPOJO(List<PersonPOJO> people) {
    RealmList<Person> listOfPersons = new RealmList<>();

    if (people == null || people.size() == 0) {
        return listOfPersons;
    }

    RealmQuery<Person> query = realm.where(Person.class)
            .equalTo(Person.Column.ID, people.get(0).getId());

    for (int i = 1; i < people.size(); i++) {
        query = query.or().equalTo(Person.Column.ID, people.get(i).getId());
    }

    RealmResults<Person> results = query.findAll();
    for (int i = 0; i < results.size(); i++) {
        listOfPersons.add(results.get(i));
    }

    return listOfPersons;
}
 
开发者ID:ceaseless-prayer,项目名称:CeaselessAndroid,代码行数:23,代码来源:PersonManagerImpl.java

示例14: getLessonsByDateAndDs

import io.realm.RealmQuery; //导入方法依赖的package包/类
/**
 * Liefert eine List der Lehrveranstaltungen des übergebenen Tages und Ds für einen Raum
 *
 * @param realm             aktuelle Datenbankverbindung
 * @param calendar          Tag für welchen die Lehrveranstaltungen gelistet werden soll
 * @param room              Raum für welchen die Belegung angezeigt werden soll
 * @param ds                Zeit in welcher die Lehrveranstaltungen stattfinden sollen
 * @param filterCurrentWeek Nur Lehrveranstaltungen der aktuellen Kalenderwoche zurückgeben
 * @return Liste von passenden Lehrveranstaltungen
 */
public static RealmResults<LessonRoom> getLessonsByDateAndDs(@NonNull final Realm realm, @NonNull final Calendar calendar, @NonNull final String room, final int ds,
                                                             final boolean filterCurrentWeek) {
    final int dsIndex = ds > 0 ? ds - 1 : 0;
    final RealmQuery<LessonRoom> realmQuery = realm.where(LessonRoom.class)
            .equalTo(Const.database.LessonRoom.ROOM, room)
            .equalTo(Const.database.Lesson.DAY, calendar.get(Calendar.DAY_OF_WEEK) - 1)
            // Nach Kalenderwoche einschränken
            .beginGroup()
            .equalTo(Const.database.Lesson.WEEK, getWeekTyp(calendar.get(Calendar.WEEK_OF_YEAR)))
            .or().equalTo(Const.database.Lesson.WEEK, 0)
            .endGroup()
            // Vor dem Ende dieser DS beginnen und länger gehen als DS startet
            .lessThan(Const.database.Lesson.BEGIN_TIME, Const.Timetable.endDS[dsIndex])
            .greaterThan(Const.database.Lesson.END_TIME, Const.Timetable.beginDS[dsIndex]);

    if (filterCurrentWeek) {
        realmQuery.beginGroup()
                .isEmpty(Const.database.Lesson.WEEKS_ONLY)
                .or().equalTo(Const.database.Lesson.WEEKS_ONLY + ".weekOfYear", calendar.get(Calendar.WEEK_OF_YEAR))
                .endGroup();
    }

    return realmQuery.findAll();
}
 
开发者ID:HTWDD,项目名称:HTWDresden,代码行数:35,代码来源:TimetableRoomHelper.java

示例15: applySortingMode

import io.realm.RealmQuery; //导入方法依赖的package包/类
private RealmResults<T> applySortingMode(SortingMode sm, RealmQuery<T> query){
    KeysAndSorts keysAndSorts = convertSortingMode(sm);
    if(keysAndSorts != null){
        return query.findAllSortedAsync(keysAndSorts.key, keysAndSorts.sort);
    }
    return query.findAll();
}
 
开发者ID:playmoweb,项目名称:store2realm,代码行数:8,代码来源:RealmDao.java


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