Skip to content

Commit

Permalink
Fix NovelDetails / Novel deletion issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gmathi committed Oct 15, 2021
1 parent c1da0cd commit b6c778a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Binary file removed app/src/main/assets/album_arts/13.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class NavDrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelecte
MaterialDialog(this).show {
title(text = "\uD83C\uDF89 What's New ${BuildConfig.VERSION_NAME}!")
message(
text = WhatsChanged.VERSION_20
text = WhatsChanged.VERSION_21
)
positiveButton(text = "Ok")
}
Expand Down Expand Up @@ -221,7 +221,7 @@ class NavDrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelecte
}

private fun setNewImageInNavigationHeaderView() {
val randomNumber = Random(Date().time).nextInt(13) + 1
val randomNumber = Random(Date().time).nextInt(12) + 1 //since we have only 12 images to rotate from.
val uri = Uri.parse("file:///android_asset/album_arts/$randomNumber.png")
Glide.with(this)
.asBitmap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ class NovelDetailsActivity : BaseActivity(), TextViewLinkHandler.OnClickListener
retryCounter = 0
} catch (e: Exception) {
if (e.message?.contains(Exceptions.MISSING_SOURCE_ID) == true) {
toast("Missing Novel Source Id. Please re-add the novel")
contentBinding.progressLayout.showError(errorText = "Missing Novel Source Id.\nPlease re-add the novel.", buttonText = "Delete Novel") {
deleteNovel()
finish()
}
return@launch
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ class LibraryFragment : BaseFragment(), GenericAdapter.Listener<Novel>, SimpleIt
}
}

@SuppressLint("CheckResult")
private fun showNovelSectionsList(novels: ArrayList<Novel>) {
val isMultiNovelUpdate = novels.size > 1
val novelSections = ArrayList(dbHelper.getAllNovelSections())
Expand Down Expand Up @@ -648,7 +649,7 @@ class LibraryFragment : BaseFragment(), GenericAdapter.Listener<Novel>, SimpleIt
R.id.action_novel_remove -> {
confirmDialog(getString(R.string.remove_novels), {
val novels = ArrayList(dataSet)
withSnackBarStatus(novels, "Deleting") { novel ->
withSnackBarStatus(novels, "Deleting", shouldRefetchNovels = true) { novel ->
this@LibraryFragment.deleteNovel(novel)
}
})
Expand All @@ -657,10 +658,9 @@ class LibraryFragment : BaseFragment(), GenericAdapter.Listener<Novel>, SimpleIt
confirmDialog(getString(R.string.reset_novel), {
if (networkHelper.isConnectedToNetwork()) {
val novels = ArrayList(dataSet)
withSnackBarStatus(novels, "Resetting") { novel ->
withSnackBarStatus(novels, "Resetting", shouldRefetchNovels = true) { novel ->
this@LibraryFragment.resetNovel(novel)
}
setData()
} else {
showAlertDialog(message = "You need to be connected to Internet to Hard Reset.")
mode?.finish()
Expand Down Expand Up @@ -777,7 +777,7 @@ class LibraryFragment : BaseFragment(), GenericAdapter.Listener<Novel>, SimpleIt
/**
* Handy actionMode operations functions that wraps around updating the status for action being performed.
*/
private fun withSnackBarStatus(novels: ArrayList<Novel>, action: String = "", operation: suspend (novel: Novel) -> Unit) {
private fun withSnackBarStatus(novels: ArrayList<Novel>, action: String = "", shouldRefetchNovels: Boolean = false, operation: suspend (novel: Novel) -> Unit) {
lifecycleScope.launch(Dispatchers.Main) {
snackBarView(SnackBarStatus.Initialize)
snackBarView(SnackBarStatus.MaxProgress, maxProgress = novels.size)
Expand All @@ -787,6 +787,7 @@ class LibraryFragment : BaseFragment(), GenericAdapter.Listener<Novel>, SimpleIt
withContext(Dispatchers.IO) { operation(novel) }
}
snackBarView(SnackBarStatus.Dismiss)
if (shouldRefetchNovels) setData()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ object WhatsChanged {
"\uD83D\uDEE0️ Other major/minor bug fixes reported on GitHub.\n" +
"❌️ Novel Sync not working => Fix coming next update!!\n"

const val VERSION_21 = "✨️ 0.21 Goodies!\n" +
"✨ TTS - Another Major Update!!\n" +
"✨ Community made art in the drawer menu. (tap to change)\n" +
"✨ Auto Scroll still in works\n" +
"✨ ReaderMenu clean up\n" +
"⚠️️ Fixed - Minor bug fixes\n" +
"⚠️ Fixed - Update extension now works\n" +
"\uD83D\uDEE0️ Other major/minor bug fixes reported on GitHub.\n" +
"❌️ Novel Sync is now accessible, but it will not work.\n"

}

0 comments on commit b6c778a

Please sign in to comment.