-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98c839b
commit 1bf9bf1
Showing
34 changed files
with
494 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.cniao5.home | ||
|
||
import com.cniao5.common.network.KtRetrofit | ||
import com.cniao5.common.utils.getBaseHost | ||
import com.cniao5.home.net.HomeService | ||
import com.cniao5.home.repo.HomeResource | ||
import com.cniao5.home.repo.IHomeResource | ||
import com.cniao5.home.ui.HomeViewModel | ||
import org.koin.core.parameter.parametersOf | ||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.bind | ||
import org.koin.dsl.module | ||
|
||
|
||
/* | ||
* 依赖注入管理 Home的module | ||
* */ | ||
val moduleHome = module { | ||
|
||
//service retrofit | ||
//single声明单例对象 | ||
// single { | ||
// KtRetrofit.initConfig("http://yapi.54yct.com/mock/24/") //baseurl | ||
// .getService(MineService::class.java) | ||
// } | ||
|
||
single { | ||
get<KtRetrofit> { parametersOf(getBaseHost()) }.getService(HomeService::class.java) | ||
} | ||
|
||
//repo IMineResource | ||
single { HomeResource(get()) } bind IHomeResource::class | ||
|
||
viewModel { HomeViewModel(get()) } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.cniao5.home.net | ||
import androidx.annotation.Keep | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
|
||
/* | ||
* 首页上方banner图数据 | ||
* */ | ||
class BannerList : ArrayList<BannerList.BannerListItem>(){ | ||
@Keep | ||
data class BannerListItem( | ||
@SerializedName("client_url") | ||
val clientUrl: Any?, | ||
@SerializedName("created_time") | ||
val createdTime: String?, | ||
val id: Int, | ||
@SerializedName("img_url") | ||
val imgUrl: String?, | ||
val name: Any?, | ||
@SerializedName("order_num") | ||
val orderNum: Int, | ||
@SerializedName("page_show") | ||
val pageShow: Int, | ||
@SerializedName("redirect_url") | ||
val redirectUrl: String?, | ||
val state: Int, | ||
val type: String? | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.cniao5.home.net | ||
|
||
import com.test.service.net.BaseResponse | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
|
||
/* | ||
* 主页模块的接口 | ||
* */ | ||
interface HomeService { | ||
|
||
/* | ||
* 首页上方banner | ||
* */ | ||
@GET("ad/new/banner/list") | ||
fun getBanner( | ||
@Query("type")type: Int = 2, //类型 1:小程序 2:web 3:h5 4:ios 5:android 如: 2表示web 默认2 | ||
@Query("page_show") pageshow:Int = 1 //页面显示 1 首页 2 课程 3 大数据学院 4 机器人学院 5 人工智能学院 6 推广员 默认1 | ||
) : Call<BaseResponse> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.cniao5.home.repo | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import com.blankj.utilcode.util.LogUtils | ||
import com.cniao5.common.network.support.serverData | ||
import com.cniao5.home.net.BannerList | ||
import com.cniao5.home.net.HomeService | ||
import com.test.service.net.onBizError | ||
import com.test.service.net.onBizOK | ||
import com.test.service.net.onFailure | ||
import com.test.service.net.onSuccess | ||
|
||
class HomeResource (val service: HomeService) : IHomeResource { | ||
|
||
private val _liveBanner = MutableLiveData<BannerList>() | ||
|
||
override val liveBanner: LiveData<BannerList> | ||
get() = _liveBanner | ||
|
||
/* | ||
* 获取首页上方banner图数据 | ||
* */ | ||
override suspend fun getBanner() { | ||
service.getBanner() | ||
.serverData() | ||
.onSuccess { | ||
onBizError { code, message -> | ||
LogUtils.w("获取banner信息 onBizzError $code$message") | ||
} | ||
onBizOK<BannerList> { code, data, message -> | ||
_liveBanner.value = data | ||
LogUtils.i("获取banner信息 onBizzOK $data") | ||
} | ||
} | ||
.onFailure { | ||
LogUtils.e("获取banner信息 接口异常 ${it.message}") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.cniao5.home.repo | ||
|
||
import androidx.lifecycle.LiveData | ||
import com.cniao5.home.net.BannerList | ||
/* | ||
* 抽象接口 | ||
* */ | ||
interface IHomeResource { | ||
|
||
//首页上方banner图 | ||
val liveBanner: LiveData<BannerList> | ||
|
||
suspend fun getBanner() | ||
|
||
} |
Oops, something went wrong.