美文网首页
Kotlin请求数据设置的response

Kotlin请求数据设置的response

作者: PeterWu丷 | 来源:发表于2019-06-18 19:56 被阅读0次

这里请求一个新闻列表,首先设置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请求数据了

相关文章

网友评论

      本文标题:Kotlin请求数据设置的response

      本文链接:https://www.haomeiwen.com/subject/knuqqctx.html