mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
0044250563
commit
93662444da
@ -38,14 +38,6 @@ object AppConst {
|
|||||||
SimpleDateFormat("yy-MM-dd-HH-mm-ss")
|
SimpleDateFormat("yy-MM-dd-HH-mm-ss")
|
||||||
}
|
}
|
||||||
|
|
||||||
const val rootGroupId = -100L
|
|
||||||
const val bookGroupAllId = -1L
|
|
||||||
const val bookGroupLocalId = -2L
|
|
||||||
const val bookGroupAudioId = -3L
|
|
||||||
const val bookGroupNetNoneId = -4L
|
|
||||||
const val bookGroupLocalNoneId = -5L
|
|
||||||
const val bookGroupErrorId = -11L
|
|
||||||
|
|
||||||
const val imagePathKey = "imagePath"
|
const val imagePathKey = "imagePath"
|
||||||
|
|
||||||
val menuViewNames = arrayOf(
|
val menuViewNames = arrayOf(
|
||||||
|
@ -7,7 +7,6 @@ import androidx.room.Database
|
|||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.data.dao.*
|
import io.legado.app.data.dao.*
|
||||||
import io.legado.app.data.entities.*
|
import io.legado.app.data.entities.*
|
||||||
import io.legado.app.help.DefaultData
|
import io.legado.app.help.DefaultData
|
||||||
@ -99,43 +98,43 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupAllSql = """
|
val insertBookGroupAllSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', show)
|
insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupAllId}, '全部', -10, 1
|
select ${BookGroup.IdAll}, '全部', -10, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAllId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdAll})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupAllSql)
|
db.execSQL(insertBookGroupAllSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupLocalSql = """
|
val insertBookGroupLocalSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', enableRefresh, show)
|
insert into book_groups(groupId, groupName, 'order', enableRefresh, show)
|
||||||
select ${AppConst.bookGroupLocalId}, '本地', -9, 0, 1
|
select ${BookGroup.IdLocal}, '本地', -9, 0, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdLocal})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupLocalSql)
|
db.execSQL(insertBookGroupLocalSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupMusicSql = """
|
val insertBookGroupMusicSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', show)
|
insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupAudioId}, '音频', -8, 1
|
select ${BookGroup.IdAudio}, '音频', -8, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAudioId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdAudio})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupMusicSql)
|
db.execSQL(insertBookGroupMusicSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupNetNoneGroupSql = """
|
val insertBookGroupNetNoneGroupSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', show)
|
insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupNetNoneId}, '网络未分组', -7, 1
|
select ${BookGroup.IdNetNone}, '网络未分组', -7, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNetNoneId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdNetNone})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupNetNoneGroupSql)
|
db.execSQL(insertBookGroupNetNoneGroupSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupLocalNoneGroupSql = """
|
val insertBookGroupLocalNoneGroupSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', show)
|
insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupLocalNoneId}, '本地未分组', -6, 0
|
select ${BookGroup.IdLocalNone}, '本地未分组', -6, 0
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalNoneId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdLocalNone})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupLocalNoneGroupSql)
|
db.execSQL(insertBookGroupLocalNoneGroupSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
val insertBookGroupErrorSql = """
|
val insertBookGroupErrorSql = """
|
||||||
insert into book_groups(groupId, groupName, 'order', show)
|
insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupErrorId}, '更新失败', -1, 1
|
select ${BookGroup.IdError}, '更新失败', -1, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupErrorId})
|
where not exists (select * from book_groups where groupId = ${BookGroup.IdError})
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
db.execSQL(insertBookGroupErrorSql)
|
db.execSQL(insertBookGroupErrorSql)
|
||||||
@Language("sql")
|
@Language("sql")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package io.legado.app.data.dao
|
package io.legado.app.data.dao
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.constant.BookType
|
import io.legado.app.constant.BookType
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
|
import io.legado.app.data.entities.BookGroup
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
@ -14,7 +14,7 @@ interface BookDao {
|
|||||||
select * from books where type & ${BookType.text} > 0
|
select * from books where type & ${BookType.text} > 0
|
||||||
and type & ${BookType.local} = 0
|
and type & ${BookType.local} = 0
|
||||||
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
||||||
and (select show from book_groups where groupId = ${AppConst.bookGroupNetNoneId}) != 1
|
and (select show from book_groups where groupId = ${BookGroup.IdNetNone}) != 1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun flowRoot(): Flow<List<Book>>
|
fun flowRoot(): Flow<List<Book>>
|
||||||
|
@ -6,8 +6,9 @@ import androidx.room.ColumnInfo
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppConst
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@ -26,14 +27,38 @@ data class BookGroup(
|
|||||||
var bookSort: Int = -1
|
var bookSort: Int = -1
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val IdRoot = -100L
|
||||||
|
const val IdAll = -1L
|
||||||
|
const val IdLocal = -2L
|
||||||
|
const val IdAudio = -3L
|
||||||
|
const val IdNetNone = -4L
|
||||||
|
const val IdLocalNone = -5L
|
||||||
|
const val IdError = -11L
|
||||||
|
|
||||||
|
fun flowBook(groupId: Long): Flow<List<Book>> {
|
||||||
|
return when (groupId) {
|
||||||
|
IdRoot -> appDb.bookDao.flowRoot()
|
||||||
|
IdAll -> appDb.bookDao.flowAll()
|
||||||
|
IdLocal -> appDb.bookDao.flowLocal()
|
||||||
|
IdAudio -> appDb.bookDao.flowAudio()
|
||||||
|
IdNetNone -> appDb.bookDao.flowNetNoGroup()
|
||||||
|
IdLocalNone -> appDb.bookDao.flowLocalNoGroup()
|
||||||
|
IdError -> appDb.bookDao.flowUpdateError()
|
||||||
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun getManageName(context: Context): String {
|
fun getManageName(context: Context): String {
|
||||||
return when (groupId) {
|
return when (groupId) {
|
||||||
AppConst.bookGroupAllId -> "$groupName(${context.getString(R.string.all)})"
|
IdAll -> "$groupName(${context.getString(R.string.all)})"
|
||||||
AppConst.bookGroupAudioId -> "$groupName(${context.getString(R.string.audio)})"
|
IdAudio -> "$groupName(${context.getString(R.string.audio)})"
|
||||||
AppConst.bookGroupLocalId -> "$groupName(${context.getString(R.string.local)})"
|
IdLocal -> "$groupName(${context.getString(R.string.local)})"
|
||||||
AppConst.bookGroupNetNoneId -> "$groupName(${context.getString(R.string.net_no_group)})"
|
IdNetNone -> "$groupName(${context.getString(R.string.net_no_group)})"
|
||||||
AppConst.bookGroupLocalNoneId -> "$groupName(${context.getString(R.string.local_no_group)})"
|
IdLocalNone -> "$groupName(${context.getString(R.string.local_no_group)})"
|
||||||
AppConst.bookGroupErrorId -> "$groupName(${context.getString(R.string.update_book_fail)})"
|
IdError -> "$groupName(${context.getString(R.string.update_book_fail)})"
|
||||||
else -> groupName
|
else -> groupName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseActivity
|
import io.legado.app.base.VMBaseActivity
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.constant.AppConst.charsets
|
import io.legado.app.constant.AppConst.charsets
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
@ -187,14 +186,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
|||||||
private fun initBookData() {
|
private fun initBookData() {
|
||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
BookGroup.flowBook(groupId).conflate().map { books ->
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
|
||||||
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
|
||||||
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
|
||||||
}.conflate().map { books ->
|
|
||||||
val booksDownload = books.filter {
|
val booksDownload = books.filter {
|
||||||
!it.isAudio
|
!it.isAudio
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseActivity
|
import io.legado.app.base.VMBaseActivity
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
@ -199,16 +198,7 @@ class BookshelfManageActivity :
|
|||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
val bookSort = AppConfig.getBookSortByGroupId(viewModel.groupId)
|
val bookSort = AppConfig.getBookSortByGroupId(viewModel.groupId)
|
||||||
when (viewModel.groupId) {
|
BookGroup.flowBook(viewModel.groupId).conflate().map { list ->
|
||||||
AppConst.rootGroupId -> appDb.bookDao.flowNetNoGroup()
|
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
|
||||||
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
|
||||||
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
|
||||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
|
||||||
else -> appDb.bookDao.flowByGroup(viewModel.groupId)
|
|
||||||
}.conflate().map { list ->
|
|
||||||
when (bookSort) {
|
when (bookSort) {
|
||||||
1 -> list.sortedByDescending {
|
1 -> list.sortedByDescending {
|
||||||
it.latestChapterTime
|
it.latestChapterTime
|
||||||
|
@ -11,7 +11,6 @@ import androidx.fragment.app.FragmentManager
|
|||||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
import androidx.fragment.app.FragmentStatePagerAdapter
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
@ -86,7 +85,7 @@ class BookshelfFragment1() : BaseBookshelfFragment(R.layout.fragment_bookshelf1)
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
override fun upGroup(data: List<BookGroup>) {
|
override fun upGroup(data: List<BookGroup>) {
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
appDb.bookGroupDao.enableGroup(AppConst.bookGroupAllId)
|
appDb.bookGroupDao.enableGroup(BookGroup.IdAll)
|
||||||
} else {
|
} else {
|
||||||
if (data != bookGroups) {
|
if (data != bookGroups) {
|
||||||
bookGroups.clear()
|
bookGroups.clear()
|
||||||
|
@ -10,11 +10,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.BaseFragment
|
import io.legado.app.base.BaseFragment
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
import io.legado.app.databinding.FragmentBooksBinding
|
import io.legado.app.databinding.FragmentBooksBinding
|
||||||
@ -135,16 +133,8 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
private fun upRecyclerData() {
|
private fun upRecyclerData() {
|
||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
BookGroup.flowBook(groupId).conflate().map { list ->
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
//排序
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
|
||||||
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
|
||||||
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
|
||||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
|
||||||
// 书籍排序
|
|
||||||
}.conflate().map { list ->
|
|
||||||
when (bookSort) {
|
when (bookSort) {
|
||||||
1 -> list.sortedByDescending { it.latestChapterTime }
|
1 -> list.sortedByDescending { it.latestChapterTime }
|
||||||
2 -> list.sortedWith { o1, o2 ->
|
2 -> list.sortedWith { o1, o2 ->
|
||||||
|
@ -9,11 +9,9 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppConst
|
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookGroup
|
import io.legado.app.data.entities.BookGroup
|
||||||
import io.legado.app.databinding.FragmentBookshelf2Binding
|
import io.legado.app.databinding.FragmentBookshelf2Binding
|
||||||
@ -65,7 +63,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
private var bookGroups: List<BookGroup> = emptyList()
|
private var bookGroups: List<BookGroup> = emptyList()
|
||||||
private var booksFlowJob: Job? = null
|
private var booksFlowJob: Job? = null
|
||||||
override var groupId = AppConst.rootGroupId
|
override var groupId = BookGroup.IdRoot
|
||||||
override var books: List<Book> = emptyList()
|
override var books: List<Book> = emptyList()
|
||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@ -135,23 +133,17 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
BookGroup.flowBook(groupId).conflate().map { list ->
|
||||||
AppConst.rootGroupId -> appDb.bookDao.flowRoot()
|
//排序
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
|
||||||
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
|
||||||
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
|
||||||
AppConst.bookGroupErrorId -> appDb.bookDao.flowUpdateError()
|
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
|
||||||
}.conflate().map { list ->
|
|
||||||
when (AppConfig.getBookSortByGroupId(groupId)) {
|
when (AppConfig.getBookSortByGroupId(groupId)) {
|
||||||
1 -> list.sortedByDescending {
|
1 -> list.sortedByDescending {
|
||||||
it.latestChapterTime
|
it.latestChapterTime
|
||||||
}
|
}
|
||||||
|
|
||||||
2 -> list.sortedWith { o1, o2 ->
|
2 -> list.sortedWith { o1, o2 ->
|
||||||
o1.name.cnCompare(o2.name)
|
o1.name.cnCompare(o2.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
3 -> list.sortedBy {
|
3 -> list.sortedBy {
|
||||||
it.order
|
it.order
|
||||||
}
|
}
|
||||||
@ -229,7 +221,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return if (groupId == AppConst.rootGroupId) {
|
return if (groupId == BookGroup.IdRoot) {
|
||||||
bookGroups.size + books.size
|
bookGroups.size + books.size
|
||||||
} else {
|
} else {
|
||||||
books.size
|
books.size
|
||||||
@ -237,7 +229,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemType(position: Int): Int {
|
override fun getItemType(position: Int): Int {
|
||||||
if (groupId != AppConst.rootGroupId) {
|
if (groupId != BookGroup.IdRoot) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (position < bookGroups.size) {
|
if (position < bookGroups.size) {
|
||||||
@ -247,7 +239,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(position: Int): Any? {
|
override fun getItem(position: Int): Any? {
|
||||||
if (groupId != AppConst.rootGroupId) {
|
if (groupId != BookGroup.IdRoot) {
|
||||||
return books.getOrNull(position)
|
return books.getOrNull(position)
|
||||||
}
|
}
|
||||||
if (position < bookGroups.size) {
|
if (position < bookGroups.size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user