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


Java Realm.copyFromRealm方法代碼示例

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


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

示例1: getAll

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public Flowable<Optional<List<T>>> getAll(List<T> items) {
    Realm realm = Realm.getDefaultInstance();
    RealmQuery<T> query = realm.where(clazz);

    if(items.size() > 0){
        String paramName = items.get(0).getUniqueIdentifierName();
        Integer[] keys = new Integer[items.size()];
        for(int i = 0; i < items.size(); i++){
            keys[i] = items.get(i).getUniqueIdentifier();
        }
        query.in(paramName, keys);
    }

    List<T> copies = realm.copyFromRealm(query.findAll());
    realm.close();

    return Flowable.just(Optional.wrap(copies));
}
 
開發者ID:playmoweb,項目名稱:store2realm,代碼行數:20,代碼來源:RealmDao.java

示例2: getOne

import io.realm.Realm; //導入方法依賴的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

示例3: insertOrUpdate

import io.realm.Realm; //導入方法依賴的package包/類
/**
 * Insert or update all
 * @param items
 * @return List of item copied from realm
 */
@Override
public Flowable<Optional<List<T>>> insertOrUpdate(List<T> items) {
    final Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    items = realm.copyToRealmOrUpdate(items);
    realm.commitTransaction();
    List<T> copies = realm.copyFromRealm(items);
    realm.close();

    return Flowable.just(Optional.wrap(copies));
}
 
開發者ID:playmoweb,項目名稱:store2realm,代碼行數:17,代碼來源:RealmDao.java

示例4: setPackageReadable

import io.realm.Realm; //導入方法依賴的package包/類
/**
 * Set a package of specific number read or unread new.
 * @param packageId The primary key or the package id.
 *                  See {@link Package#number}
 * @param readable Read or unread new.
 *                 See {@link Package#readable}
 */
@Override
public void setPackageReadable(@NonNull String packageId, boolean readable) {
    Realm rlm = RealmHelper.newRealmInstance();
    Package p = rlm.copyFromRealm(rlm.where(Package.class)
            .equalTo("number", packageId)
            .findFirst());
    if (p != null) {
        rlm.beginTransaction();
        p.setReadable(readable);
        // When a package is not readable, it is not pushable.
        p.setPushable(readable);
        rlm.copyToRealmOrUpdate(p);
        rlm.commitTransaction();
        rlm.close();
    }
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:24,代碼來源:PackagesLocalDataSource.java

示例5: searchCompanies

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
    Realm rlm = RealmHelper.newRealmInstance();
    List<Company> results = rlm.copyFromRealm(
            rlm.where(Company.class)
                    .like("name","*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("tel", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("website", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("alphabet", "*" + keyWords + "*", Case.INSENSITIVE)
                    .findAllSorted("alphabet", Sort.ASCENDING));
    return Observable.fromIterable(results)
            .toList()
            .toObservable();
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:18,代碼來源:CompaniesLocalDataSource.java

示例6: setAllPackagesRead

import io.realm.Realm; //導入方法依賴的package包/類
/**
 * Set all the packages which are the unread new read.
 */
@Override
public void setAllPackagesRead() {
    Realm rlm = RealmHelper.newRealmInstance();
    List<Package> results = rlm.copyFromRealm(rlm.where(Package.class).findAll());

    for (Package p : results) {
        p.setReadable(false);
        p.setPushable(false);
        rlm.beginTransaction();
        rlm.copyToRealmOrUpdate(p);
        rlm.commitTransaction();
    }
    rlm.close();
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:18,代碼來源:PackagesLocalDataSource.java

示例7: getViewAt

import io.realm.Realm; //導入方法依賴的package包/類
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews remoteViews = new RemoteViews(
            context.getPackageName(), R.layout.item_package_for_widget);

    Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .name(DATABASE_NAME)
            .build());
    List<Package> results = rlm.copyFromRealm(rlm.where(Package.class)
            .notEqualTo("state", String.valueOf(Package.STATUS_DELIVERED))
            .findAllSorted("timestamp", Sort.DESCENDING));

    Package p = results.get(position);

    if (p.getData() != null && p.getData().size() > 0) {
        int state = Integer.parseInt(p.getState());
        remoteViews.setTextViewText(R.id.textViewStatus,
                String.valueOf(packageStatus[state]) + " - " + p.getData().get(0).getContext());
        remoteViews.setTextViewText(R.id.textViewTime, p.getData().get(0).getTime());
    } else {
        remoteViews.setTextViewText(R.id.textViewTime, "");
        remoteViews.setTextViewText(R.id.textViewStatus, statusError);
    }

    remoteViews.setTextViewText(R.id.textViewPackageName, p.getName());
    remoteViews.setTextViewText(R.id.textViewAvatar, p.getName().substring(0, 1));
    remoteViews.setImageViewResource(R.id.imageViewAvatar, p.getColorAvatar());

    Intent intent = new Intent();
    intent.putExtra(PackageDetailsActivity.PACKAGE_ID, p.getNumber());
    remoteViews.setOnClickFillInIntent(R.id.layoutPackageItemMain, intent);

    return remoteViews;
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:36,代碼來源:WidgetListFactory.java

示例8: get

import io.realm.Realm; //導入方法依賴的package包/類
public static <O extends  RealmObject> O get(Realm realmInstance, QueryFilters filters, Class<O> clazz) throws LocalDataNotFoundException{
    Realm realm = realmInstance;
    RealmQuery<O> query = realm.where(clazz);
    query = filters.copyToRealmQuery(query);
    O result = query.findFirst();
    if(result != null){
        O finalResult = realm.copyFromRealm(result);
        realm.close();
        return finalResult;
    }
    throw new SessionNotFoundException("queried data is not found");
}
 
開發者ID:rezkyatinnov,項目名稱:kyandroid,代碼行數:13,代碼來源:LocalData.java

示例9: getList

import io.realm.Realm; //導入方法依賴的package包/類
public static <O extends RealmObject> List<O> getList(Realm realmInstance, QueryFilters filters, Class<O> clazz) throws LocalDataNotFoundException{
    Realm realm = realmInstance;
    RealmQuery<O> query = realm.where(clazz);
    query = filters.copyToRealmQuery(query);
    List<O> results = realm.copyFromRealm(query.findAll());
    realm.close();
    return results;
}
 
開發者ID:rezkyatinnov,項目名稱:kyandroid,代碼行數:9,代碼來源:LocalData.java

示例10: setMother

import io.realm.Realm; //導入方法依賴的package包/類
public void setMother(final String id) {
  Realm realm = Realm.getDefaultInstance();
  elephant.mother = realm.where(Elephant.class).equalTo(ID, id).findFirst();
  elephant.mother = realm.copyFromRealm(elephant.mother);
  motherButton.setVisibility(View.GONE);
  motherPreview.setElephant(elephant.mother);
  motherPreview.setVisibility(View.VISIBLE);
  realm.close();
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:10,代碼來源:AddParentageFragment.java

示例11: setFather

import io.realm.Realm; //導入方法依賴的package包/類
public void setFather(String id) {
  Realm realm = Realm.getDefaultInstance();
  elephant.father = realm.where(Elephant.class).equalTo(ID, id).findFirst();
  elephant.father = realm.copyFromRealm(elephant.father);
  fatherButton.setVisibility(View.GONE);
  fatherPreview.setElephant(elephant.father);
  fatherPreview.setVisibility(View.VISIBLE);
  realm.close();
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:10,代碼來源:AddParentageFragment.java

示例12: loadDocuments

import io.realm.Realm; //導入方法依賴的package包/類
private void loadDocuments() {
	Realm realm = Realm.getDefaultInstance();
	Integer id = ((ShowElephantActivity)getActivity()).getElephant().id;
	List<Document> results = realm.copyFromRealm(realm.where(Document.class).equalTo(Document.ELEPHANT_ID, id).findAll());
	adapter = new DocumentAdapter(getContext(), results, new DocumentAdapter.Listener() {
		@Override
		public void onDocumentClick(Document document) {
			((ShowElephantActivity)getActivity()).onDocumentClick(document);
		}
	});
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:12,代碼來源:ShowDocumentFragment.java

示例13: onHandleIntent

import io.realm.Realm; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(@Nullable Intent intent) {

    Log.d(TAG, "onHandleIntent: ");

    boolean isDisturbMode = preference.getBoolean(SettingsUtil.KEY_DO_NOT_DISTURB_MODE, true);

    // The alert mode is off
    // or DO-NOT-DISTURB-MODE is off
    // or time now is not in the DO-NOT-DISTURB-MODE range.
    if (isDisturbMode && PushUtil.isInDisturbTime(this, Calendar.getInstance())) {
        return;
    }

    Realm rlm = RealmHelper.newRealmInstance();

    List<Package> results = rlm.copyFromRealm(
            rlm.where(Package.class)
                    .notEqualTo("state", String.valueOf(Package.STATUS_DELIVERED))
                    .findAll());

    for (int i = 0; i < results.size(); i++){

        Package p = results.get(i);
        // Avoid repeated pushing
        if (p.isPushable()) {

            Realm realm = RealmHelper.newRealmInstance();

            p.setPushable(false);

            pushNotification(i + 1001, setNotifications(i, p));

            realm.beginTransaction();
            realm.copyToRealmOrUpdate(p);
            realm.commitTransaction();
            realm.close();

        } else if (NetworkUtil.networkConnected(getApplicationContext())) {
            refreshPackage(i, results.get(i));
        }

    }

    rlm.close();

}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:48,代碼來源:ReminderService.java

示例14: populateUI

import io.realm.Realm; //導入方法依賴的package包/類
private void populateUI() {
    Realm realm = Realm.getDefaultInstance();
    trip = realm.copyFromRealm(realm.where(Trip.class).equalTo("id", tripId).findFirst());
    realm.close();

    originalPath = trip.toConnectionPath(network);

    if (!trip.canBeCorrected()) {
        finish();
    }

    List<Station> stations = new ArrayList<>(network.getStations());

    startPicker.setStations(stations);
    endPicker.setStations(stations);

    startPicker.setAllStationsSortStrategy(new StationPickerView.DistanceSortStrategy(network, originalPath.getStartVertex()));
    endPicker.setAllStationsSortStrategy(new StationPickerView.DistanceSortStrategy(network, originalPath.getEndVertex()));

    startPicker.setWeakSelection(originalPath.getStartVertex().getStation());
    endPicker.setWeakSelection(originalPath.getEndVertex().getStation());

    StationPickerView.OnStationSelectedListener onStationSelectedListener = new StationPickerView.OnStationSelectedListener() {
        @Override
        public void onStationSelected(Station station) {
            redrawPath();
        }
    };
    startPicker.setOnStationSelectedListener(onStationSelectedListener);
    endPicker.setOnStationSelectedListener(onStationSelectedListener);

    StationPickerView.OnSelectionLostListener onSelectionLostListener = new StationPickerView.OnSelectionLostListener() {
        @Override
        public void onSelectionLost() {
            redrawPath();
        }
    };
    startPicker.setOnSelectionLostListener(onSelectionLostListener);
    endPicker.setOnSelectionLostListener(onSelectionLostListener);

    redrawPath();

    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveChanges();
        }
    });
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:50,代碼來源:TripCorrectionActivity.java

示例15: getAllBlogs

import io.realm.Realm; //導入方法依賴的package包/類
public static List<BlogMetadata> getAllBlogs() {
    final Realm realm = Realm.getDefaultInstance();
    return realm.copyFromRealm(realm
            .where(BlogMetadata.class)
            .findAll());
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:7,代碼來源:AccountManager.java


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