Skip to content

Commit

Permalink
♻️ [Android] 用新的思路重构了浏览器的书签
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaubee committed Jun 6, 2023
1 parent ba6dc35 commit c63c0c0
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 386 deletions.
3 changes: 2 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ android {
"proguard-rules.pro"
)
)
isShrinkResources = true //移除无用的resource文件
isShrinkResources = true
signingConfig = signingConfigs.getByName("debug")//移除无用的resource文件
}
create("sit") {
isDebuggable = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import io.ktor.util.date.*
import java.io.ByteArrayOutputStream
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalField
import java.util.*


internal const val WebSiteTableName = "website"

/**
* 定义数据实体
*/
Expand All @@ -26,12 +28,14 @@ internal const val WebSiteTableName = "website"
data class WebSiteInfo(
@PrimaryKey(autoGenerate = true) val id: Long = 0L,
var title: String,
var url: String,
// var parent: Int = 0,
var url: String = "",
val type: WebSiteType,
val timeMillis: Long = LocalDate.now().toEpochDay(),
val icon: ImageBitmap? = null,
// val time: Long = System.currentTimeMillis(),
) {
fun getStickyName() : String {
fun getStickyName(): String {
val currentOfEpochDay = LocalDate.now().toEpochDay()
return if (timeMillis >= currentOfEpochDay) {
"今天"
Expand Down Expand Up @@ -113,7 +117,7 @@ class Converters {
}

@TypeConverter
fun byteArrayToImageBitmap(byteArray: ByteArray?) : ImageBitmap? {
fun byteArrayToImageBitmap(byteArray: ByteArray?): ImageBitmap? {
return byteArray?.let {
if (it.isNotEmpty()) {
BitmapFactory.decodeByteArray(it, 0, it.size).asImageBitmap()
Expand All @@ -122,7 +126,7 @@ class Converters {
}

@TypeConverter
fun fromImageBitmap(imageBitmap: ImageBitmap?) : ByteArray? {
fun fromImageBitmap(imageBitmap: ImageBitmap?): ByteArray? {
return imageBitmap?.asAndroidBitmap()?.let {
val baos = ByteArrayOutputStream()
it.compress(Bitmap.CompressFormat.PNG, 100, baos)
Expand Down
Loading

0 comments on commit c63c0c0

Please sign in to comment.