Java 类io.realm.Case 实例源码

项目:ElephantAsia    文件:SearchContactResultActivity.java   
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();
}
项目:Espresso    文件:PackagesLocalDataSource.java   
@Override
public Observable<List<Package>> searchPackages(@NonNull String keyWords) {
    Realm rlm = RealmHelper.newRealmInstance();
    return Observable.fromIterable(rlm.copyFromRealm(
            rlm.where(Package.class)
                    .like("name", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("companyChineseName", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("company", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("number", "*" + keyWords + "*", Case.INSENSITIVE)
                    .findAll()))
            .toList()
            .toObservable();
}
项目:Espresso    文件:CompaniesLocalDataSource.java   
@Override
public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
    Realm rlm = RealmHelper.newRealmInstance();
    List<Company> results = rlm.copyFromRealm(
            rlm.where(Company.class)
                    .like("name","*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("tel", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("website", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("alphabet", "*" + keyWords + "*", Case.INSENSITIVE)
                    .findAllSorted("alphabet", Sort.ASCENDING));
    return Observable.fromIterable(results)
            .toList()
            .toObservable();
}
项目:ElephantAsia    文件:SearchElephantResultActivity.java   
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();
}
项目:Minerva    文件:LibraryFragment.java   
/**
 * Queries Realm to get the {@link #books} list. Uses the given {@code filter} and keeps the current sort method and
 * direction. This method does NOT update the adapter.
 * @param filter String to use to filter the list. Can be {@code null}/empty.
 */
private void getBooksList(String filter) {
    this.filter = filter;
    if (filter == null || filter.isEmpty())
        books = realm.where(RBook.class)
                     .findAllSorted(sortType.getRealmFields(), sortDir.getRealmSort(sortType.getNumRealmFields()));
    else
        books = realm.where(RBook.class)
                     .contains("title", filter, Case.INSENSITIVE)
                     .or()
                     .contains("author", filter, Case.INSENSITIVE)
                     .findAllSorted(sortType.getRealmFields(), sortDir.getRealmSort(sortType.getNumRealmFields()));

    books.addChangeListener(emptyListener);
    // TODO Might need to manually call toggleEmptyState() here.
}
项目:RxJavaTeamworkClient    文件:LatestActivityRealmRepository.java   
@Override
public Observable<List<LatestActivityDto>> searchItems(String searchString) {

    Realm realm = realmManager.newRealm();

    RealmResults<LatestActivityModel> realmResults = realm.where(LatestActivityModel.class)
            .contains("description", searchString, Case.INSENSITIVE)
            .or()
            .contains("fromUsername", searchString, Case.INSENSITIVE)
            .or()
            .contains("formattedDescription", searchString, Case.INSENSITIVE)
            .findAll();

    Observable<List<LatestActivityDto>> observable = Observable.just(latestActivityModelToDtoMapper.map(realmResults));

    realm.close();

    return observable;
}
项目:realm-helpers    文件:MainActivity.java   
public void filterResults(String text) {
    Realm realm = realmManager.getLocalInstance();
    text = text == null ? null : text.toLowerCase().trim();
    if(text == null || "".equals(text)) {
        updateData(realm.where(Cat.class).findAllAsync());
    } else {
        updateData(realm
                .where(Cat.class)
                .contains(CatFields.NAME, text, Case.INSENSITIVE)
                .findAllAsync());
    }
}
项目:realm-helpers    文件:MainActivity.java   
public void filterResults(String text) {
    Realm realm = realmManager.getLocalInstance();
    text = text == null ? null : text.toLowerCase().trim();
    if(text == null || "".equals(text)) {
        updateData(realm.where(Cat.class).findAllAsync());
    } else {
        updateData(realm
                .where(Cat.class)
                .contains(CatFields.NAME, text, Case.INSENSITIVE)
                .findAllAsync());
    }
}
项目:CleanArchitecture    文件:GetMovieInteractor.java   
@Override
public void getMovieForTitle(String title, String type) {
    if (getPresenterContract() != null) {
        Movie movie = mRealm.where(Movie.class).equalTo("Title", title, Case.INSENSITIVE).findFirst();
        if (movie != null) {
            showGetMovieSuccess(movie);
        } else {
            mOmdbApiObservables.getMovieForTitle(title, type).subscribe(getSingleSubscriber(this));
        }
    }
}
项目:SjekkUT    文件:Place.java   
public static RealmResults<Place> findNamedPlacesSortedAsync(Realm realm, String name) {
    RealmQuery<Place> query = realm.where(Place.class);
    if (name != null && name.length() > 0) {
        query.contains("name", name, Case.INSENSITIVE);
    }
    return query.findAllSortedAsync("name", Sort.ASCENDING);
}
项目:SjekkUT    文件:Project.java   
public static RealmResults<Project> findAllActiveOrRecentProjectsWithNameAsync(Realm realm, long slack, String name) {
    RealmQuery<Project> query = queryAllActiveOrRecentProjects(realm, slack);
    if (name != null && name.length() > 0) {
        query.contains("name", name, Case.INSENSITIVE);
    }
    return query.findAllAsync();
}
项目:SjekkUT    文件:Project.java   
public static RealmResults<Project> findNamedProjectsSortedAsync(Realm realm, String name) {
    RealmQuery<Project> query = realm.where(Project.class);
    if (name != null && name.length() > 0) {
        query.contains("name", name, Case.INSENSITIVE);
    }
    return query.findAllSortedAsync("name", Sort.ASCENDING);
}
项目:KSAnime    文件:MainActivity.java   
/** SEARCH **/
@Override
public boolean onQueryTextChange(String newText) {
    if (newText.length() < 1) {
        int items = searchList.size();
        searchList.clear();
        searchView.getAdapter().notifyItemRangeRemoved(0, items);
        return false;
    }
    Realm realm = Realm.getDefaultInstance();
    RealmResults<Anime> queryResult = realm.where(Anime.class).beginsWith("title", newText, Case.INSENSITIVE).findAll();
    int searchSize = searchList.size();
    int querySize = queryResult.size();
    int minSize = (searchSize > querySize) ? querySize : searchSize;
    for (int i = 0; i < minSize; i++) {
        if (!searchList.get(i).equals(queryResult.get(i).title)) {
            searchList.set(i, queryResult.get(i).title);
            searchView.getAdapter().notifyItemChanged(i);
        }
    }
    if (querySize > searchSize) {
        for (int i = minSize; i < querySize; i++) {
            searchList.add(queryResult.get(i).title);
        }
        searchView.getAdapter().notifyItemRangeInserted(minSize, querySize - minSize);
    } else {
        for (int i = minSize; i < searchSize; i++) {
            searchList.remove(minSize);
        }
        searchView.getAdapter().notifyItemRangeRemoved(minSize, searchSize - minSize);
    }
    realm.close();
    return false;
}
项目:toshi-android-client    文件:ContactStore.java   
public Single<List<Contact>> searchByName(final String query) {
    return Single.fromCallable(() -> {
        final Realm realm = BaseApplication.get().getRealm();
        final RealmQuery<Contact> realmQuery = realm.where(Contact.class);
        realmQuery
                .contains("user.username", query, Case.INSENSITIVE)
                .or()
                .contains("user.name", query, Case.INSENSITIVE);

        final List<Contact> result = realm.copyFromRealm(realmQuery.findAll());
        realm.close();
        return result;
    });
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<VersionModel> generateResults(Realm realm) {
    RealmQuery<VersionModel> query = realm.where(VersionModel.class);
    query = query.equalTo("languageCode", languageCode, Case.INSENSITIVE);
    query = query.equalTo("versionCode", versionCode, Case.INSENSITIVE);
    return query.findAll();
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<BookModel> generateResults(Realm realm) {
    RealmQuery<BookModel> query = realm.where(BookModel.class);
    query = query.equalTo("languageCode", language, Case.INSENSITIVE);
    query = query.equalTo("versionCode", version, Case.INSENSITIVE);
    return query.findAll().sort("bookNumber");
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<BookModel> generateResults(Realm realm) {
    RealmQuery<BookModel> query = realm.where(BookModel.class);
    query = query.equalTo("languageCode", language, Case.INSENSITIVE);
    query = query.equalTo("versionCode", version, Case.INSENSITIVE);
    query = query.contains("bookName", text, Case.INSENSITIVE);
    return query.findAll().sort("bookNumber");
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<VerseComponentsModel> generateResults(Realm realm) {
    RealmQuery<VerseComponentsModel> query = realm.where(VerseComponentsModel.class);
    query = query.equalTo("languageCode", language, Case.INSENSITIVE);
    query = query.equalTo("versionCode", version, Case.INSENSITIVE);
    query = query.contains("text", text, Case.INSENSITIVE);
    return query.findAll().distinct("chapterId", "verseNumber");
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
        public RealmResults<NotesModel> generateResults(Realm realm) {
            RealmQuery<NotesModel> query = realm.where(NotesModel.class);
            query = query.equalTo("languageCode", language, Case.INSENSITIVE);
//            query = query.equalTo("versionCode", version, Case.INSENSITIVE);
            return query.findAll().sort("timestamp", Sort.DESCENDING);
        }
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<NotesModel> generateResults(Realm realm) {
    RealmQuery<NotesModel> query = realm.where(NotesModel.class);
    query = query.equalTo("timestamp", id);
    query = query.equalTo("languageCode", language, Case.INSENSITIVE);
    query = query.equalTo("versionCode", version, Case.INSENSITIVE);
    return query.findAll();
}
项目:Autographa-Go    文件:AllSpecifications.java   
@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);
}
项目:GitHub    文件:TableQuery.java   
public TableQuery equalTo(long[] columnIndexes, long[] tablePtrs, @Nullable String value, Case caseSensitive) {
    nativeEqual(nativePtr, columnIndexes, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:GitHub    文件:TableQuery.java   
public TableQuery notEqualTo(long[] columnIndex, long[] tablePtrs, @Nullable String value, Case caseSensitive) {
    nativeNotEqual(nativePtr, columnIndex, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:GitHub    文件:TableQuery.java   
public TableQuery beginsWith(long[] columnIndices, long[] tablePtrs, String value, Case caseSensitive) {
    nativeBeginsWith(nativePtr, columnIndices, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:GitHub    文件:TableQuery.java   
public TableQuery endsWith(long[] columnIndices, long[] tablePtrs, String value, Case caseSensitive) {
    nativeEndsWith(nativePtr, columnIndices, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:GitHub    文件:TableQuery.java   
public TableQuery like(long[] columnIndices, long[] tablePtrs, String value, Case caseSensitive) {
    nativeLike(nativePtr, columnIndices, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:GitHub    文件:TableQuery.java   
public TableQuery contains(long[] columnIndices, long[] tablePtrs, String value, Case caseSensitive) {
    nativeContains(nativePtr, columnIndices, tablePtrs, value, caseSensitive.getValue());
    queryValidated = false;
    return this;
}
项目:android-realm-builders    文件:StringConditionBuilder.java   
public B beginsWith(String value, Case casing) {
    this.builder.query.beginsWith(fieldName, value, casing);
    return builder;
}
项目:android-realm-builders    文件:StringConditionBuilder.java   
public B endsWith(String value, Case casing) {
    this.builder.query.endsWith(fieldName, value, casing);
    return builder;
}
项目:android-realm-builders    文件:StringConditionBuilder.java   
public B contains(String value, Case casing) {
    this.builder.query.contains(fieldName, value, casing);
    return builder;
}
项目:android-realm-builders    文件:StringConditionBuilder.java   
public B in(String[] values, Case casing) {
    this.builder.query.in(fieldName, values, casing);
    return builder;
}
项目:RxJavaTeamworkClient    文件:ProjectRealmRepository.java   
@Override
public Observable<List<ProjectDto>> searchItems(String searchString) {

    Realm realm = realmManager.newRealm();

    RealmResults<ProjectRealmModel> realmModels = realm.where(ProjectRealmModel.class)
            .contains("name", searchString, Case.INSENSITIVE)
            .findAll();

    List<ProjectDto> projectDtoList = new ArrayList<>(realmModels.size());

    for(ProjectRealmModel projectRealmModel : realmModels){

        projectDtoList.add(projectModelToDtoMapper.map(projectRealmModel));

    }

    return Observable.just(projectDtoList);
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<LanguageModel> generateResults(Realm realm) {
    RealmQuery<LanguageModel> query = realm.where(LanguageModel.class);
    query = query.equalTo("languageCode", code, Case.INSENSITIVE);
    return query.findAll();
}
项目:Autographa-Go    文件:AllSpecifications.java   
@Override
public RealmResults<BookModel> generateResults(Realm realm) {
    RealmQuery<BookModel> query = realm.where(BookModel.class);
    query = query.equalTo("bookPrimaryId", language+"_"+version+"_"+bookId, Case.INSENSITIVE);
    return query.findAll();
}
项目:Autographa-Go    文件:AllSpecifications.java   
@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);
}