Skip to content

Commit

Permalink
hide fragment when deck is empty
Browse files Browse the repository at this point in the history
This commit ensure that NoteEditor frame will be hide is the deck is
empty
  • Loading branch information
SanjaySargam committed Aug 29, 2024
1 parent 1469efd commit b650208
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,8 @@ open class CardBrowser :
showBackIcon()
increaseHorizontalPaddingOfOverflowMenuIcons(menu)
}
// Append note editor menu to card browser menu if fragmented
if (fragmented) {
// Append note editor menu to card browser menu if fragmented and deck is not empty
if (fragmented && viewModel.rowCount != 0) {
fragment?.onCreateMenu(menu, menuInflater)
}
actionBarMenu?.findItem(R.id.action_undo)?.run {
Expand Down Expand Up @@ -1670,8 +1670,17 @@ open class CardBrowser :
private fun redrawAfterSearch() {
Timber.i("CardBrowser:: Completed searchCards() Successfully")
updateList()
currentCardId = viewModel.cards[0].id
loadNoteEditorFragmentIfFragmented(editNoteLauncher)
// Check whether deck is empty or not
val isDeckEmpty = viewModel.rowCount == 0
// Hide note editor frame if deck is empty and fragmented
noteEditorFrame?.visibility = if (fragmented && !isDeckEmpty) {
currentCardId = viewModel.cards[0].id
loadNoteEditorFragmentIfFragmented(editNoteLauncher)
View.VISIBLE
} else {
invalidateOptionsMenu()
View.GONE
}
/*check whether mSearchView is initialized as it is lateinit property.*/
if (searchView == null || searchView!!.isIconified) {
restoreScrollPositionIfRequested()
Expand Down

0 comments on commit b650208

Please sign in to comment.