当前位置: 首页>>代码示例>>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;未经允许,请勿转载。