parent
e7aa8f71cd
commit
5d8da4bff7
@ -0,0 +1,12 @@
|
||||
package com.yinuo.commonlibtest
|
||||
|
||||
import android.app.Application
|
||||
import com.yinuo.commonlib.CommonApplication
|
||||
|
||||
class MyApplication : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
CommonApplication.intLibs(this)
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.yinuo.commonlibtest.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
/**
|
||||
* 文章数据类
|
||||
*/
|
||||
@Parcelize
|
||||
data class Article(var apkLink: String = ""): Parcelable {
|
||||
var audit: Int = 0
|
||||
var author: String = ""
|
||||
var canEdit: Boolean = false
|
||||
var chapterId: Int = 0
|
||||
var chapterName: String = ""
|
||||
var collect: Boolean = false
|
||||
var courseId: Int = 0
|
||||
var desc: String = ""
|
||||
var descMd: String = ""
|
||||
var envelopePic: String = ""
|
||||
var fresh: Boolean = false
|
||||
var host: String = ""
|
||||
var id: Long = 0
|
||||
var link: String = ""
|
||||
var niceDate: String = ""
|
||||
var niceShareDate: String = ""
|
||||
var origin: String = ""
|
||||
var prefix: String = ""
|
||||
var projectLink: String = ""
|
||||
var publishTime: Long = 0
|
||||
var realSuperChapterId: Long = 0
|
||||
var selfVisible: Int = 0
|
||||
var shareDate: Long = 0
|
||||
var shareUser: String = ""
|
||||
var superChapterId: Long = 0
|
||||
var superChapterName: String = ""
|
||||
var tags: List<ArticleTag>? = null
|
||||
var title: String = ""
|
||||
var type: Int = 0
|
||||
var userId: Long = 0
|
||||
var visible: Int = 0
|
||||
var zan: Int = 0
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.yinuo.commonlibtest.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class ArticleTag(
|
||||
var name: String? = "",
|
||||
var url: String? = ""
|
||||
) : Parcelable
|
@ -0,0 +1,15 @@
|
||||
package com.yinuo.commonlibtest.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.yinuo.commonlibtest.bean.Article
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class Articles(var curPage: Int) : Parcelable {
|
||||
var datas: List<Article>? = null
|
||||
var offset: Int = 0
|
||||
var over: Boolean = false
|
||||
var pageCount: Long = 0
|
||||
var size: Int = 0
|
||||
var total: Long = 0
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.yinuo.commonlibtest.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.yinuo.commonlib.net.bean.BaseResponse
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class ArticlesResponse(var data: Articles? = null): Parcelable, BaseResponse()
|
@ -0,0 +1,27 @@
|
||||
package com.yinuo.commonlibtest.manager
|
||||
|
||||
import com.common.commonlib.net.RequestCallBack
|
||||
import com.yinuo.commonlib.net.BaseObserve
|
||||
import com.yinuo.commonlibtest.bean.ArticlesResponse
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.Path
|
||||
|
||||
class InternetLoader : BaseObserve<InternetLoader.HomeApi>() {
|
||||
var homeApi: HomeApi
|
||||
|
||||
init {
|
||||
homeApi = initService(HomeApi::class.java)
|
||||
}
|
||||
|
||||
fun getHomeArticles(pageName: Int, callBack: RequestCallBack<ArticlesResponse>) {
|
||||
observe(homeApi.getHomeArticles(pageName), callBack)
|
||||
}
|
||||
|
||||
interface HomeApi {
|
||||
@Headers("baseurl:debug1")
|
||||
@GET("/article/list/{pageNum}/json")
|
||||
fun getHomeArticles(@Path("pageNum") pageNum: Int): Observable<ArticlesResponse>
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue