Skip to content

Commit

Permalink
fix: 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Mystery00 committed Feb 4, 2024
1 parent fdfac04 commit cf2c09d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ val databaseModule = module {
}

private val MIGRATION_1_2: Migration = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_course_color` (`courseName` TEXT NOT NULL, `color` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_course_color` (`courseName` TEXT NOT NULL, `color` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
}
}

private val MIGRATION_2_3: Migration = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_thing` (`thingId` INTEGER NOT NULL, `title` TEXT NOT NULL, `location` TEXT NOT NULL, `allDay` INTEGER NOT NULL, `startTime` INTEGER NOT NULL, `endTime` INTEGER NOT NULL, `remark` TEXT NOT NULL, `color` TEXT NOT NULL, `extraData` TEXT NOT NULL, `year` TEXT NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, PRIMARY KEY(`thingId`))")
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_thing` (`thingId` INTEGER NOT NULL, `title` TEXT NOT NULL, `location` TEXT NOT NULL, `allDay` INTEGER NOT NULL, `startTime` INTEGER NOT NULL, `endTime` INTEGER NOT NULL, `remark` TEXT NOT NULL, `color` TEXT NOT NULL, `extraData` TEXT NOT NULL, `year` TEXT NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, PRIMARY KEY(`thingId`))")
}
}

private val MIGRATION_3_4: Migration = object : Migration(3, 4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("alter table tb_course_item rename to _temp_tb_course_item")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_course_item` (`courseName` TEXT NOT NULL, `teacherName` TEXT NOT NULL, `location` TEXT NOT NULL, `weekString` TEXT NOT NULL, `weekNum` INTEGER NOT NULL, `time` TEXT NOT NULL, `weekIndex` INTEGER NOT NULL, `type` INTEGER NOT NULL, `source` INTEGER NOT NULL, `extraData` TEXT NOT NULL, `year` TEXT NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
database.execSQL("insert into tb_course_item select courseName, teacherName, location, weekString, weekNum, time, weekIndex, type, source, '[]', year, term, studentId, id from _temp_tb_course_item")
database.execSQL("drop table _temp_tb_course_item")
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("alter table tb_course_item rename to _temp_tb_course_item")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_course_item` (`courseName` TEXT NOT NULL, `teacherName` TEXT NOT NULL, `location` TEXT NOT NULL, `weekString` TEXT NOT NULL, `weekNum` INTEGER NOT NULL, `time` TEXT NOT NULL, `weekIndex` INTEGER NOT NULL, `type` INTEGER NOT NULL, `source` INTEGER NOT NULL, `extraData` TEXT NOT NULL, `year` TEXT NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
db.execSQL("insert into tb_course_item select courseName, teacherName, location, weekString, weekNum, time, weekIndex, type, source, '[]', year, term, studentId, id from _temp_tb_course_item")
db.execSQL("drop table _temp_tb_course_item")
}
}

private val Migration_4_5: Migration = object : Migration(4, 5) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("drop table tb_course_item")
database.execSQL("drop table tb_custom_thing")
database.execSQL("drop table tb_notice")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_course` (`courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `location` TEXT NOT NULL, `teacher` TEXT NOT NULL, `extraData` TEXT NOT NULL, `campus` TEXT NOT NULL, `courseType` TEXT NOT NULL, `credit` REAL NOT NULL, `courseCodeType` TEXT NOT NULL, `courseCodeFlag` TEXT NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_practical_course` (`courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `teacher` TEXT NOT NULL, `campus` TEXT NOT NULL, `credit` REAL NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_experiment_course` (`courseName` TEXT NOT NULL, `experimentProjectName` TEXT NOT NULL, `teacherName` TEXT NOT NULL, `experimentGroupName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `region` TEXT NOT NULL, `location` TEXT NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_course` (`courseId` INTEGER NOT NULL, `courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `location` TEXT NOT NULL, `teacher` TEXT NOT NULL, `extraData` TEXT NOT NULL, `createTime` INTEGER NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
database.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_thing` (`thingId` INTEGER NOT NULL, `title` TEXT NOT NULL, `location` TEXT NOT NULL, `allDay` INTEGER NOT NULL, `startTime` INTEGER NOT NULL, `endTime` INTEGER NOT NULL, `remark` TEXT NOT NULL, `color` TEXT NOT NULL, `metadata` TEXT NOT NULL, `createTime` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("drop table tb_course_item")
db.execSQL("drop table tb_custom_thing")
db.execSQL("drop table tb_notice")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_course` (`courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `location` TEXT NOT NULL, `teacher` TEXT NOT NULL, `extraData` TEXT NOT NULL, `campus` TEXT NOT NULL, `courseType` TEXT NOT NULL, `credit` REAL NOT NULL, `courseCodeType` TEXT NOT NULL, `courseCodeFlag` TEXT NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_practical_course` (`courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `teacher` TEXT NOT NULL, `campus` TEXT NOT NULL, `credit` REAL NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_experiment_course` (`courseName` TEXT NOT NULL, `experimentProjectName` TEXT NOT NULL, `teacherName` TEXT NOT NULL, `experimentGroupName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `region` TEXT NOT NULL, `location` TEXT NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_course` (`courseId` INTEGER NOT NULL, `courseName` TEXT NOT NULL, `weekStr` TEXT NOT NULL, `weekList` TEXT NOT NULL, `dayIndex` INTEGER NOT NULL, `startDayTime` INTEGER NOT NULL, `endDayTime` INTEGER NOT NULL, `startTime` TEXT NOT NULL, `endTime` TEXT NOT NULL, `location` TEXT NOT NULL, `teacher` TEXT NOT NULL, `extraData` TEXT NOT NULL, `createTime` INTEGER NOT NULL, `year` INTEGER NOT NULL, `term` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
db.execSQL("CREATE TABLE IF NOT EXISTS `tb_custom_thing` (`thingId` INTEGER NOT NULL, `title` TEXT NOT NULL, `location` TEXT NOT NULL, `allDay` INTEGER NOT NULL, `startTime` INTEGER NOT NULL, `endTime` INTEGER NOT NULL, `remark` TEXT NOT NULL, `color` TEXT NOT NULL, `metadata` TEXT NOT NULL, `createTime` INTEGER NOT NULL, `studentId` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class BackgroundActivity : BaseComposeActivity() {
verticalArrangement = Arrangement.Center,
) {
CircularProgressIndicator(
progress = downloadProgressState.progress.progress / 100.0F,
progress = { downloadProgressState.progress.progress / 100.0F },
modifier = Modifier.size(72.dp),
)
Spacer(modifier = Modifier.height(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import androidx.compose.material.icons.rounded.Add
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -175,7 +175,7 @@ class CustomCourseActivity : BaseSelectComposeActivity() {
)
}
stickyHeader {
Divider()
HorizontalDivider()
}
itemsIndexed(
pager,
Expand Down Expand Up @@ -821,7 +821,7 @@ class CustomCourseActivity : BaseSelectComposeActivity() {
}
}
}
Divider(
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp, bottom = 4.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ModalBottomSheet
Expand Down Expand Up @@ -165,7 +165,7 @@ class CustomThingActivity : BaseSelectComposeActivity() {
}
}
stickyHeader {
Divider()
HorizontalDivider()
}
itemsIndexed(
pager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
Expand Down Expand Up @@ -266,7 +266,7 @@ fun DayHeader(dayString: String) {

@Composable
private fun RowScope.DayHeaderLine() {
Divider(
HorizontalDivider(
modifier = Modifier
.weight(1f)
.align(Alignment.CenterVertically),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -152,11 +152,11 @@ val profileCourseContent: TabContent = @Composable { ext ->
}
}
}
Divider(
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.height(6.dp)
.background(ExtendedTheme.colorScheme.surfaceContainer),
.background(ExtendedTheme.colorScheme.surfaceContainer)
)

val menuList by viewModel.menu.collectAsState()
Expand All @@ -183,19 +183,19 @@ val profileCourseContent: TabContent = @Composable { ext ->
}
})
if (iterator.hasNext()) {
Divider(
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.height(1.dp)
.background(ExtendedTheme.colorScheme.surfaceContainer),
.background(ExtendedTheme.colorScheme.surfaceContainer)
)
}
}
Divider(
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.height(6.dp)
.background(ExtendedTheme.colorScheme.surfaceContainer),
.background(ExtendedTheme.colorScheme.surfaceContainer)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ private fun BoxScope.ShowCourseDialog(
}
}
}
@Suppress("DEPRECATION")
HorizontalPagerIndicator(
pageCount = showList.size,
pagerState = pagerState,
Expand Down

0 comments on commit cf2c09d

Please sign in to comment.