|
|
@ -121,11 +121,9 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), |
|
|
|
bookGroupLiveData?.removeObservers(this) |
|
|
|
bookGroupLiveData?.removeObservers(this) |
|
|
|
bookGroupLiveData = appDb.bookGroupDao.liveDataShow().apply { |
|
|
|
bookGroupLiveData = appDb.bookGroupDao.liveDataShow().apply { |
|
|
|
observe(viewLifecycleOwner) { |
|
|
|
observe(viewLifecycleOwner) { |
|
|
|
if (it.size != bookGroups.size) { |
|
|
|
if (it != bookGroups) { |
|
|
|
bookGroups = it |
|
|
|
bookGroups = it |
|
|
|
booksAdapter.notifyDataSetChanged() |
|
|
|
booksAdapter.notifyDataSetChanged() |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -183,7 +181,8 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), |
|
|
|
override fun onItemClick(position: Int) { |
|
|
|
override fun onItemClick(position: Int) { |
|
|
|
if (position < bookGroups.size) { |
|
|
|
if (position < bookGroups.size) { |
|
|
|
val bookGroup = bookGroups[position] |
|
|
|
val bookGroup = bookGroups[position] |
|
|
|
|
|
|
|
groupId = bookGroup.groupId |
|
|
|
|
|
|
|
initBooksData() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val book = books[position - bookGroups.size] |
|
|
|
val book = books[position - bookGroups.size] |
|
|
|
when (book.type) { |
|
|
|
when (book.type) { |
|
|
@ -200,6 +199,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), |
|
|
|
|
|
|
|
|
|
|
|
override fun onItemLongClick(position: Int) { |
|
|
|
override fun onItemLongClick(position: Int) { |
|
|
|
if (position < bookGroups.size) { |
|
|
|
if (position < bookGroups.size) { |
|
|
|
|
|
|
|
val bookGroup = bookGroups[position] |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val book = books[position - bookGroups.size] |
|
|
|
val book = books[position - bookGroups.size] |
|
|
|