Fix migration dialog showing on startup even with no manga

This commit is contained in:
NerdNumber9 2017-08-25 22:26:57 -04:00
parent 08dffda2a1
commit bcc2ec1668
3 changed files with 29 additions and 24 deletions

View File

@ -170,7 +170,7 @@ class MainActivity : BaseActivity() {
// Migrate metadata to Realm (EH)
if(!preferences.migrateLibraryAsked2().getOrDefault())
MetadataFetchDialog().askMigration(this)
MetadataFetchDialog().askMigration(this, false)
}
}

View File

@ -137,7 +137,7 @@ class SettingsEhController : SettingsController() {
onClick {
activity?.let {
MetadataFetchDialog().askMigration(it)
MetadataFetchDialog().askMigration(it, true)
}
}
}

View File

@ -83,31 +83,36 @@ class MetadataFetchDialog {
}
}
fun askMigration(activity: Activity) {
fun askMigration(activity: Activity, explicit: Boolean) {
var extra = ""
db.getLibraryMangas().asRxSingle().subscribe {
//Not logged in but have ExHentai galleries
if(!preferenceHelper.enableExhentai().getOrDefault()) {
it.find { isExSource(it.source) }?.let {
extra = "<b><font color='red'>If you use ExHentai, please log in first before fetching your library metadata!</font></b><br><br>"
if(!explicit && it.isEmpty()) {
//Do not open dialog on startup if no manga
preferenceHelper.migrateLibraryAsked2().set(true)
} else {
//Not logged in but have ExHentai galleries
if (!preferenceHelper.enableExhentai().getOrDefault()) {
it.find { isExSource(it.source) }?.let {
extra = "<b><font color='red'>If you use ExHentai, please log in first before fetching your library metadata!</font></b><br><br>"
}
}
activity.runOnUiThread {
MaterialDialog.Builder(activity)
.title("Fetch library metadata")
.content(Html.fromHtml("You need to fetch your library's metadata before tag searching in the library will function.<br><br>" +
"This process may take a long time depending on your library size and will also use up a significant amount of internet bandwidth.<br><br>" +
extra +
"This process can be done later if required."))
.positiveText("Migrate")
.negativeText("Later")
.onPositive { _, _ -> show(activity) }
.onNegative({ _, _ -> adviseMigrationLater(activity) })
.cancelable(false)
.canceledOnTouchOutside(false)
.dismissListener {
preferenceHelper.migrateLibraryAsked2().set(true)
}.show()
}
}
activity.runOnUiThread {
MaterialDialog.Builder(activity)
.title("Fetch library metadata")
.content(Html.fromHtml("You need to fetch your library's metadata before tag searching in the library will function.<br><br>" +
"This process may take a long time depending on your library size and will also use up a significant amount of internet bandwidth.<br><br>" +
extra +
"This process can be done later if required."))
.positiveText("Migrate")
.negativeText("Later")
.onPositive { _, _ -> show(activity) }
.onNegative({ _, _ -> adviseMigrationLater(activity) })
.cancelable(false)
.canceledOnTouchOutside(false)
.dismissListener {
preferenceHelper.migrateLibraryAsked2().set(true)
}.show()
}
}