使用realm改造无法获得带有对象的json

时间:2016-02-12 15:54:56

标签: android retrofit realm retrofit2

当我需要拾取具有其他内部对象的对象时,我在尝试使用领域进行改造时遇到了问题。

问题是.enqueue改造方法永远不会得到回调,看起来解析就是永远。

我在日志中得到了这个

enter image description here

下面的模型类没有其他模型(相册和艺术家)时代码工作。

简单的Json im解析。这是一张里面有艺术家的专辑。

{
    id: "2",
    name: "CoverGirl",
    image: "http://res.cloudinary.com/thefader/image/upload/s--Ky_sXRw2--/w_760,c_limit,q_jpegmini,f_auto/mila_j_cover_q96o4t.jpg",
    bigger: false,
    artist: {
        id: 2,
        name: "Mila J",
        image: "http://www.billboard.com/files/styles/article_main_image/public/media/mila-j-pose-2015-billboard-650.jpg"
    }
}

专辑类

public class Album {
    private int id;
    private String name;
    private Artist artist;

    ...getter and setter for all attributes
}

艺术家课

public class Artist extends RealmObject{
    private int id;
    private String name;

    ...getter and setter for all attributes
}

我正在使用

来调用它
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("my_url_is_here")
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    GitHubService service = retrofit.create(GitHubService.class);
    //The problem is here. the enqueue method stops here, and in the log cat show the messages that is in the image I publish
    service.getAlbum().enqueue(new Callback<Album>() {
        @Override
        public void onResponse(Call<Album> call, Response<Album> response) {
            System.out.println();
        }

        @Override
        public void onFailure(Call<Album> call, Throwable t) {
            System.out.println();
        }
    });

我认为问题是因为我的模型扩展RealmObject因为某些原因,改造无法解析它。

我只想要一个解释或者解决方案。任何答案都会非常有用。

0 个答案:

没有答案