use of org.edx.mobile.model.PaginationData in project edx-app-android by edx.
the class JsonPageDeserializer method deserialize.
@Override
public Page<?> deserialize(JsonElement json, final Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final List<?> list = context.deserialize(json.getAsJsonObject().get("results"), new ParameterizedType() {
public Type getRawType() {
return List.class;
}
public Type getOwnerType() {
return null;
}
public Type[] getActualTypeArguments() {
return ((ParameterizedType) typeOfT).getActualTypeArguments();
}
});
JsonElement paginationJson = json.getAsJsonObject().get("pagination");
if (null == paginationJson || paginationJson.isJsonNull()) {
paginationJson = json;
}
final PaginationData paginationData = context.deserialize(paginationJson, PaginationData.class);
return new Page<>(paginationData, list);
}
Aggregations