Возникла проблема с восстановлением данных в моей базе данных с помощью функции retrofit2 call.execute (). Body (). Мое приложение останавливается, когда оно прибывает в этот момент. я не знаю, почему нет сообщения об ошибке: оно просто останавливается. я также пробовал с call.enqueu и т. д., чтобы увидеть, что происходит в переопределенном методе onFailure. но это не входит в это.
может быть проблема с разбором? может быть, что-то еще ?
я серьезно не имею понятия.
И у меня есть другие части кода, которые работают точно так же. так ...
благодарю вас.
Вот мой метод:
public CalendrierDisponibilite CallBy(int idPersonne) throws IOException {
Call<CalendrierDisponibilite> call = userService.getCalendrierDisponibilite(idPersonne);
Log.d("CallBy: " , call.execute().errorBody().toString());
calendrier = call.execute().body();
return calendrier;
}
вот мой интерфейс API:
@GET("calendrierdisponibilites/{id}")
Call<CalendrierDisponibilite> getCalendrierDisponibilite(@Query("id") int id);
вот моя модель:
package com.example.dupla.sparktennis.entities;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by Remi on 2017-10-12.
*/
public class CalendrierDisponibilite extends BaseObservable implements Parcelable{
@SerializedName("idcalendrier")
@Expose
private int idcalendrier;
@SerializedName("iduser")
@Expose
private int iduser;
@SerializedName("lundimatin")
@Expose
private int lundimatin;
@SerializedName("lundiapmidi")
@Expose
private int lundiapmidi;
@SerializedName("lundisoir")
@Expose
private int lundisoir;
@SerializedName("mardimatin")
@Expose
private int mardimatin;
@SerializedName("mardiapmidi")
@Expose
private int mardiapmidi;
@SerializedName("mardisoir")
@Expose
private int mardisoir;
@SerializedName("mercredimatin")
@Expose
private int mercredimatin;
@SerializedName("mercrediapmidi")
@Expose
private int mercrediapmidi;
@SerializedName("mercredisoir")
@Expose
private int mercredisoir;
@SerializedName("jeudimatin")
@Expose
private int jeudimatin;
@SerializedName("jeudiapmidi")
@Expose
private int jeudiapmidi;
@SerializedName("jeudisoir")
@Expose
private int jeudisoir;
@SerializedName("vendredimatin")
@Expose
private int vendredimatin;
@SerializedName("vendrediapmidi")
@Expose
private int vendrediapmidi;
@SerializedName("vendredisoir")
@Expose
private int vendredisoir;
@SerializedName("weekendmatin")
@Expose
private int weekendmatin;
@SerializedName("weekendapmidi")
@Expose
private int weekendapmidi;
@SerializedName("weekendsoir")
@Expose
private int weekendsoir;
@SerializedName("DateModification")
@Expose
private int dateModification;
/*
@SerializedName("tstBool")
@Expose
private int tstBool;
*/
public CalendrierDisponibilite(int idcalendrier, int iduser, int lundimatin, int lundiapmidi, int lundisoir, int mardimatin, int mardiapmidi, int mardisoir, int mercredimatin, int mercrediapmidi, int mercredisoir, int jeudimatin, int jeudiapmidi, int jeudisoir, int vendredimatin, int vendrediapmidi, int vendredisoir, int weekendmatin, int weekendapmidi, int weekendsoir , int test) {
this.idcalendrier = idcalendrier;
this.iduser = iduser;
this.lundimatin = lundimatin;
this.lundiapmidi = lundiapmidi;
this.lundisoir = lundisoir;
this.mardimatin = mardimatin;
this.mardiapmidi = mardiapmidi;
this.mardisoir = mardisoir;
this.mercredimatin = mercredimatin;
this.mercrediapmidi = mercrediapmidi;
this.mercredisoir = mercredisoir;
this.jeudimatin = jeudimatin;
this.jeudiapmidi = jeudiapmidi;
this.jeudisoir = jeudisoir;
this.vendredimatin = vendredimatin;
this.vendrediapmidi = vendrediapmidi;
this.vendredisoir = vendredisoir;
this.weekendmatin = weekendmatin;
this.weekendapmidi = weekendapmidi;
this.weekendsoir = weekendsoir;
// this.tstBool = test;
}
public CalendrierDisponibilite() {
}
public boolean isPositive(int val){
if(val == 1){
return true;
}
else{
return false;
}
}
/*
@Bindable
public int getTstBool() {
return tstBool;
}
public void setTstBool(int tstBool) {
this.tstBool = tstBool;
}
*/
@Bindable
public int getDateModification() {
return dateModification;
}
public void setDateModification(int dateModification) {
this.dateModification = dateModification;
}
@Bindable
public int getIdcalendrier() {
return idcalendrier;
}
public void setIdcalendrier(int idcalendrier) {
this.idcalendrier = idcalendrier;
}
@Bindable
public int getIduser() {
return iduser;
}
public void setIduser(int iduser) {
this.iduser = iduser;
}
@Bindable
public int getLundimatin() {
return lundimatin;
}
public void setLundimatin(int lundimatin) {
this.lundimatin = lundimatin;
}
@Bindable
public int getLundiapmidi() {
return lundiapmidi;
}
public void setLundiapmidi(int lundiapmidi) {
this.lundiapmidi = lundiapmidi;
}
@Bindable
public int getLundisoir() {
return lundisoir;
}
public void setLundisoir(int lundisoir) {
this.lundisoir = lundisoir;
}
@Bindable
public int getMardimatin() {
return mardimatin;
}
public void setMardimatin(int mardimatin) {
this.mardimatin = mardimatin;
}
@Bindable
public int getMardiapmidi() {
return mardiapmidi;
}
public void setMardiapmidi(int mardiapmidi) {
this.mardiapmidi = mardiapmidi;
}
@Bindable
public int getMardisoir() {
return mardisoir;
}
public void setMardisoir(int mardisoir) {
this.mardisoir = mardisoir;
}
@Bindable
public int getMercredimatin() {
return mercredimatin;
}
public void setMercredimatin(int mercredimatin) {
this.mercredimatin = mercredimatin;
}
@Bindable
public int getMercrediapmidi() {
return mercrediapmidi;
}
public void setMercrediapmidi(int mercrediapmidi) {
this.mercrediapmidi = mercrediapmidi;
}
@Bindable
public int getMercredisoir() {
return mercredisoir;
}
public void setMercredisoir(int mercredisoir) {
this.mercredisoir = mercredisoir;
}
@Bindable
public int getJeudimatin() {
return jeudimatin;
}
public void setJeudimatin(int jeudimatin) {
this.jeudimatin = jeudimatin;
}
@Bindable
public int getJeudiapmidi() {
return jeudiapmidi;
}
public void setJeudiapmidi(int jeudiapmidi) {
this.jeudiapmidi = jeudiapmidi;
}
@Bindable
public int getJeudisoir() {
return jeudisoir;
}
public void setJeudisoir(int jeudisoir) {
this.jeudisoir = jeudisoir;
}
@Bindable
public int getVendredimatin() {
return vendredimatin;
}
public void setVendredimatin(int vendredimatin) {
this.vendredimatin = vendredimatin;
}
@Bindable
public int getVendrediapmidi() {
return vendrediapmidi;
}
public void setVendrediapmidi(int vendrediapmidi) {
this.vendrediapmidi = vendrediapmidi;
}
@Bindable
public int getVendredisoir() {
return vendredisoir;
}
public void setVendredisoir(int vendredisoir) {
this.vendredisoir = vendredisoir;
}
@Bindable
public int getWeekendmatin() {
return weekendmatin;
}
public void setWeekendmatin(int weekendmatin) {
this.weekendmatin = weekendmatin;
}
@Bindable
public int getWeekendapmidi() {
return weekendapmidi;
}
public void setWeekendapmidi(int weekendapmidi) {
this.weekendapmidi = weekendapmidi;
}
@Bindable
public int getWeekendsoir() {
return weekendsoir;
}
public void setWeekendsoir(int weekendsoir) {
this.weekendsoir = weekendsoir;
}
public CalendrierDisponibilite(Parcel in ) {
this.idcalendrier = in.readInt();
this.iduser = in.readInt();
this.lundimatin = in.readInt();
this.lundiapmidi = in.readInt();
this.lundisoir = in.readInt();
this.mardimatin = in.readInt();
this.mardiapmidi = in.readInt();
this.mardisoir = in.readInt();
this.mercredimatin = in.readInt();
this.mercrediapmidi = in.readInt();
this.mercredisoir = in.readInt();
this.jeudimatin = in.readInt();
this.jeudiapmidi = in.readInt();
this.jeudisoir = in.readInt();
this.vendredimatin = in.readInt();
this.vendrediapmidi = in.readInt();
this.vendredisoir = in.readInt();
this.weekendmatin = in.readInt();
this.weekendapmidi = in.readInt();
this.weekendsoir = in.readInt();
// this.tstBool = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(idcalendrier);
dest.writeInt(iduser);
dest.writeInt(lundimatin);
dest.writeInt(lundiapmidi);
dest.writeInt(lundisoir);
dest.writeInt(mardimatin);
dest.writeInt(mardiapmidi);
dest.writeInt(mardisoir);
dest.writeInt(mercredimatin);
dest.writeInt(mercrediapmidi);
dest.writeInt(mercredisoir);
dest.writeInt(jeudimatin);
dest.writeInt(jeudiapmidi);
dest.writeInt(jeudisoir);
dest.writeInt(vendredimatin);
dest.writeInt(vendrediapmidi);
dest.writeInt(vendredisoir);
dest.writeInt(weekendmatin);
dest.writeInt(weekendapmidi);
dest.writeInt(weekendsoir);
// dest.writeInt(tstBool);
}
public static final Parcelable.Creator<CalendrierDisponibilite> CREATOR = new Parcelable.Creator<CalendrierDisponibilite>() {
public CalendrierDisponibilite createFromParcel(Parcel in) {
return new CalendrierDisponibilite(in);
}
public CalendrierDisponibilite[] newArray(int size) {
return new CalendrierDisponibilite[size];
}
};
@Override
public boolean equals(Object obj) {
if(obj instanceof CalendrierDisponibilite) {
CalendrierDisponibilite toCompare = (CalendrierDisponibilite) obj;
return (this.idcalendrier == toCompare.getIdcalendrier());
}
return false;
}
@Override
public int hashCode() {
return (this.getIdcalendrier());
}
}
и вот где мне это нужно:
public RepoCalendrierDisponibilite(int idPersonne) throws IOException {
this.calendrier = CallBy(idPersonne);
this.idPersonne = idPersonne;
Log.d("Calendrier Dispo : ", String.valueOf(this.calendrier.getDateModification()));
}
и, наконец, вот что я получаю, используя свой контроллер (результат виден в браузере):
{"idcalendrier":3,"iduser":3,"lundimatin":1,"lundiapmidi":1,"lundisoir":1,"mardimatin":1,"mardiapmidi":1,"mardisoir":1,"mercredimatin":1,"mercrediapmidi":1,"mercredisoir":1,"jeudimatin":1,"jeudiapmidi":1,"jeudisoir":1,"vendredimatin":1,"vendrediapmidi":1,"vendredisoir":1,"weekendmatin":1,"weekendapmidi":1,"weekendsoir":1,"DateModification":"2018-06-18T00:00:00"}
Так что, похоже, мой контроллер и данные работают.
В моем приложении есть проблема с функцией execute (). И как я поставил точку debbuger, которая ничего не показывает (приложение просто останавливается). Хотя, возможно, это проблема парсинга ... но мне не хватает опыта в модернизации, чтобы определить, что это или что-то еще.