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


Java RealmQuery.equalTo方法代碼示例

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


在下文中一共展示了RealmQuery.equalTo方法的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: 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

示例3: 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

示例4: getItems

import io.realm.RealmQuery; //導入方法依賴的package包/類
@Override
public List<Item> getItems(Realm realm, boolean onlyUnread) {
    // Get all feeds belonging to Folder treeItem
    List<Feed> feeds = getFeeds(realm, onlyUnread);
    RealmQuery<Item> query = null;
    if(feeds != null && feeds.size() > 0) {
        // Find all items belonging to any feed from this folder
        Iterator<Feed> feedIterator = feeds.iterator();
        query = realm.where(Item.class).beginGroup()
                .equalTo(Item.FEED_ID, feedIterator.next().getId());
        while (feedIterator.hasNext()) {
            query.or().equalTo(Item.FEED_ID, feedIterator.next().getId());
        }
        query.endGroup();
        if(onlyUnread)
            query.equalTo(Item.UNREAD, true);
    }
    return query != null ? query.distinct(Item.FINGERPRINT) : null;
}
 
開發者ID:schaal,項目名稱:ocreader,代碼行數:20,代碼來源:Folder.java

示例5: queryEqualTo

import io.realm.RealmQuery; //導入方法依賴的package包/類
public static <E extends RealmObject> RealmResults<E> queryEqualTo(final Realm realm, final Class<E> eClass, final String field, final boolean... filters) {

        try {
            final RealmQuery<E> realmQuery = realm.where(eClass);
            int i = 0;
            for (final boolean filter : filters) {
                if (i != 0)
                    realmQuery.or();
                realmQuery.equalTo(field, filter);
                i++;
            }
            return getRealmResults(realmQuery);
        } catch (Exception e) {
            Log.d(TAG, "", e);
            return null;
        }

    }
 
開發者ID:murielK,項目名稱:AndroidWPTemplate,代碼行數:19,代碼來源:RealmHelper.java

示例6: 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);
    }
}
 
開發者ID:koustuvsinha,項目名稱:androidSensorsDemo,代碼行數:23,代碼來源:DisplaySensorHistoryData.java

示例7: displayLaunches

import io.realm.RealmQuery; //導入方法依賴的package包/類
public void displayLaunches() {
    Timber.v("loadLaunches...");
    Calendar calendar = Calendar.getInstance();
    if (switchPreferences.getPersistSwitch()) {
        calendar.add(Calendar.HOUR_OF_DAY, -24);
    }
    Date date = calendar.getTime();

    if (switchPreferences.getAllSwitch()) {
        RealmQuery<Launch> query = getRealm().where(Launch.class)
                .greaterThanOrEqualTo("net", date);
        if (switchPreferences.getNoGoSwitch()) {
            query.equalTo("status", 1);
        }
        launchRealms = query.findAllSortedAsync("net", Sort.ASCENDING);
        launchRealms.addChangeListener(callback);
        Timber.v("loadLaunches - Realm query created.");
    } else {
        filterLaunchRealm();
        Timber.v("loadLaunches - Filtered Realm query created.");
    }
}
 
開發者ID:ItsCalebJones,項目名稱:SpaceLaunchNow-Android,代碼行數:23,代碼來源:NextLaunchFragment.java

示例8: getQuery

import io.realm.RealmQuery; //導入方法依賴的package包/類
private static RealmResults<Photos> getQuery(Context context, Realm realm) {
    String feature = Settings.getFeature(context);
    RealmQuery<Photos> query = realm.where(Photos.class);
    if (feature.equals("search")) {
        query.equalTo("search", Settings.getSearchQuery(context));
    } else {
        query.equalTo("feature", feature);
    }

    query.beginGroup();
    int[] categories = Settings.getCategories(context);
    for (int i = 0; i < categories.length - 1; i++) {
        query.equalTo("category", categories[i])
                .or();
    }
    query.equalTo("category", categories[categories.length - 1])
            .endGroup();

    return query.equalTo("seen", false)
            .findAllSorted(new String[] { "failedCount", "highestRating", "views", "createdAt" },
                    new Sort[] { Sort.ASCENDING, Sort.DESCENDING, Sort.DESCENDING, Sort.ASCENDING });
}
 
開發者ID:lkorth,項目名稱:photo-paper,代碼行數:23,代碼來源:Photos.java

示例9: copyToRealmQuery

import io.realm.RealmQuery; //導入方法依賴的package包/類
public <O extends RealmObject> RealmQuery<O> copyToRealmQuery(RealmQuery<O> query){

        Iterator it = filters.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry)it.next();
            if(pair.getValue() instanceof  Byte){
                query.equalTo((String) pair.getKey(), (Byte) pair.getValue());
            } else if(pair.getValue() instanceof  Boolean){
                query.equalTo((String) pair.getKey(), (Boolean) pair.getValue());
            } else if(pair.getValue() instanceof  Date){
                query.equalTo((String) pair.getKey(), (Date) pair.getValue());
            } else if(pair.getValue() instanceof  byte[]){
                query.equalTo((String) pair.getKey(), (byte[]) pair.getValue());
            } else if(pair.getValue() instanceof  Integer){
                query.equalTo((String) pair.getKey(), (Integer) pair.getValue());
            } else if(pair.getValue() instanceof  Short){
                query.equalTo((String) pair.getKey(), (Short) pair.getValue());
            } else if(pair.getValue() instanceof  Long){
                query.equalTo((String) pair.getKey(), (Long) pair.getValue());
            } else if(pair.getValue() instanceof  Float){
                query.equalTo((String) pair.getKey(), (Float) pair.getValue());
            } else if(pair.getValue() instanceof  Double){
                query.equalTo((String) pair.getKey(), (Double) pair.getValue());
            } else if(pair.getValue() instanceof  String){
                query.equalTo((String) pair.getKey(), (String) pair.getValue());
            }
            it.remove();
        }
        return query;
    }
 
開發者ID:rezkyatinnov,項目名稱:kyandroid,代碼行數:31,代碼來源:QueryFilters.java

示例10: generateResults

import io.realm.RealmQuery; //導入方法依賴的package包/類
@Override
public RealmResults<SearchModel> generateResults(Realm realm) {
    RealmQuery<SearchModel> query = realm.where(SearchModel.class);
    query = query.equalTo("languageCode", language, Case.INSENSITIVE);
    query = query.equalTo("versionCode", version, Case.INSENSITIVE);
    return query.findAll().sort("timeStamp", Sort.DESCENDING);
}
 
開發者ID:friendsofagape,項目名稱:Autographa-Go,代碼行數:8,代碼來源:AllSpecifications.java

示例11: queryPlacesInProjects

import io.realm.RealmQuery; //導入方法依賴的package包/類
private static RealmQuery<Place> queryPlacesInProjects(Realm realm, RealmResults<Project> projects) {
    Set<String> placeIds = new HashSet<>();
    for (Project project : projects) {
        for (Place place : project.getPlaces()) {
            placeIds.add(place.getId());
        }
    }
    RealmQuery<Place> query = realm.where(Place.class);
    if (placeIds.isEmpty()) {
        query = query.equalTo("id", "non-existing-id-to-hack-empty-realmresult");
    } else {
        query.in("id", placeIds.toArray(new String[placeIds.size()]));
    }
    return query;
}
 
開發者ID:Turistforeningen,項目名稱:SjekkUT,代碼行數:16,代碼來源:Place.java

示例12: getItems

import io.realm.RealmQuery; //導入方法依賴的package包/類
@Override
public List<Item> getItems(Realm realm, boolean onlyUnread) {
    final RealmQuery<Item> query = realm.where(Item.class);
    if(onlyUnread)
        query.equalTo(Item.UNREAD, true);
    return query.distinct(Item.FINGERPRINT);
}
 
開發者ID:schaal,項目名稱:ocreader,代碼行數:8,代碼來源:AllUnreadFolder.java

示例13: getItems

import io.realm.RealmQuery; //導入方法依賴的package包/類
@Override
public List<Item> getItems(Realm realm, boolean onlyUnread) {
    final RealmQuery<Item> query = realm.where(Item.class).equalTo(Item.FEED_ID, id);
    if(onlyUnread)
        query.equalTo(Item.UNREAD, true);
    return query.findAll();
}
 
開發者ID:schaal,項目名稱:ocreader,代碼行數:8,代碼來源:Feed.java

示例14: onCreate

import io.realm.RealmQuery; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    realm = Realm.getInstance(getActivity());
    SensorManagement sensorManagement = new SensorManagement(getActivity());
    if(savedInstanceState!=null) {
        selectedSensor = savedInstanceState.getInt(Constants.SELECTED_SENSOR);
    } else {
        Bundle args = getArguments();
        selectedSensor = args.getInt(Constants.SELECTED_SENSOR);
    }
    mSensor =  sensorManagement.getSensorByType(selectedSensor);
    mSensorManager = sensorManagement.getSensorManager();

    mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
    RealmQuery<SensorModel> query = realm.where(SensorModel.class);
    // convert today's date in String
    String todayDate = new SimpleDateFormat(Constants.DATE_FORMAT).format(Calendar.getInstance().getTime());
    query.equalTo("recordDate",todayDate);
    query.equalTo("sensorType",mSensor.getType());
    RealmResults<SensorModel> result = query.findAll();
    if(result.size() > 0) {
        sensorModel =  result.get(0);

        Log.i(Constants.TAG_NAME, "Record found, loading the record");

        sensorMax1 = sensorModel.getSensorMax1();
        sensorMax2 = sensorModel.getSensorMax2();
        sensorMax3 = sensorModel.getSensorMax3();
        sensorMin1 = sensorModel.getSensorMin1();
        sensorMin2 = sensorModel.getSensorMin2();
        sensorMin3 = sensorModel.getSensorMin3();

    } else {
        sensorModel = new SensorModel();
        Log.i(Constants.TAG_NAME,"Record not found, intializing the record");
        isFirst = true;
    }
}
 
開發者ID:koustuvsinha,項目名稱:androidSensorsDemo,代碼行數:40,代碼來源:DisplayRawSensorData.java

示例15: getLessonsByDateAndDs

import io.realm.RealmQuery; //導入方法依賴的package包/類
/**
 * Liefert eine List der Lehrveranstaltungen des übergebenen Tages und Ds
 *
 * @param realm aktuelle Datenbankverbindung
 * @param calendar Tag für welchen die Lehrveranstaltungen gelistet werden soll
 * @param ds Zeit in welcher die Lehrveranstaltungen stattfinden sollen
 * @param filterCurrentWeek Nur Lehrveranstaltungen der aktuellen Kalenderwoche zurückgeben
 * @param showHiddenLessons versteckte Lehrveranstaltungen mit anzeigen
 * @return Liste von passenden Lehrveranstaltungen
 */
public static RealmResults<LessonUser> getLessonsByDateAndDs(@NonNull final Realm realm, @NonNull final Calendar calendar, final int ds, final boolean filterCurrentWeek,
                                                             final boolean showHiddenLessons) {
    final int dsIndex = ds > 0 ? ds - 1 : 0;
    final RealmQuery<LessonUser> realmQuery = realm.where(LessonUser.class)
            .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();
    }

    // Versteckte Lehrveranstaltungen ausschließen
    if (!showHiddenLessons) {
        realmQuery.equalTo(Const.database.Lesson.HIDE_LESSON, false);
    }

    return realmQuery.findAll();
}
 
開發者ID:HTWDD,項目名稱:HTWDresden,代碼行數:39,代碼來源:TimetableHelper.java


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