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


Java RealmResults.get方法代碼示例

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


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

示例1: init

import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public void init() {
    RealmResults<TodoList> listResults = todoRepository.queryList(listId);
    list = listResults.get(0);
    view.initViews(list.getTitle());

    bindData();
    list.addChangeListener(new RealmChangeListener<RealmModel>() {
        @Override
        public void onChange(RealmModel element) {
            if (view != null) {
                bindData();
                view.notifyDataChanged(list.getTitle());
            }
        }
    });
}
 
開發者ID:mengdd,項目名稱:TodoRealm,代碼行數:18,代碼來源:ListDetailPresenter.java

示例2: init

import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public void init(long taskId) {
    RealmResults<Task> taskResults = repository.queryTask(taskId);
    if (taskResults.size() > 0) {
        task = taskResults.get(0);
    }
    task.addChangeListener(new RealmChangeListener<RealmModel>() {
        @Override
        public void onChange(RealmModel element) {
            task.getId();
            view.updateViews(task);
        }
    });
    view.initViews();
    view.updateViews(task);
}
 
開發者ID:mengdd,項目名稱:TodoRealm,代碼行數:17,代碼來源:TaskDetailPresenter.java

示例3: fetchRandomMovieOrTvSeries

import io.realm.RealmResults; //導入方法依賴的package包/類
private Movie fetchRandomMovieOrTvSeries() {
    Realm realm = Realm.getDefaultInstance();
    //TODO: Add Random TV Series to fetch
    RealmResults<Movie> movieRealmResults = realm.where(Movie.class).equalTo("isNotified", false).findAll();

    Util.debugLog(TAG, "fetchRandomMovieOrTvSeries: Size of movies with isNotified false " + movieRealmResults.size());

    if (movieRealmResults.size() != 0) {

        Random r = new Random();
        int randomNumber = r.nextInt(movieRealmResults.size());

        Movie movie = movieRealmResults.get(randomNumber);

        realm.beginTransaction();
        movieRealmResults.get(randomNumber).setNotified(true);
        realm.commitTransaction();


        return movie;
    } else {
        return null;
    }
}
 
開發者ID:hsm59,項目名稱:WatchIt,代碼行數:25,代碼來源:NotificationPublisher.java

示例4: saveData

import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Android> data) {//刷新時才調用到
    RealmResults<Android> all = mRealm.where(Android.class).findAll();
    if (all.size() > 0) {
        Android android = all.get(0);
        if (android != null) {
            if (!(android.content).equals(data.get(0).content)) {
                mRealm.executeTransaction(realm -> {
                    items.clear();
                    time2 = "";
                    realm.delete(Android.class);
                    realm.copyToRealmOrUpdate(data);
                });
            } else {//數據一樣不保存,同時不做 Adapter 刷新
                mPage = mPageIndex;
                AppUtils.toast(R.string.tip_no_new_data);
                mView.hideLoading();
            }
        }
    } else {
        mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));
    }
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:23,代碼來源:AndroidPresenter.java

示例5: saveData

import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Content> data) {
    RealmResults<Content> all = mRealm.where(Content.class).findAll();
    if (all.size() > 0) {
        Content content = all.get(0);
        if (content != null) {
            if (!(content.content).equals(data.get(0).content)) {
                mRealm.executeTransaction(realm -> {
                    realm.delete(Android.class);
                    mList.clear();
                    mList.addAll(data);
                    realm.copyToRealmOrUpdate(data);
                });
            } else {//數據一樣不保存,同時不做 Adapter 刷新
                mPage = mPageIndex;
                AppUtils.toast(R.string.tip_no_new_data);
                mView.hideLoading();
            }
        }
    } else {
        mList.addAll(data);
        mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));//第一次進入應用時
    }
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:24,代碼來源:ImagePresenter.java

示例6: saveData

import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<IOS> data) {//刷新時才調用到
    RealmResults<IOS> all = mRealm.where(IOS.class).findAll();
    if (all.size() > 0) {
        IOS ios = all.get(0);
        if (ios != null) {
            if (!(ios.content).equals(data.get(0).content)) {
                mRealm.executeTransaction(realm -> {
                    items.clear();
                    time2 = "";
                    realm.delete(IOS.class);
                    realm.copyToRealmOrUpdate(data);
                });
            } else {//數據一樣不保存,同時不做 Adapter 刷新
                mPage = mPageIndex;
                AppUtils.toast(R.string.tip_no_new_data);
                mView.hideLoading();
            }
        }
    } else {
        mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));
    }
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:23,代碼來源:IOSPresenter.java

示例7: generateSeasons

import io.realm.RealmResults; //導入方法依賴的package包/類
private void generateSeasons() {
    try {
        dataLoaded = true;
        seasonList.clear();

        Realm realm = RealmSingleton.getInstance().getRealm();
        RealmResults<RealmEpisode> episodes = realm.where(RealmEpisode.class)
                .equalTo("showID", showID)
                .equalTo("episodeNumber", 1)
                .distinct("seasonNumber")
                .sort("seasonNumber", Sort.DESCENDING);

        for (int i = 0; i < episodes.size(); i++) {
            RealmEpisode temp = episodes.get(i);
            int seasonNumber = temp.getSeasonNumber();
            if (seasonNumber == 0) {
                seasonList.add(new SeasonItem("Specials", temp.getEpisodeID(), seasonNumber));
            } else {
                seasonList.add(new SeasonItem("Season " + seasonNumber, temp.getEpisodeID(), seasonNumber));
            }
        }
        if (episodes.size() != 0) {
            mSeasonFragmentAdapter.notifyDataSetChanged();
        } else {
            tvError.setVisibility(View.VISIBLE);
        }
    } catch (Exception e) {
        Log.e("SeasonFragment", String.valueOf(e));
    }
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:31,代碼來源:Season.java

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

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

示例10: getLastGlucoseReading

import io.realm.RealmResults; //導入方法依賴的package包/類
public GlucoseReading getLastGlucoseReading() {
    RealmResults<GlucoseReading> results =
            realm.where(GlucoseReading.class)
                    .findAllSorted("created", Sort.DESCENDING);
    return results.get(0);
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:7,代碼來源:DatabaseHandler.java


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