parent
fa7f69c5ef
commit
259fe55870
@ -0,0 +1,16 @@ |
||||
package io.legado.app.data.dao |
||||
|
||||
import androidx.lifecycle.LiveData |
||||
import androidx.room.Dao |
||||
import androidx.room.Query |
||||
import io.legado.app.data.entities.IdealEntity |
||||
|
||||
@Dao |
||||
interface BookIdealDao { |
||||
|
||||
/** |
||||
* 根据书名查找想法列表 |
||||
*/ |
||||
@Query("SELECT * FROM book_ideals WHERE `bookName` = bookName") |
||||
fun getIdealList(bookName: String): LiveData<List<IdealEntity>> |
||||
} |
@ -0,0 +1,23 @@ |
||||
package io.legado.app.data.dao |
||||
|
||||
import androidx.lifecycle.LiveData |
||||
import androidx.room.Dao |
||||
import androidx.room.Insert |
||||
import androidx.room.OnConflictStrategy |
||||
import androidx.room.Query |
||||
import io.legado.app.data.entities.IdealDetailEntity |
||||
|
||||
@Dao |
||||
interface BookIdealDetailDao { |
||||
|
||||
|
||||
/** |
||||
* 根据想法id查询想法内容列表 |
||||
*/ |
||||
@Query("SELECT * FROM book_ideal_list WHERE `idealId` = idealId") |
||||
fun getIdealListById(idealId: Long): LiveData<List<IdealDetailEntity>> |
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE) |
||||
fun insertIDeal(vararg idealDetail: IdealDetailEntity) |
||||
|
||||
} |
@ -0,0 +1,4 @@ |
||||
package io.legado.app.data.dao |
||||
|
||||
class BookLineDao { |
||||
} |
@ -0,0 +1,42 @@ |
||||
package io.legado.app.data.entities |
||||
|
||||
import io.legado.app.R |
||||
|
||||
class DrawLineEntity { |
||||
|
||||
// 第几章的划线 |
||||
var chapterIndex: Int = 0 |
||||
|
||||
// 章节的第几个字符开始 |
||||
var startIndex: Int = 0 |
||||
|
||||
// 本章的第几个字符结束 |
||||
var endIndex: Int = 0 |
||||
|
||||
// 划线的样式 |
||||
var lineStyle: LineStyle = LineStyle.SHAPE |
||||
|
||||
// 划线颜色 |
||||
var lineColor: LineColor = LineColor.BLUE |
||||
|
||||
enum class LineColor { |
||||
BLUE, |
||||
ORANGE, |
||||
YELLOW, |
||||
GREEN |
||||
} |
||||
|
||||
enum class LineStyle { |
||||
STEEP, // 直线 |
||||
WAVE, // 波浪线 |
||||
SHAPE, // 选中样式 |
||||
} |
||||
|
||||
|
||||
fun getLineColor() = when (lineColor) { |
||||
LineColor.BLUE -> R.color.md_blue_200 |
||||
LineColor.GREEN -> R.color.md_green_600 |
||||
LineColor.ORANGE -> R.color.md_orange_600 |
||||
LineColor.YELLOW -> R.color.md_yellow_600 |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package io.legado.app.data.entities |
||||
|
||||
import android.os.Parcelable |
||||
import androidx.room.Entity |
||||
import kotlinx.parcelize.Parcelize |
||||
|
||||
@Entity(primaryKeys = ["id", "idealId"], tableName = "book_ideal_list") |
||||
@Parcelize |
||||
data class IdealDetailEntity( |
||||
var id: Long = 0b1, |
||||
var idealId: Long, // 整个想法的id |
||||
var idealContent: String? = "", // 想法内容 |
||||
var userAvatar: String? = "", // 用户头像 |
||||
var assistCount: Int = 0, // 赞数量 |
||||
var replyCount: Int = 0 // 回复数量 |
||||
) : Parcelable { |
||||
|
||||
override fun hashCode(): Int { |
||||
return id.hashCode() |
||||
} |
||||
|
||||
override fun equals(other: Any?): Boolean { |
||||
if (other !is IdealDetailEntity) return false |
||||
return id == other.id && |
||||
idealId == other.idealId && |
||||
idealContent == other.idealContent && |
||||
userAvatar == other.userAvatar && |
||||
assistCount == other.assistCount && |
||||
replyCount == other.replyCount |
||||
} |
||||
} |
@ -0,0 +1,53 @@ |
||||
package io.legado.app.data.entities |
||||
|
||||
import android.os.Parcelable |
||||
import androidx.room.Entity |
||||
import androidx.room.PrimaryKey |
||||
import io.legado.app.R |
||||
import kotlinx.parcelize.Parcelize |
||||
|
||||
/** |
||||
* 想法 |
||||
*/ |
||||
@Parcelize |
||||
@Entity(tableName = "book_ideals") |
||||
data class IdealEntity( |
||||
|
||||
@PrimaryKey |
||||
var idealId: Long = 0, |
||||
|
||||
// 在本章里面的第几个想法 |
||||
var inChapterIndex: Int = 0, |
||||
|
||||
// 书id |
||||
var bookName: String = "", |
||||
|
||||
// 第几章的想法 |
||||
var chapterIndex: Int = 0, |
||||
|
||||
// 章节的第几个字符开始 |
||||
var startIndex: Int = 0, |
||||
|
||||
// 本章的第几个字符结束 |
||||
var endIndex: Int = 0 |
||||
|
||||
) : Parcelable { |
||||
|
||||
|
||||
override fun hashCode(): Int { |
||||
return idealId.hashCode() |
||||
} |
||||
|
||||
override fun equals(other: Any?): Boolean { |
||||
if (other is IdealEntity) { |
||||
return idealId == other.idealId && |
||||
chapterIndex == other.chapterIndex && |
||||
startIndex == other.startIndex && |
||||
endIndex == other.endIndex |
||||
} |
||||
|
||||
return false |
||||
} |
||||
|
||||
fun getLineColor() = R.color.md_red_300 |
||||
} |
@ -0,0 +1,15 @@ |
||||
package io.legado.app.data.entities |
||||
|
||||
import android.os.Parcelable |
||||
import androidx.room.Entity |
||||
import kotlinx.parcelize.Parcelize |
||||
|
||||
@Entity( |
||||
tableName = "ideal_detail_list", |
||||
primaryKeys = ["id", "idealId"] |
||||
) |
||||
@Parcelize |
||||
data class IdealRelation( |
||||
var id: Long = 0b1, |
||||
var idealId: Long = 0b1 |
||||
) : Parcelable |
@ -0,0 +1,22 @@ |
||||
package io.legado.app.data.entities |
||||
|
||||
import android.os.Parcelable |
||||
import androidx.room.Embedded |
||||
import androidx.room.Junction |
||||
import androidx.room.Relation |
||||
import kotlinx.parcelize.Parcelize |
||||
|
||||
@Parcelize |
||||
data class IdealWithDetail( |
||||
|
||||
@Embedded |
||||
var idealEntity: IdealEntity, |
||||
|
||||
@Relation( |
||||
parentColumn = "idealId", |
||||
entityColumn = "id", |
||||
entity = IdealDetailEntity::class, |
||||
associateBy = Junction(IdealRelation::class) |
||||
) |
||||
var idealList: List<IdealDetailEntity> |
||||
) : Parcelable |
@ -1,9 +1,18 @@ |
||||
package io.legado.app.ui.book.read.page.entities |
||||
|
||||
import io.legado.app.data.entities.DrawLineEntity |
||||
import io.legado.app.data.entities.IdealEntity |
||||
|
||||
data class TextChar( |
||||
val charData: String, |
||||
var start: Float, |
||||
var end: Float, |
||||
var selected: Boolean = false, |
||||
var isImage: Boolean = false |
||||
var isImage: Boolean = false, |
||||
// 是否是首行缩进字符 |
||||
var isIndent: Boolean = false, |
||||
// 划线 |
||||
var drawLineEntity: DrawLineEntity? = null, |
||||
// 想法 |
||||
var idealEntity: IdealEntity? = null |
||||
) |
Loading…
Reference in new issue