当前位置: 首页>>代码示例>>Java>>正文


Java RealmResults类代码示例

本文整理汇总了Java中io.realm.RealmResults的典型用法代码示例。如果您正苦于以下问题:Java RealmResults类的具体用法?Java RealmResults怎么用?Java RealmResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RealmResults类属于io.realm包,在下文中一共展示了RealmResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setData

import io.realm.RealmResults; //导入依赖的package包/类
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "label");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setLabel("Example market share");
        set.setSliceSpace(2);

        // create a data object with the dataset list
        PieData data = new PieData(set);
        styleData(data);
        data.setValueTextColor(Color.WHITE);
        data.setValueTextSize(12f);

        // set data
        mChart.setData(data);
        mChart.animateY(1400);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmDatabaseActivityPie.java

示例2: searchContacts

import io.realm.RealmResults; //导入依赖的package包/类
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();
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:24,代码来源:SearchContactResultActivity.java

示例3: getAll

import io.realm.RealmResults; //导入依赖的package包/类
/**
 * Get all for a specific filters
 * @return
 */
@Override
public Flowable<Optional<List<T>>> getAll(Filter filter, SortingMode sortingMode) {
    Realm realm = Realm.getDefaultInstance();
    RealmQuery<T> query = realm.where(clazz);
    query = filterToQuery(filter, query);

    RealmResults<T> items;
    if(sortingMode != null && sortingMode.entries.size() > 0) {
        items = applySortingMode(sortingMode, query);
    } else {
        items = query.findAll();
    }
    List<T> copies = realm.copyFromRealm(items);
    realm.close();

    return Flowable.just(Optional.wrap(copies));
}
 
开发者ID:playmoweb,项目名称:store2realm,代码行数:22,代码来源:RealmDao.java

示例4: setData

import io.realm.RealmResults; //导入依赖的package包/类
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
        set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        set.setLabel("Realm LineDataSet");
        set.setDrawCircleHole(false);
        set.setColor(ColorTemplate.rgb("#FF5722"));
        set.setCircleColor(ColorTemplate.rgb("#FF5722"));
        set.setLineWidth(1.8f);
        set.setCircleRadius(3.6f);

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        LineData data = new LineData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:RealmDatabaseActivityLine.java

示例5: setData

import io.realm.RealmResults; //导入依赖的package包/类
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
        set.setLabel("Realm CandleDataSet");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(0.7f);
        set.setDecreasingColor(Color.RED);
        set.setDecreasingPaintStyle(Paint.Style.FILL);
        set.setIncreasingColor(Color.rgb(122, 242, 84));
        set.setIncreasingPaintStyle(Paint.Style.STROKE);
        set.setNeutralColor(Color.BLUE);

        ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        CandleData data = new CandleData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RealmDatabaseActivityCandle.java

示例6: setData

import io.realm.RealmResults; //导入依赖的package包/类
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "yValue"); // stacked entries
        set.setLabel("Realm RadarDataSet");
        set.setDrawFilled(true);
        set.setColor(ColorTemplate.rgb("#009688"));
        set.setFillColor(ColorTemplate.rgb("#009688"));
        set.setFillAlpha(130);
        set.setLineWidth(2f);

        ArrayList<IRadarDataSet> dataSets = new ArrayList<IRadarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RadarData data = new RadarData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:RealmDatabaseActivityRadar.java

示例7: btn_logout_click

import io.realm.RealmResults; //导入依赖的package包/类
public void btn_logout_click(View v) {
    RealmConfiguration config = new RealmConfiguration.Builder().name("yyox.realm").build();
    Realm objRealm = Realm.getInstance(config);

    //查找
    RealmUser realmUser = objRealm.where(RealmUser.class).findFirst();
    if (realmUser != null) {
        //先删除
        objRealm.beginTransaction();
        RealmResults results = objRealm.where(RealmUser.class).findAll();
        results.deleteAllFromRealm();
        objRealm.commitTransaction();

    }
    mPresenter.requestLogout(this);
    WEApplication weApplication = (WEApplication) getApplication();
    weApplication.setRealmUser(null);

    Intent intent = new Intent();
    setResult(CodeDefine.SETTING_RESULT, intent);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:22,代码来源:UserSettingActivity.java

示例8: onCreate

import io.realm.RealmResults; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history);
    // Calling the RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setHasFixedSize(true);

    Realm.init(this);
    realm = Realm.getDefaultInstance();
    RealmResults<StepCounts> results = realm.where(StepCounts.class).findAll();
    // The number of Columns
    mLayoutManager = new GridLayoutManager(this, 1);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new HistoryAdapter(results,HistoryActivity.this);
    mRecyclerView.setAdapter(mAdapter);
}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:19,代码来源:HistoryActivity.java

示例9: createResults

import io.realm.RealmResults; //导入依赖的package包/类
private Observable<List<Task>> createResults(QuerySelector<DbTask> querySelector) {
    return Observable.create((ObservableOnSubscribe<List<Task>>) emitter -> {
        Realm realm = Realm.getDefaultInstance();
        final RealmResults<DbTask> dbTasks = querySelector.createQuery(realm);
        final RealmChangeListener<RealmResults<DbTask>> realmChangeListener = element -> {
            if(element.isLoaded() && !emitter.isDisposed()) {
                List<Task> tasks = mapFrom(element);
                if(!emitter.isDisposed()) {
                    emitter.onNext(tasks);
                }
            }
        };
        emitter.setDisposable(Disposables.fromAction(() -> {
            if(dbTasks.isValid()) {
                dbTasks.removeChangeListener(realmChangeListener);
            }
            realm.close();
        }));
        dbTasks.addChangeListener(realmChangeListener);
    }).subscribeOn(looperScheduler.getScheduler()).unsubscribeOn(looperScheduler.getScheduler());
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:22,代码来源:TaskRepository.java

示例10: onCreateView

import io.realm.RealmResults; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.layout_recycler_view, container, false);
    unbinder = ButterKnife.bind(this, rootView);

    Bundle arguments = getArguments();
    int infoType = arguments.getInt(ARG_INFO_TYPE);

    Realm realm = Realm.getDefaultInstance();
    Timber.d("type:%s", infoType);
    RealmResults<TemplateItem> results = realm.where(TemplateItem.class)
            .beginsWith("template.type.id", String.valueOf(infoType))
            .findAllSorted("id");
    mAdapter = new TemplatesAdapter(getContext(), results, false, false);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

    return rootView;
}
 
开发者ID:jonashao,项目名称:Samantha,代码行数:21,代码来源:TemplatesFragment.java

示例11: loadNewsFeed

import io.realm.RealmResults; //导入依赖的package包/类
/**
 * Loads the news feed as well as all future updates.
 */
@UiThread
public Flowable<RealmResults<NYTimesStory>> loadNewsFeed(@NonNull String sectionKey, boolean forceReload) {
    // Start loading data from the network if needed
    // It will put all data into Realm
    if (forceReload || timeSinceLastNetworkRequest(sectionKey) > MINIMUM_NETWORK_WAIT_SEC) {
        dataLoader.loadData(sectionKey, apiKey, realm, networkLoading);
        lastNetworkRequest.put(sectionKey, System.currentTimeMillis());
    }

    // Return the data in Realm. The query result will be automatically updated when the network requests
    // save data in Realm
    return realm.where(NYTimesStory.class)
            .equalTo(NYTimesStory.API_SECTION, sectionKey)
            .findAllSortedAsync(NYTimesStory.PUBLISHED_DATE, Sort.DESCENDING)
            .asFlowable();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:Repository.java

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

示例13: onCreateView

import io.realm.RealmResults; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_schedule, container, false);

    int day = getArguments().getInt(ARG_SECTION_NUMBER);

    InstinctsApplication instinctsApplication = (InstinctsApplication) getActivity().getApplication();
    RealmHelper realmHelper = instinctsApplication.getRealmHelper();
    Realm realm = realmHelper.getRealmInstance();
    RealmResults<Event> eventRealmResults = realm.where(Event.class)
            .contains("startTime", (day > 9) ? day + "-03-2017" : "0" + day + "-03-2017")
            .findAllSorted("startTime");

    ScheduleAdapter adapter = new ScheduleAdapter(getActivity(), eventRealmResults);
    RecyclerView eventsRecyclerView = (RecyclerView) rootView.findViewById(R.id.events_recycler_view);
    eventsRecyclerView.setAdapter(adapter);
    eventsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    return rootView;
}
 
开发者ID:adithya321,项目名称:Instincts-2k17,代码行数:21,代码来源:ScheduleActivity.java

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

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


注:本文中的io.realm.RealmResults类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。