Kotlin请求数据设置的response

2019-06-18  本文已影响0人  PeterWu丷

这里请求一个新闻列表,首先设置response

请求的新闻列表json数据

注意,NewData里的参数(news和isLast)要和json数据的参数名保持一致
在build中设置以下信息

androidExtensions {
        experimental = true
    }
class NewsResponse(code: Int, msg: String, val data: NewsData) : BaseResponse(code, msg)

class NewsData(
    val news: List<NewsEntity>,
    val isLast: Boolean
)

@Keep
@Parcelize
data class NewsEntity(
    val id: String,
    val title: String? = null,
    val content: String? = null,
    val publishedtime: String? = null,
    val author: String? = null,
    val coverpic1: String? = null,
    val coverpic2: String? = null,
    val coverpic3: String? = null,
    val catId: Int,
    val language: String?,
    val sourceUrl: String?,
    val catName: String? = null,
    val catNameEn: String? = null,
    val timeAgo: String? = null,
    val webview: Int,
    val subTitle: String? = null,
    val type: Int,
    var showType: Int = 0,
    var viewType: Int = 0
) : Parcelable

然后就可以设置Api请求数据了

上一篇 下一篇

猜你喜欢

热点阅读