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