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


Java RealmResults.isEmpty方法代碼示例

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


在下文中一共展示了RealmResults.isEmpty方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOne

import io.realm.RealmResults; //導入方法依賴的package包/類
/**
 * Get one with a specific filter object
 * @param filter
 * @return
 */
@Override
public Flowable<Optional<T>> getOne(Filter filter, SortingMode sortingMode) {
    Realm realm = Realm.getDefaultInstance();
    RealmQuery<T> query = realm.where(clazz);
    query = filterToQuery(filter, query);
    T item = null;
    if (sortingMode != null) {
        RealmResults<T> items = applySortingMode(sortingMode, query);
        if (!items.isEmpty()) {
            item = items.first();
        }
    } else {
        item = query.findFirst();
    }
    T copy = null;
    if (item != null) {
        copy = realm.copyFromRealm(item);
    }
    realm.close();
    return Flowable.just(Optional.wrap(copy));
}
 
開發者ID:playmoweb,項目名稱:store2realm,代碼行數:27,代碼來源:RealmDao.java

示例2: loadCurrentActivityData

import io.realm.RealmResults; //導入方法依賴的package包/類
@Nullable
public List<CurrentActivityData> loadCurrentActivityData() {
    RealmResults<CurrentActivityData> results = realm.where(CurrentActivityData.class).findAll();
    if (!results.isEmpty()) {
        List<CurrentActivityData> data = new ArrayList<>();
        int resultsNum = results.size() - 1;
        if (resultsNum >= 10) {
            for (int i = resultsNum; i >= resultsNum - 10; i--)
                data.add(results.get(i));
        } else {
            for (int i = resultsNum; i >= 0; i--) data.add(results.get(i));
        }
        return data;
    }
    return null;
}
 
開發者ID:Omico,項目名稱:CurrentActivity,代碼行數:17,代碼來源:CurrentActivity.java

示例3: makeGlucoseData

import io.realm.RealmResults; //導入方法依賴的package包/類
private GlucoseData makeGlucoseData(Realm realmProcessedData, int glucoseLevelRaw, int ageInSensorMinutes, long dataDate) {
    // if this data point has been read from this sensor before, reuse the object form the database, instead of changing the old data
    RealmResults<GlucoseData> previousGlucoseData = realmProcessedData.where(GlucoseData.class)
            .equalTo(GlucoseData.ID, GlucoseData.generateId(sensor, ageInSensorMinutes, false, glucoseLevelRaw)).findAll();

    // check if a valid previous data point was found
    if (!previousGlucoseData.isEmpty()) {
        if (previousGlucoseData.first().getGlucoseLevelRaw() == glucoseLevelRaw) {
            return previousGlucoseData.first();
        }
        // if the old value does not equal the new one and the sensor has been running for more than three hours, there is an error in the data
        if (ageInSensorMinutes > 3 * minSensorAgeInMinutes) {
            Log.e("OpenLibre::ReadingData", "error in glucose level raw:" + previousGlucoseData.first().getGlucoseLevelRaw() + " != " + glucoseLevelRaw
                    + " for glucose data with id: " + previousGlucoseData.first().getId());
            history.clear();
            trend.clear();
            return null;
        }
    }
    return new GlucoseData(sensor, ageInSensorMinutes, timezoneOffsetInMinutes, glucoseLevelRaw, false, dataDate);
}
 
開發者ID:DorianScholz,項目名稱:OpenLibre,代碼行數:22,代碼來源:ReadingData.java

示例4: isPackageExist

import io.realm.RealmResults; //導入方法依賴的package包/類
/**
 * Query the existence of a specific number.
 * @param packageId the package number to query.
 *                  See {@link Package#number}
 * @return whether the number is in the database.
 */
@Override
public boolean isPackageExist(@NonNull String packageId) {
    Realm rlm = RealmHelper.newRealmInstance();
    RealmResults<Package> results = rlm.where(Package.class)
            .equalTo("number", packageId)
            .findAll();
    return (results != null) && (!results.isEmpty());
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:15,代碼來源:PackagesLocalDataSource.java

示例5: getCurrentActivity

import io.realm.RealmResults; //導入方法依賴的package包/類
@NonNull
private String getCurrentActivity(Context context) {
    String packageName = null;
    String activityName = null;
    String applicationName;

    switch (Settings.getString(Settings.Mode.SELECTION, Settings.Mode.NONE)) {
        case Settings.Mode.ROOT:
            String request = SU.getSU().runCommand("dumpsys activity | grep \"mFocusedActivity\"");

            if (!TextUtils.isEmpty(request)) {
                String requests[] = request.split(" ")[3].split("/");

                packageName = requests[0];
                activityName = requests[1].substring(0, 1).equals(".") ? requests[0] + requests[1] : requests[1];
            }
            break;
        case Settings.Mode.ACCESSIBILITY_SERVICE:
            if (AccessibilityServiceUtils.isAccessibilityServiceEnabled(context, CurrentActivityAccessibilityService.class)) {
                packageName = CurrentActivityAccessibilityService.foregroundPackageName();
                activityName = CurrentActivityAccessibilityService.foregroundClassName();
                if (packageName.equals("null") || activityName.equals("null")) return "";
            } else {
                return context.getString(R.string.should_re_enable_accessibility_service);
            }
            break;
    }

    if (packageName != null && activityName != null) {
        applicationName = ApplicationUtil.getApplicationNameByPackageName(context, packageName);
        if (applicationName != null) {
            RealmResults<CurrentActivityData> results = realm.where(CurrentActivityData.class).findAll();
            if (!Objects.equals(packageName, getPackageName())) {
                if (results.isEmpty()) {
                    saveCurrentActivityData(applicationName, packageName, activityName);
                } else {
                    CurrentActivityData lastData = results.get(results.size() - 1);
                    if (!Objects.equals(lastData.getPackageName(), packageName) || !Objects.equals(lastData.getActivityName(), activityName))
                        saveCurrentActivityData(applicationName, packageName, activityName);
                }
            }
            return (applicationName + " ( " + packageName + " )" + "\n" + activityName);
        } else {
            return (packageName + "\n" + activityName);
        }
    } else {
        return context.getString(R.string.failed_to_get);
    }
}
 
開發者ID:Omico,項目名稱:CurrentActivity,代碼行數:50,代碼來源:CurrentActivity.java

示例6: deleteBlog

import io.realm.RealmResults; //導入方法依賴的package包/類
public static void deleteBlog(@NonNull String blogUrl) {
    RealmResults<BlogMetadata> matchingBlogs = findAllBlogsMatchingUrl(blogUrl);
    if (matchingBlogs.isEmpty()) {
        throw new IllegalStateException("No blog found matching the URL: " + blogUrl);
    }
    // we don't allow adding more than 1 blog with the same URL, so this should never happen
    if (matchingBlogs.size() > 1) {
        throw new IllegalStateException("More than 1 blog found matching the URL: " + blogUrl);
    }

    // delete blog metadata before data because data without metadata is harmless, but vice-versa is not
    // keep a copy of the metadata around so we can delete the data Realm after this
    final Realm realm = Realm.getDefaultInstance();
    BlogMetadata blogToDelete = matchingBlogs.get(0);
    RealmConfiguration dataRealmToDelete = realm.copyFromRealm(blogToDelete).getDataRealmConfig();
    RealmUtils.executeTransaction(realm, r -> {
        RealmObject.deleteFromRealm(blogToDelete);
    });

    // delete blog data
    Realm.deleteRealm(dataRealmToDelete);

    // if the active blog was deleted, set the active blog to a different one
    if (blogUrl.equals(getActiveBlogUrl())) {
        List<BlogMetadata> allBlogs = getAllBlogs();
        if (!allBlogs.isEmpty()) {
            setActiveBlog(allBlogs.get(0).getBlogUrl());
        } else {
            setActiveBlog("");
        }
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:33,代碼來源:AccountManager.java


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