Multiple queries in Realm

0

I am trying to perform different searches on the same query. That is, on a RealmQuery look for a series of colors that match the ones I want and then look for a series of types. Putting all this in the same query

            ArrayList<Integer> listColor = myAdapterColor.getListSelected();
            ArrayList<Integer> listType = myAdapterType.getListSelected();
            ArrayList<Integer> listStyle = myAdapterStyle.getListSelected();
            ArrayList<Integer> listSeason = myAdapterSeason.getListSelected();


            clothesRealmQuery = realm.where(Clothes.class);

            int x = 0;

            for(Integer id : listColor) {
                if (x++ > 0)
                    clothesRealmQuery = clothesRealmQuery.or();
                clothesRealmQuery = clothesRealmQuery.equalTo("colorId", id);
            }

            x = 0;
            for(Integer id : listType) {
                if (x++ > 0)
                    clothesRealmQuery = clothesRealmQuery.or();
                clothesRealmQuery = clothesRealmQuery.equalTo("typeId", id);
            }

            clothes = clothesRealmQuery.findAll(); //private RealmResults<Clothes> clothes;
    
asked by CMorillo 05.05.2018 в 19:12
source

0 answers