當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。