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


Java RealmList.add方法代码示例

本文整理汇总了Java中io.realm.RealmList.add方法的典型用法代码示例。如果您正苦于以下问题:Java RealmList.add方法的具体用法?Java RealmList.add怎么用?Java RealmList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.realm.RealmList的用法示例。


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

示例1: deserialize

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public List<NYTimesMultimedium> deserialize(JsonParser parser, DeserializationContext context) throws IOException {
    RealmList<NYTimesMultimedium> list = new RealmList<>();

    TreeNode treeNode = parser.getCodec().readTree(parser);
    if (!(treeNode instanceof ArrayNode)) {
        return list;
    }

    ArrayNode arrayNode = (ArrayNode) treeNode;
    for (JsonNode node : arrayNode) {
        NYTimesMultimedium nyTimesMultimedium =
                objectMapper.treeToValue(node, NYTimesMultimedium.class);
        list.add(nyTimesMultimedium);
    }
    return list;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:RealmListNYTimesMultimediumDeserializer.java

示例2: syncStringList

import io.realm.RealmList; //导入方法依赖的package包/类
public RealmList<RString> syncStringList(JSONArray jsonArray) {
    RealmList<RString> strings = new RealmList<>();
    for (int i = 0; i < jsonArray.length(); i++) {
        RString string = realm.createObject(RString.class);

        try {
            string.setValue(jsonArray.getString(i));
        } catch (JSONException e) {
            Log.e(TAG, "Error parsing string from JSON Array", e);
        }

        strings.add(string);
    }

    return strings;
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:17,代码来源:RealmSyncs.java

示例3: syncQuizQuestions

import io.realm.RealmList; //导入方法依赖的package包/类
public RealmList<RQuizQuestion> syncQuizQuestions(JSONArray jsonArray) throws JSONException {

        RealmList<RQuizQuestion> questions = new RealmList<>();

        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject questionJsonObject = jsonArray.getJSONObject(i);

            try {
                RQuizQuestion question = syncQuizQuestion(questionJsonObject);
                questions.add(question);

            } catch (JSONException e) {
                Log.e(TAG, "Error parsing quiz question", e);
            }
        }

        return questions;
    }
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:19,代码来源:RealmSyncs.java

示例4: syncFilters

import io.realm.RealmList; //导入方法依赖的package包/类
public RealmList<RFilter> syncFilters(JSONArray jsonArray) throws JSONException {

        RealmList<RFilter> filters = new RealmList<>();

        realm.delete(RFilter.class);

        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject filterJsonObject = jsonArray.getJSONObject(i);

            try {
                RFilter filter = syncFilter(filterJsonObject);
                filters.add(filter);

            } catch (JSONException e) {
                Log.e(TAG, "Error parsing filter", e);
            }
        }

        return filters;
    }
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:21,代码来源:RealmSyncs.java

示例5: getContacts

import io.realm.RealmList; //导入方法依赖的package包/类
/**
 * get saved contacts data from local storage
 * @return dictionary format
 */
public static RealmList<RealmContact> getContacts(Context context){
    Realm realm = Realm.getDefaultInstance();
    RealmResults<RealmContact> results = realm.where(RealmContact.class).findAll();
    RealmList<RealmContact> contacts = new RealmList<>();
    for (RealmContact contact: results) {
        contacts.add(contact);
    }
    return contacts;
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:14,代码来源:AppManager.java

示例6: deserialize

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public RealmList<T> deserialize(JsonElement json, Type typeOfT,
                                        JsonDeserializationContext context) throws JsonParseException {
    RealmList<T> items = new RealmList<>();
    JsonArray ja = json.getAsJsonArray();
    for (JsonElement je : ja) {
        items.add((T) context.deserialize(je, getObjectType()));
    }
    return items;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:11,代码来源:RealmListGsonConverter.java

示例7: parse

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public RealmList<T> parse(JsonParser jsonParser) throws IOException {
    init();
    RealmList<T> list = new RealmList<>();
    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
            T object = typeConverter != null ? typeConverter.parse(jsonParser) : mapper.parse(jsonParser);
            if (object != null) {
                list.add(object);
            }
        }
    }
    return list;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:15,代码来源:RealmListLoganSquareConverter.java

示例8: fromParcel

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public RealmList fromParcel(Parcel parcel) {
    int size = parcel.readInt();
    if (size != -1) {
        RealmList list = new RealmList();
        for (int i = 0; i < size; i++) {
            Parcelable parcelable = parcel.readParcelable(getClass().getClassLoader());
            list.add((RealmObject) Parcels.unwrap(parcelable));
        }
        return list;
    }
    return null;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:14,代码来源:RealmListParcelConverter.java

示例9: fromJson

import io.realm.RealmList; //导入方法依赖的package包/类
@Nullable
@Override
public RealmList<T> fromJson(@NonNull JsonReader reader) throws IOException {
    RealmList<T> result = new RealmList<>();
    reader.beginArray();
    while (reader.hasNext()) {
        result.add(elementAdapter.fromJson(reader));
    }
    reader.endArray();
    return result;
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:12,代码来源:RealmListAdapter.java

示例10: deserialize

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public RealmList<RealmString> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
    RealmList<RealmString> list = new RealmList<>();
    JsonArray ja = json.getAsJsonArray();
    for (JsonElement je : ja) {
        list.add(new RealmString(je.getAsString()));
    }
    return list;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:11,代码来源:GsonProvider.java

示例11: getTags

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public RealmList<Tag> getTags() {
    RealmList<Tag> tags = new RealmList<>();
    List<String> tagStrs = mPostTagsEditText.getTokens();
    for (String tagStr : tagStrs) {
        tags.add(new Tag(tagStr));
    }
    return tags;
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:10,代码来源:PostViewActivity.java

示例12: onLoadFinished

import io.realm.RealmList; //导入方法依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null) {
        if (data.getCount() > 0) {
            RealmList<ImageBean> realmList = new RealmList<>();
            data.moveToFirst();
            do {
                String path = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[0]));
                String name = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[1]));
                long dateTime = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[2]));
                long id = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[5]));
                if (fileExist(path)) {
                    ImageBean bean = new ImageBean();
                    bean.setId(id);
                    bean.setPath(path);
                    bean.setName(name);
                    bean.setDate(dateTime);
                    realmList.add(bean);
                }

            } while (data.moveToNext());

            if (onLoadFinishedListener != null) {
                onLoadFinishedListener.onLoadFinished(realmList);
            }
        }
    }
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:29,代码来源:MediaLoaderCallback.java

示例13: syncQuizQuestion

import io.realm.RealmList; //导入方法依赖的package包/类
public RQuizQuestion syncQuizQuestion(JSONObject jsonObject) throws JSONException {

        String questionId = jsonObject.getString("id");
        RQuizQuestion question = RealmWrites.withRealm(realm).findOrCreate(RQuizQuestion.class, questionId);

        question.setQuestion(jsonObject.getString("question"));

        JSONArray answersJsonArray = jsonObject.getJSONArray("answers");
        RealmList<RQuizAnswer> answers = new RealmList<>();

        for (int i = 0; i < answersJsonArray.length(); i++) {
            JSONObject answerJsonObject = answersJsonArray.getJSONObject(i);

            String answerId = answerJsonObject.getString("id");
            RQuizAnswer answer = RealmWrites.withRealm(realm).findOrCreate(RQuizAnswer.class, answerId);

            answer.setAnswer(answerJsonObject.getString("answer"));

            answers.add(answer);
        }

        question.setAnswers(answers);

        return question;
    }
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:26,代码来源:RealmSyncs.java

示例14: loadPhoneContacts

import io.realm.RealmList; //导入方法依赖的package包/类
/**
 * load all contacts from Phone Contact
 * this method needs async task because it may take too longer to load
 * @param listener : success result handler
 */
public void loadPhoneContacts(ResultListener listener){
    long startnow = android.os.SystemClock.uptimeMillis();
    Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    String[] projection = new String[] {
            Phone._ID,
            Phone.DISPLAY_NAME,
            Phone.NUMBER
    };

    Cursor people = context.getContentResolver().query(uri, projection, null, null, null);
    int indexId = people.getColumnIndex(Phone._ID);
    int indexName = people.getColumnIndex(Phone.DISPLAY_NAME);
    int indexNumber = people.getColumnIndex(Phone.NUMBER);

    RealmList<RealmContact> realmContacts = new RealmList<>();

    if(people.moveToFirst()) {
        do {
            String idx = people.getString(indexId);
            String name   = people.getString(indexName);
            String number = people.getString(indexNumber);
            // Do work...
            String phone = number.replace(" ", "").replace("-", "");

            RealmContact contact = new RealmContact();
            contact.setIdx(idx);
            contact.setName(name);
            contact.setPhone(phone);

            /*boolean isExist = false;

            for (int i = 0; i < phoneContacts.size(); i++){
                RealmContact existContact = phoneContacts.get(i);
                if (existContact.getIdx().equals(contact.getIdx())){
                    isExist = true;
                    break;
                }
            }
            if (!isExist){
                phoneContacts.add(contact);
            }*/

            realmContacts.add(contact);

        } while (people.moveToNext());

        saveContacts(realmContacts);
    }

    if (phoneContacts.isEmpty())
        phoneContacts = getContacts(context);

    long endnow = android.os.SystemClock.uptimeMillis();
    long processingDuration = endnow - startnow;
    Log.d("AppManager", "TimeForContacts " + (endnow - startnow) + " ms");

    // analysis
    Bundle params = new Bundle();
    params.putLong("duration", processingDuration);
    References.getInstance().analytics.logEvent("load_contacts", params);

    if (listener != null) {
        listener.onResult(true);
    }
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:71,代码来源:AppManager.java

示例15: Post

import io.realm.RealmList; //导入方法依赖的package包/类
public Post(@NonNull Post post) {
    this.setId(post.getId());
    this.setUuid(post.getUuid());
    this.setTitle(post.getTitle());
    this.setSlug(post.getSlug());
    this.setStatus(post.getStatus());
    this.setMarkdown(post.getMarkdown());
    this.setMobiledoc(post.getMobiledoc());
    this.setHtml(post.getHtml());

    List<Tag> realmTags = post.getTags();
    RealmList<Tag> unmanagedTags = new RealmList<>();
    for (Tag realmTag : realmTags) {
        unmanagedTags.add(new Tag(realmTag));
    }
    this.setTags(unmanagedTags);

    this.setFeatureImage(post.getFeatureImage());
    this.setFeatured(post.isFeatured());
    this.setPage(post.isPage());
    this.setLanguage(post.getLanguage());

    this.setAuthor(post.getAuthor());
    this.setCreatedBy(post.getCreatedBy());
    this.setUpdatedBy(post.getUpdatedBy());
    this.setPublishedBy(post.getPublishedBy());

    this.setCreatedAt(post.getCreatedAt());
    this.setUpdatedAt(post.getUpdatedAt());
    this.setPublishedAt(post.getPublishedAt());

    this.setMetaTitle(post.getMetaTitle());
    this.setMetaDescription(post.getMetaDescription());

    this.setCustomExcerpt(post.getCustomExcerpt());

    for (PendingAction action : post.getPendingActions()) {
        this.addPendingAction(action.getType());
    }
    this.setConflictState(post.getConflictState());
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:42,代码来源:Post.java


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