-
Notifications
You must be signed in to change notification settings - Fork 107
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
Showing
71 changed files
with
733 additions
and
1,477 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
import com.aleyn.BuildConfig | ||
import com.aleyn.Depend | ||
import com.aleyn.AndroidX | ||
import com.aleyn.Retrofit | ||
|
||
plugins { | ||
id("com.android.application") | ||
kotlin("android") | ||
kotlin("kapt") | ||
} | ||
|
||
android { | ||
compileSdk = BuildConfig.compileSdkVersion | ||
|
||
defaultConfig { | ||
applicationId = BuildConfig.applicationId | ||
minSdk = BuildConfig.minSdkVersion | ||
targetSdk = BuildConfig.targetSdkVersion | ||
versionCode = BuildConfig.versionCode | ||
versionName = BuildConfig.versionName | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
|
||
buildFeatures { | ||
dataBinding = true | ||
viewBinding = true | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) | ||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) | ||
AndroidX.values.forEach { implementation(it) } | ||
testImplementation(Depend.junit) | ||
androidTestImplementation(Depend.androidTestJunit) | ||
androidTestImplementation(Depend.espressoCore) | ||
//MVVMLin | ||
implementation(project("path" to ":mvvmlin")) | ||
//第三方 | ||
implementation(Depend.banner) | ||
implementation(Depend.BRVAH) | ||
implementation(Depend.refreshKernel) | ||
implementation(Depend.refreshHeader) | ||
implementation(Depend.bdclta) | ||
implementation(Depend.bdcltaRv) | ||
implementation(Depend.netCache) | ||
implementation(Depend.netCache) | ||
Retrofit.values.forEach { implementation(it) } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.pcl.mvvm.common | ||
|
||
/** | ||
* @auther : Aleyn | ||
* @author : Aleyn | ||
* time : 2019/08/16 | ||
*/ | ||
object Constant { | ||
|
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 |
---|---|---|
@@ -1,69 +1,47 @@ | ||
package com.pcl.mvvm.data | ||
|
||
import com.aleyn.cache.CacheMode | ||
import com.aleyn.mvvm.base.BaseModel | ||
import com.pcl.mvvm.app.base.BaseResult | ||
import com.pcl.mvvm.data.db.dao.HomeDao | ||
import com.pcl.mvvm.data.http.HomeNetWork | ||
import com.pcl.mvvm.network.entity.BannerBean | ||
import com.pcl.mvvm.network.entity.HomeListBean | ||
import com.pcl.mvvm.network.entity.NavTypeBean | ||
import com.pcl.mvvm.network.entity.UsedWeb | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* @auther : Aleyn | ||
* @author : Aleyn | ||
* time : 2019/10/29 | ||
*/ | ||
class HomeRepository private constructor( | ||
private val netWork: HomeNetWork, | ||
private val localData: HomeDao | ||
private val netWork: HomeNetWork | ||
) : BaseModel() { | ||
|
||
suspend fun getBannerData(refresh: Boolean = false): List<BannerBean> { | ||
return cacheNetCall({ | ||
netWork.getBannerData() | ||
}, { | ||
localData.getBannerList() | ||
}, { | ||
if (refresh) localData.deleteBannerAll() | ||
localData.insertBanner(it) | ||
}, { | ||
!refresh && !it.isNullOrEmpty() | ||
}) | ||
fun getBannerData(refresh: Boolean): Flow<BaseResult<List<BannerBean>>> { | ||
val cacheModel = | ||
if (refresh) CacheMode.NETWORK_PUT_CACHE else CacheMode.READ_CACHE_NETWORK_PUT | ||
return netWork.getBannerData(cacheModel) | ||
} | ||
|
||
suspend fun getHomeList(page: Int, refresh: Boolean): HomeListBean { | ||
return cacheNetCall({ | ||
netWork.getHomeList(page) | ||
}, { | ||
localData.getHomeList(page + 1) | ||
}, { | ||
if (refresh) localData.deleteHomeAll() | ||
localData.insertData(it) | ||
}, { | ||
!refresh | ||
}) | ||
fun getHomeList(page: Int, refresh: Boolean = false): Flow<BaseResult<HomeListBean>> { | ||
val cacheModel = | ||
if (refresh) CacheMode.NETWORK_PUT_CACHE else CacheMode.READ_CACHE_NETWORK_PUT | ||
return netWork.getHomeList(page, cacheModel) | ||
} | ||
|
||
suspend fun getNaviJson(): BaseResult<List<NavTypeBean>> { | ||
return netWork.getNaviJson() | ||
} | ||
suspend fun getNaviJson() = netWork.getNaviJson() | ||
|
||
suspend fun getProjectList(page: Int, cid: Int): BaseResult<HomeListBean> { | ||
return netWork.getProjectList(page, cid) | ||
} | ||
suspend fun getProjectList(page: Int, cid: Int) = netWork.getProjectList(page, cid) | ||
|
||
suspend fun getPopularWeb(): BaseResult<MutableList<UsedWeb>> { | ||
return netWork.getPopularWeb() | ||
} | ||
suspend fun getPopularWeb() = netWork.getPopularWeb() | ||
|
||
companion object { | ||
|
||
@Volatile | ||
private var INSTANCE: HomeRepository? = null | ||
|
||
fun getInstance(netWork: HomeNetWork, homeDao: HomeDao) = | ||
fun getInstance(netWork: HomeNetWork) = | ||
INSTANCE ?: synchronized(this) { | ||
INSTANCE ?: HomeRepository(netWork, homeDao).also { INSTANCE = it } | ||
INSTANCE ?: HomeRepository(netWork).also { INSTANCE = it } | ||
} | ||
} | ||
} |
Oops, something went wrong.