Skip to content

Commit

Permalink
Merge pull request #354 from RedrockMobile/GuoXR/course_optimize
Browse files Browse the repository at this point in the history
🔖 发布 6.6.1 版本
  • Loading branch information
985892345 authored Mar 6, 2023
2 parents 85e6607 + a869f9a commit b99fea9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
4 changes: 4 additions & 0 deletions build-logic/core/app/src/main/kotlin/AppPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import org.gradle.kotlin.dsl.*
import java.io.File

/**
*
* 考虑到单模块调试,所以应该把通用的设置放在 BaseApplicationPlugin 里面,这里面只用来放特殊的设置
*
*@author ZhiQiang Tu
*@time 2022/10/11 17:28
*@signature There are no stars in the hills.
Expand Down Expand Up @@ -77,6 +80,7 @@ class AppPlugin : BasePlugin() {
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
outputDir = File(project.buildDir, "channel")
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
//这个命名跟发版 CI 有对应关系,请不要随意修改 !!!
apkNameFormat = "掌上重邮-\${versionName}-\${flavorName}-\${buildType}-\${buildTime}"
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
fastMode = false
Expand Down
6 changes: 1 addition & 5 deletions build-logic/core/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#
#####################################################################
#noinspection ShrinkerUnresolvedReference
#基线包使用,生成mapping.txtt
-printmapping mapping.txt
#补丁包使用,应用mapping.txt
#-applymapping mapping.txt
#-------------------------------------------定制化区域----------------------------------------------
#---------------------------------1.实体类---------------------------------
#原因:实体类数据,一定不能混淆,忽略了Serializable接口和Parcelable接口,实体类必须实现这两个接口
Expand Down Expand Up @@ -133,7 +129,7 @@
## hotfix
## Sophix https://help.aliyun.com/document_detail/61082.html
#基线包使用,生成mapping.txt
-printmapping mapping.txt
#-printmapping mapping.txt # 后面已经生成混淆映射文件
#生成的mapping.txt在app/build/outputs/mapping/release路径下,移动到/app路径下
#修复后的项目使用,保证混淆结果一致
#-applymapping mapping.txt
Expand Down
4 changes: 2 additions & 2 deletions build-logic/core/versions/src/main/kotlin/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ object Config {
const val targetSdk = 33
const val compileSdk = targetSdk

const val versionCode = 81 // 线上80,开发81
const val versionName = "6.6.1-beta" // 线上6.6.0,开发6.6.1
const val versionCode = 81 // 线上81,开发82
const val versionName = "6.6.1" // 线上6.6.1,开发6.6.2

val releaseAbiFilters = listOf("arm64-v8a")
val debugAbiFilters = listOf("arm64-v8a","x86_64")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,24 @@ interface ILessonService : IProvider {
set(value) = defaultSp.edit { putBoolean("是否使用本地课表数据", value) }
}

object CourseDisallowLocalSaveException : RuntimeException("课表数据不被允许本地保存")

/**
* 直接得到当前学号的课
* - 上游已主动切换成 io 线程
* - 在得不到这个人课表数据时会抛出异常,比如学号为空串时
* - 在不允许使用本地缓存且得不到课表数据时抛出 [CourseDisallowLocalSaveException] 异常
*/
fun getStuLesson(stuNum: String): Single<List<Lesson>>

/**
* 得到当前登录人的课
* - 上游已主动切换成 io 线程
* - 在得不到这个人课表数据时会抛出异常
* - 在不允许使用本地缓存且得不到课表数据时抛出 [CourseDisallowLocalSaveException] 异常
*/
fun getSelfLesson(): Single<List<Lesson>>

/**
* 得到当前关联人的课
* - 上游已主动切换成 io 线程
* - 在不存在关联人和得不到这个人课表数据时会抛出异常
* - 在不允许使用本地缓存且得不到课表数据时抛出 [CourseDisallowLocalSaveException] 异常
*/
fun getLinkLesson(): Single<List<Lesson>>

Expand All @@ -63,7 +58,6 @@ interface ILessonService : IProvider {
* - 上游已主动切换成 io 线程
* - 在得不到当前登录人课表数据时会抛出异常
* - 在不存在关联人和得不到这个人课表数据时会返回 emptyList()
* - 在不允许使用本地缓存且得不到课表数据时抛出 [CourseDisallowLocalSaveException] 异常
*/
fun getSelfLinkLesson(): Single<Pair<List<Lesson>, List<Lesson>>>

Expand All @@ -75,8 +69,10 @@ interface ILessonService : IProvider {
* - 没登录时发送 emptyList()
* - 没有连接网络并且不允许使用本地缓存时会一直不发送数据给下游
* - 不会抛出异常给下游
*
* @param isForce 是否强制刷新,默认不进行强制刷新,会使用应用生命周期的缓存
*/
fun observeSelfLesson(): Observable<List<Lesson>>
fun observeSelfLesson(isForce: Boolean = false): Observable<List<Lesson>>

/**
* 这里提供 Calendar 与 [hashDay] 互换代码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ interface ILinkService : IProvider {
fun getLinkStu(): Single<LinkStu>

/**
* 观察当前登录人的关联情况
* - 不会抛异常
* 观察当前登录人的我的关联数据
* - 支持换账号登录后返回新登录人的数据
* - 没登录返回的数据全为空串
* - 第一次观察时会请求新的数据
* - 使用了 distinctUntilChanged(),只会在数据更改了才会回调
* - 上游不会抛出错误到下游
*
* ## 注意
* - 观察后是一定有值发送下来的,请使用 [LinkStu.isNull] 来判断是否存在关联人
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.annotation.WorkerThread
import androidx.collection.ArrayMap
import com.mredrock.cyxbs.api.account.IAccountService
import com.mredrock.cyxbs.api.course.ILessonService
import com.mredrock.cyxbs.api.course.ILessonService.CourseDisallowLocalSaveException
import com.mredrock.cyxbs.course.page.course.bean.StuLessonBean
import com.mredrock.cyxbs.course.page.course.room.LessonDataBase
import com.mredrock.cyxbs.course.page.course.room.StuLessonEntity
Expand All @@ -19,7 +18,6 @@ import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.rx3.asObservable
import retrofit2.HttpException

/**
* ...
Expand All @@ -41,7 +39,7 @@ object StuLessonRepository {
* - 没有连接网络并且不允许使用本地缓存时会一直不发送数据给下游
* - 不会抛出异常给下游
*/
fun observeSelfLesson(): Observable<List<StuLessonEntity>> {
fun observeSelfLesson(isForce: Boolean = false): Observable<List<StuLessonEntity>> {
return IAccountService::class.impl
.getUserService()
.observeStuNumState()
Expand All @@ -54,7 +52,7 @@ object StuLessonRepository {
.observeLesson(stuNum)
.doOnSubscribe {
// 在开始订阅时异步请求一次云端数据,所以下游会先拿到本地数据库中的数据,如果远端数据更新了,整个流会再次通知
refreshLesson(stuNum).unsafeSubscribeBy()
refreshLesson(stuNum, isForce).unsafeSubscribeBy()
}.distinctUntilChanged() // 去重
.subscribeOn(Schedulers.io())
} else {
Expand All @@ -65,7 +63,7 @@ object StuLessonRepository {
emit(Unit)
}.asObservable()
.switchMap {
refreshLesson(stuNum)
refreshLesson(stuNum, isForce)
.onErrorComplete() // 网络请求的异常全部吞掉
.toObservable()
}
Expand Down Expand Up @@ -108,7 +106,6 @@ object StuLessonRepository {

/**
* 得到某人的课,在得不到这个人课表数据时会抛出异常,
* 在不允许使用本地数据且得到课表数据失败时抛出 [CourseDisallowLocalSaveException] 异常
*/
fun getLesson(
stuNum: String,
Expand All @@ -127,10 +124,7 @@ object StuLessonRepository {
throw throwable
}
} else {
when (throwable) {
is HttpException -> throw CourseDisallowLocalSaveException
else -> throw throwable
}
throw throwable
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class HomeCourseViewModel : BaseViewModel() {
*/
private fun initObserve(): Disposable {
// 自己课的观察流
val selfLessonObservable = StuLessonRepository.observeSelfLesson()
val selfLessonObservable = StuLessonRepository.observeSelfLesson(true)

// 关联人课的观察流
val linkLessonObservable = LinkRepository.observeLinkStudent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object LinkRepository {
/**
* 观察当前登录人的我的关联数据
* - 支持换账号登录后返回新登录人的数据
* - 没登录返回 [LinkStuEntity.NULL]
* - 第一次观察时会请求新的数据
* - 使用了 distinctUntilChanged(),只会在数据更改了才会回调
* - 上游不会抛出错误到下游
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class LessonServiceImpl : ILessonService {
}
}

override fun observeSelfLesson(): Observable<List<ILessonService.Lesson>> {
return StuLessonRepository.observeSelfLesson()
override fun observeSelfLesson(isForce: Boolean): Observable<List<ILessonService.Lesson>> {
return StuLessonRepository.observeSelfLesson(isForce)
.map { it.toLesson() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.mredrock.cyxbs.lib.utils.service.impl
import com.mredrock.cyxbs.config.config.SchoolCalendar
import com.mredrock.cyxbs.lib.utils.extensions.toast
import com.mredrock.cyxbs.lib.utils.utils.judge.NetworkUtil
import com.mredrock.cyxbs.main.BuildConfig
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
Expand Down Expand Up @@ -93,7 +92,12 @@ object CourseHeaderHelper {
if (linkData.selfNum.isBlank()) {
Observable.just(HintHeader("登录后即可查看课表"))
} else {
observeHeader3(nowWeek, linkData.selfNum, linkData.linkNum, linkData.isBoy)
observeHeader3(
nowWeek,
linkData.selfNum,
if (linkData.isShowLink) linkData.linkNum else "",
linkData.isBoy
)
}
}
}
Expand Down

0 comments on commit b99fea9

Please sign in to comment.