My goal is to display the received data from the Internet in a RecyclerAdapter. But when I tried to do this, I get an exception. I tried to make this code
myService.getFromNet(name)
.subscribeOn(Schedulers.io())
.map(Cook::getPizza)
.flatMap(cooks -> {
Realm.getDefaultInstance().executeTransaction(realm -> {
realm.delete(PizzaViewDB.class);
//But here there is an error
realm.insert(cooks);
});
return io.reactivex.Observable.just(cooks);
})
.onErrorResumeNext(throwable -> {
Realm realm = Realm.getDefaultInstance();
RealmResults<PizzaViewDB> results = realm.where(PizzaViewDB.class).findAll();
//And below is problem - reason: no instance(s) if type variable(s) E exist to that List<E> comforms to String
return io.reactivex.Observable.just(realm.copyFromRealm(results));
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(re -> {
recyclerView.setAdapter(new CookAdapter(cook.getPizza()));
});
But I still have an exception. My base class where I take my RealmList here:
@SerializedName("pizza")
@Expose
private RealmList<PizzaViewDB> pizza;
public RealmList<PizzaViewDB> getPizza() {
return pizza;
}
And my fiels from Realm:
public class PizzaViewDB extends RealmObject implements RealmModel {
@PrimaryKey
private String subject;
private String comment;
private String date;
public void setSubject(String subject) {
this.subject = subject;
}
public void setDate(String date) {
this.date = date;
}
public void setComment(String name) {
this.comment = name;
}
public String getSubject() {
return subject;
}
public String getDate() {
return date;
}
public String getComment() {
return comment;
}