public ChatListFragment() { contactUpdatedListener = new ResultListener() { @Override public void onResult(boolean success) { if (success) { if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (chatInfoList != null) { if (chatInfoList.size() > 0) { RealmList<RealmContact> phoneContacts = AppManager.getContacts(getActivity()); adapter.setPhoneContacts(phoneContacts); adapter.notifyDataSetChanged(); } } } }); } } } }; }
public RealmList<String> getFieldStringListNull() { return fieldStringListNull; }
@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; }
private void initList() { mList = new RealmList<>(); mList.add(new GoldManagerItemBean(0, true)); mList.add(new GoldManagerItemBean(1, true)); mList.add(new GoldManagerItemBean(2, true)); mList.add(new GoldManagerItemBean(3, true)); mList.add(new GoldManagerItemBean(4, false)); mList.add(new GoldManagerItemBean(5, false)); mList.add(new GoldManagerItemBean(6, false)); mList.add(new GoldManagerItemBean(7, false)); }
public Season(String id, String name, boolean hasFullSeasonDownloadUrl, RealmList<Episode> episodes, TvShow tvShow) { mId = id; mName = name; mHasFullSeasonDownloadUrl = hasFullSeasonDownloadUrl; mEpisodes = episodes; mTvShow = tvShow; }
@Test public void parse() throws Exception { String json = TestUtil.getCatWithListOfFriendsJson(); Type catRealmListType = new TypeToken<RealmList<Cat>>(){}.getType(); CatListConverter catRealmListConverter = new CatListConverter(); Gson gson = new GsonBuilder() .registerTypeAdapter(catRealmListType, catRealmListConverter) .create(); Cat cat = gson.fromJson(json, Cat.class); Assert.assertNotNull(cat); Assert.assertNotNull(cat.friends); }
@Override public <E> Flowable<RealmList<E>> from(Realm realm, final RealmList<E> list) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Flowable.create(new FlowableOnSubscribe<RealmList<E>>() { @Override public void subscribe(final FlowableEmitter<RealmList<E>> emitter) throws Exception { // Gets instance to make sure that the Realm is open for as long as the // Observable is subscribed to it. final Realm observableRealm = Realm.getInstance(realmConfig); listRefs.get().acquireReference(list); final RealmChangeListener<RealmList<E>> listener = new RealmChangeListener<RealmList<E>>() { @Override public void onChange(RealmList<E> results) { if (!emitter.isCancelled()) { emitter.onNext(list); } } }; list.addChangeListener(listener); // Cleanup when stream is disposed emitter.setDisposable(Disposables.fromRunnable(new Runnable() { @Override public void run() { list.removeChangeListener(listener); observableRealm.close(); listRefs.get().releaseReference(list); } })); // Emit current value immediately emitter.onNext(list); } }, BACK_PRESSURE_STRATEGY); }
@Override public <E> Observable<CollectionChange<RealmList<E>>> changesetsFrom(DynamicRealm realm, final RealmList<E> list) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new ObservableOnSubscribe<CollectionChange<RealmList<E>>>() { @Override public void subscribe(final ObservableEmitter<CollectionChange<RealmList<E>>> emitter) throws Exception { // Gets instance to make sure that the Realm is open for as long as the // Observable is subscribed to it. final DynamicRealm observableRealm = DynamicRealm.getInstance(realmConfig); listRefs.get().acquireReference(list); final OrderedRealmCollectionChangeListener<RealmList<E>> listener = new OrderedRealmCollectionChangeListener<RealmList<E>>() { @Override public void onChange(RealmList<E> results, OrderedCollectionChangeSet changeSet) { if (!emitter.isDisposed()) { emitter.onNext(new CollectionChange<>(results, changeSet)); } } }; list.addChangeListener(listener); // Cleanup when stream is disposed emitter.setDisposable(Disposables.fromRunnable(new Runnable() { @Override public void run() { list.removeChangeListener(listener); observableRealm.close(); listRefs.get().releaseReference(list); } })); // Emit current value immediately emitter.onNext(new CollectionChange<>(list, null)); } }); }
@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; }
public static GsonBuilder makeDefaultGsonBuilder() { return new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC) .disableHtmlEscaping() .setPrettyPrinting() .registerTypeAdapter(Date.class, new DateDeserializer()) .registerTypeAdapter(new TypeToken<RealmList<RealmString>>() {}.getType(), new RealmStringDeserializer()); }
/** * save contacts data into local storage * @param contacts */ public static void saveContacts(final RealmList<RealmContact> contacts ){ Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); final RealmResults<RealmContact> results = realm.where(RealmContact.class).findAll(); results.deleteAllFromRealm(); realm.copyToRealmOrUpdate(contacts); realm.commitTransaction(); }
@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; }
public void setFieldLongListNull(RealmList<Long> fieldLongListNull) { this.fieldLongListNull = fieldLongListNull; }
public void setFieldShortListNull(RealmList<Short> fieldShortListNull) { this.fieldShortListNull = fieldShortListNull; }
public void setRoles(RealmList<Role> roles) { this.roles = roles; }
public RealmList<Short> getFieldShortListNotNull() { return fieldShortListNotNull; }
public void setManagerList(RealmList<GoldManagerItemBean> managerList) { this.managerList = managerList; }
public void setFieldIntegerListNotNull(RealmList<Integer> fieldIntegerListNotNull) { this.fieldIntegerListNotNull = fieldIntegerListNotNull; }
public RealmList<DogPrimaryKey> getColumnRealmList() { return columnRealmList; }
public RealmList<Link> getLinks() { return links; }
public void setFieldShortList(RealmList<Short> fieldShortList) { this.fieldShortList = fieldShortList; }
public RealmList<RealmEpisode> getEpisodes() { return episodes; }
public void setTasks(RealmList<Task> tasks) { this.tasks = tasks; }
public RealmList<Season> getSeasons() { return mSeasons; }
public void setCats(RealmList<Cat> cats) { this.cats = cats; }
public RealmList<Integer> getFieldIntegerList() { return fieldIntegerList; }
public void setFieldByteList(RealmList<Byte> fieldByteList) { this.fieldByteList = fieldByteList; }
public void setPromociones(RealmList<Promocion> promociones) { this.promociones = promociones; }
public ElephantPreviewAdapter(Context context, RealmList<Elephant> elephants, boolean remove, boolean favorite) { super(context, R.layout.elephant_preview, elephants); this.favorite = favorite; this.remove = remove; }
public RealmList<Double> getFieldDoubleListNull() { return fieldDoubleListNull; }
public RealmList<AllTypes> getColumnRealmList() { return realmGet$columnRealmList(); }
public RealmList<AllTypes> realmGet$columnRealmList() { return columnRealmList; }
public void realmSet$columnRealmList(RealmList<AllTypes> columnRealmList) { this.columnRealmList = columnRealmList; }
public void setFieldListNull(RealmList<NullTypes> fieldListNull) { this.fieldListNull = fieldListNull; }
public void setList(RealmList list) { this.list = list; }
public RealmList<byte[]> getFieldBinaryList() { return fieldBinaryList; }
@Override protected StrongReferenceCounter<RealmList> initialValue() { return new StrongReferenceCounter<>(); }
public void setEpisodes(RealmList<RealmEpisode> episodes) { this.episodes = episodes; }
public RealmList<byte[]> getColumnBinaryList() { return columnBinaryList; }