无法调用无参数的公共com.ramiissa.dubaiing.data.network.model.news.NewsResponse()

时间:2018-08-05 20:05:56

标签: android gson rx-java

我有一个针对NewsResponse和RxJavaRetrofit的AutoValue类 而我的AutoValue类型适配器是

@AutoValue
public abstract class NewsResponse implements Parcelable {

public static TypeAdapter<NewsResponse> typeAdapter(Gson gson){
    return new AutoValue_NewsResponse.GsonTypeAdapter(gson);
}

@SerializedName("api_text")
public abstract String isSuccess();

@SerializedName("news")
public abstract List<NewsDetails> getNews();

}

我的NewsDetails类是

@AutoValue
public abstract class NewsDetails implements Parcelable{

public static TypeAdapter<NewsDetails> typeAdapter(Gson gson){
    return new AutoValue_NewsDetails.GsonTypeAdapter(gson);
}

@SerializedName("id")
public abstract String getNewsId();

@SerializedName("description")
public abstract String getDescription();

@SerializedName("title")
public abstract String getTitle();

@SerializedName("category")
public abstract String getCategory();

@SerializedName("thumbnail")
public abstract String getImageUrl();

@SerializedName("posted_time")
public abstract String getPostedTime();

}

我的Rxjava呼叫是

        model.getNews("1", "1", OrderBy.DESC)
            .observeOn(AndroidSchedulers.mainThread())
            .doOnError(throwable -> ToastUtils.showShort(throwable.getMessage()))
            .doOnSuccess(newsResponse -> view.setUpRecyclerView(newsResponse.getNews()))
            .subscribeOn(Schedulers.io())
            .subscribe();

我的问题是,我进行改造电话时遇到此错误

  

在没有参数的情况下无法调用公共com.ramiissa.dubaiing.data.network.model.news.NewsResponse()

来自服务器的Api响应如下

{
"api_status": "200",
"api_text": "success",
"api_version": "1.5.2",
"news": [
    {
        "id": "1",
        "title": "news1news1 news1 news1 news1 news1 news1 news1 news1",
        "description": "news1 news1 news1 news1 news1 news1 news1 news1 news1 news1  news1 news1 news1 news1 news1 news1 news1 news1 news1 news1",
        "category": "2",
        "category_name": "English",
        "thumbnail": "http://www.dubai-ing.net/upload/photos/2018/08/nAlMzZ4xZ3XfdMsyT5bj_05_c908f62a43c4f7c8d04e38b29858d9e1_image.jpg",
        "posted_time": "5 hours ago",
        "tags_array": [
            "news1"
        ]
    }
  ]
}

0 个答案:

没有答案