Don't show cloud favorites when not logged in
This commit is contained in:
1 parent
d98292da1d
commit
22b87de29d
6 files changed
+92
-77
No files matched your search
@@ -22,7 +22,6 @@ object Settings : DataStorePreferences(null) {
|
|||||||
val favChangesFlow = _favFlow.debounce(1000)
|
val favChangesFlow = _favFlow.debounce(1000)
|
||||||
var favCat by stringArrayPref("fav_cat", 10, "Favorites").emitTo(_favFlow)
|
var favCat by stringArrayPref("fav_cat", 10, "Favorites").emitTo(_favFlow)
|
||||||
var favCount by intArrayPref("fav_count", 10).emitTo(_favFlow)
|
var favCount by intArrayPref("fav_count", 10).emitTo(_favFlow)
|
||||||
var favLocalCount by intPref("fav_local", 0).emitTo(_favFlow)
|
|
||||||
var favCloudCount by intPref("fav_cloud", 0).emitTo(_favFlow)
|
var favCloudCount by intPref("fav_cloud", 0).emitTo(_favFlow)
|
||||||
|
|
||||||
var downloadScheme by stringOrNullPref("image_scheme", null)
|
var downloadScheme by stringOrNullPref("image_scheme", null)
|
||||||
@@ -66,14 +65,13 @@ object Settings : DataStorePreferences(null) {
|
|||||||
var enableQuic by boolPref("enable_quic", true)
|
var enableQuic by boolPref("enable_quic", true)
|
||||||
var bypassCloudflare by boolPref("bypass_cloudflare", false)
|
var bypassCloudflare by boolPref("bypass_cloudflare", false)
|
||||||
var thumbSizeDp by intPref("thumb_size_", 120)
|
var thumbSizeDp by intPref("thumb_size_", 120)
|
||||||
var recentFavCat by intPref("recent_fav_cat", FavListUrlBuilder.FAV_CAT_ALL)
|
var recentFavCat by intPref("recent_fav_cat", FavListUrlBuilder.FAV_CAT_LOCAL)
|
||||||
var securityDelay by intPref("require_unlock_delay", 0)
|
var securityDelay by intPref("require_unlock_delay", 0)
|
||||||
var clipboardTextHashCode by intPref("clipboard_text_hash_code", 0)
|
var clipboardTextHashCode by intPref("clipboard_text_hash_code", 0)
|
||||||
var listThumbSize by intPref("list_tile_size", 40)
|
var listThumbSize by intPref("list_tile_size", 40)
|
||||||
var searchCategory by intPref("search_pref", EhUtils.ALL_CATEGORY)
|
var searchCategory by intPref("search_pref", EhUtils.ALL_CATEGORY)
|
||||||
var requestNewsTimerHour by intPref("request_news_timer_hour", -1)
|
var requestNewsTimerHour by intPref("request_news_timer_hour", -1)
|
||||||
var requestNewsTimerMinute by intPref("request_news_timer_minute", -1)
|
var requestNewsTimerMinute by intPref("request_news_timer_minute", -1)
|
||||||
var dataMapNextId by intPref("data_map_next_id", 0)
|
|
||||||
var updateIntervalDays by intPref("update_interval_days", 0)
|
var updateIntervalDays by intPref("update_interval_days", 0)
|
||||||
var recentDownloadLabel by stringOrNullPref("recent_download_label", null)
|
var recentDownloadLabel by stringOrNullPref("recent_download_label", null)
|
||||||
var defaultDownloadLabel by stringOrNullPref("default_download_label", null)
|
var defaultDownloadLabel by stringOrNullPref("default_download_label", null)
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ object EhEngine {
|
|||||||
* @param dstCat -1 for delete, 0 - 9 for cloud favorite, others throw Exception
|
* @param dstCat -1 for delete, 0 - 9 for cloud favorite, others throw Exception
|
||||||
* @param note max 250 characters
|
* @param note max 250 characters
|
||||||
*/
|
*/
|
||||||
suspend fun addFavorites(
|
suspend fun modifyFavorites(
|
||||||
gid: Long,
|
gid: Long,
|
||||||
token: String?,
|
token: String?,
|
||||||
dstCat: Int = -1,
|
dstCat: Int = -1,
|
||||||
@@ -519,7 +519,7 @@ object EhEngine {
|
|||||||
if (filter) list.removeAllSuspend { EhFilter.filterUploader(it) || EhFilter.filterTag(it) || EhFilter.filterTagNamespace(it) }
|
if (filter) list.removeAllSuspend { EhFilter.filterUploader(it) || EhFilter.filterTag(it) || EhFilter.filterTagNamespace(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun addFavoritesRange(galleryList: List<Pair<Long, String>>, dstCat: Int) {
|
suspend fun modifyFavoritesRange(galleryList: List<Pair<Long, String>>, dstCat: Int) {
|
||||||
galleryList.forEach { (gid, token) -> addFavorites(gid, token, dstCat) }
|
galleryList.forEach { (gid, token) -> modifyFavorites(gid, token, dstCat) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import com.hippo.ehviewer.EhDB
|
import com.hippo.ehviewer.EhDB
|
||||||
import com.hippo.ehviewer.R
|
import com.hippo.ehviewer.R
|
||||||
import com.hippo.ehviewer.Settings
|
import com.hippo.ehviewer.Settings
|
||||||
|
import com.hippo.ehviewer.client.EhCookieStore
|
||||||
import com.hippo.ehviewer.client.EhEngine
|
import com.hippo.ehviewer.client.EhEngine
|
||||||
import com.hippo.ehviewer.client.EhUtils
|
import com.hippo.ehviewer.client.EhUtils
|
||||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
||||||
@@ -195,31 +196,36 @@ suspend fun keepNoMediaFileStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun DialogState.addToFavorites(galleryInfo: BaseGalleryInfo): Boolean {
|
fun getFavoriteIcon(favorited: Boolean) =
|
||||||
|
if (favorited) Icons.Default.Favorite else Icons.Default.FavoriteBorder
|
||||||
|
|
||||||
|
suspend fun DialogState.modifyFavorites(galleryInfo: BaseGalleryInfo): Boolean {
|
||||||
val localFavorited = EhDB.containLocalFavorites(galleryInfo.gid)
|
val localFavorited = EhDB.containLocalFavorites(galleryInfo.gid)
|
||||||
val localFav = if (localFavorited) {
|
if (EhCookieStore.hasSignedIn()) {
|
||||||
Icons.Default.Favorite
|
val localFav = getFavoriteIcon(localFavorited) to appCtx.getString(R.string.local_favorites)
|
||||||
} else {
|
val cloudFav = Settings.favCat.mapIndexed { index, name ->
|
||||||
Icons.Default.FavoriteBorder
|
getFavoriteIcon(galleryInfo.favoriteSlot == index) to name
|
||||||
} to appCtx.getString(R.string.local_favorites)
|
}.toTypedArray()
|
||||||
val items = Settings.favCat.mapIndexed { index, name ->
|
val isFavorited = galleryInfo.favoriteSlot != NOT_FAVORITED
|
||||||
if (galleryInfo.favoriteSlot == index) {
|
val items = if (isFavorited) {
|
||||||
Icons.Default.Favorite
|
val remove = Icons.Default.HeartBroken to appCtx.getString(R.string.remove_from_favourites)
|
||||||
|
arrayOf(remove, localFav, *cloudFav)
|
||||||
} else {
|
} else {
|
||||||
Icons.Default.FavoriteBorder
|
arrayOf(localFav, *cloudFav)
|
||||||
} to name
|
}
|
||||||
}.toTypedArray()
|
val (slot, note) = showSelectItemWithIconAndTextField(
|
||||||
val isFavorited = galleryInfo.favoriteSlot != NOT_FAVORITED
|
*items,
|
||||||
val (slot, note) = if (isFavorited) {
|
title = R.string.add_favorites_dialog_title,
|
||||||
val remove = Icons.Default.HeartBroken to appCtx.getString(R.string.remove_from_favourites)
|
hint = R.string.favorite_note,
|
||||||
showSelectItemWithIconAndTextField(remove, localFav, *items, title = R.string.add_favorites_dialog_title, hint = R.string.favorite_note, maxChar = MAX_FAVNOTE_CHAR)
|
maxChar = MAX_FAVNOTE_CHAR,
|
||||||
|
)
|
||||||
|
return doModifyFavorites(galleryInfo, if (isFavorited) slot - 2 else slot - 1, note, localFavorited)
|
||||||
} else {
|
} else {
|
||||||
showSelectItemWithIconAndTextField(localFav, *items, title = R.string.add_favorites_dialog_title, hint = R.string.favorite_note, maxChar = MAX_FAVNOTE_CHAR)
|
return doModifyFavorites(galleryInfo, LOCAL_FAVORITED, localFavorited = localFavorited)
|
||||||
}
|
}
|
||||||
return doAddToFavorites(galleryInfo, if (isFavorited) slot - 2 else slot - 1, note, localFavorited)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun doAddToFavorites(
|
private suspend fun doModifyFavorites(
|
||||||
galleryInfo: BaseGalleryInfo,
|
galleryInfo: BaseGalleryInfo,
|
||||||
slot: Int = NOT_FAVORITED,
|
slot: Int = NOT_FAVORITED,
|
||||||
note: String = "",
|
note: String = "",
|
||||||
@@ -228,7 +234,7 @@ private suspend fun doAddToFavorites(
|
|||||||
val add = when (slot) {
|
val add = when (slot) {
|
||||||
NOT_FAVORITED -> { // Remove from cloud favorites first
|
NOT_FAVORITED -> { // Remove from cloud favorites first
|
||||||
if (galleryInfo.favoriteSlot > LOCAL_FAVORITED) {
|
if (galleryInfo.favoriteSlot > LOCAL_FAVORITED) {
|
||||||
EhEngine.addFavorites(galleryInfo.gid, galleryInfo.token)
|
EhEngine.modifyFavorites(galleryInfo.gid, galleryInfo.token)
|
||||||
} else if (localFavorited) {
|
} else if (localFavorited) {
|
||||||
EhDB.removeLocalFavorites(galleryInfo)
|
EhDB.removeLocalFavorites(galleryInfo)
|
||||||
}
|
}
|
||||||
@@ -245,7 +251,7 @@ private suspend fun doAddToFavorites(
|
|||||||
}
|
}
|
||||||
|
|
||||||
in 0..9 -> {
|
in 0..9 -> {
|
||||||
EhEngine.addFavorites(galleryInfo.gid, galleryInfo.token, slot, note)
|
EhEngine.modifyFavorites(galleryInfo.gid, galleryInfo.token, slot, note)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +272,7 @@ private suspend fun doAddToFavorites(
|
|||||||
return add
|
return add
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeFromFavorites(galleryInfo: BaseGalleryInfo) = doAddToFavorites(galleryInfo)
|
suspend fun removeFromFavorites(galleryInfo: BaseGalleryInfo) = doModifyFavorites(galleryInfo)
|
||||||
|
|
||||||
fun Context.navToReader(info: BaseGalleryInfo, page: Int = -1) {
|
fun Context.navToReader(info: BaseGalleryInfo, page: Int = -1) {
|
||||||
val intent = Intent(this, ReaderActivity::class.java)
|
val intent = Intent(this, ReaderActivity::class.java)
|
||||||
@@ -316,7 +322,7 @@ suspend fun DialogState.doGalleryInfoAction(info: BaseGalleryInfo, context: Cont
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
runSuspendCatching {
|
runSuspendCatching {
|
||||||
addToFavorites(info)
|
modifyFavorites(info)
|
||||||
showTip(R.string.add_to_favorite_success, BaseScene.LENGTH_SHORT)
|
showTip(R.string.add_to_favorite_success, BaseScene.LENGTH_SHORT)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
showTip(R.string.add_to_favorite_failure, BaseScene.LENGTH_LONG)
|
showTip(R.string.add_to_favorite_failure, BaseScene.LENGTH_LONG)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|||||||
import com.hippo.ehviewer.EhDB
|
import com.hippo.ehviewer.EhDB
|
||||||
import com.hippo.ehviewer.R
|
import com.hippo.ehviewer.R
|
||||||
import com.hippo.ehviewer.Settings
|
import com.hippo.ehviewer.Settings
|
||||||
|
import com.hippo.ehviewer.client.EhCookieStore
|
||||||
import com.hippo.ehviewer.client.EhEngine
|
import com.hippo.ehviewer.client.EhEngine
|
||||||
import com.hippo.ehviewer.client.EhUrl
|
import com.hippo.ehviewer.client.EhUrl
|
||||||
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
import com.hippo.ehviewer.client.data.BaseGalleryInfo
|
||||||
@@ -271,9 +272,12 @@ class FavoritesScene : SearchBarScene() {
|
|||||||
6 -> {
|
6 -> {
|
||||||
val helper = MoveDialogHelper()
|
val helper = MoveDialogHelper()
|
||||||
// First is local favorite, the other 10 is cloud favorite
|
// First is local favorite, the other 10 is cloud favorite
|
||||||
val array = arrayOfNulls<String>(11)
|
val localFav = getString(R.string.local_favorites)
|
||||||
array[0] = getString(R.string.local_favorites)
|
val array = if (EhCookieStore.hasSignedIn()) {
|
||||||
System.arraycopy(Settings.favCat, 0, array, 1, 10)
|
arrayOf(localFav, *Settings.favCat)
|
||||||
|
} else {
|
||||||
|
arrayOf(localFav)
|
||||||
|
}
|
||||||
BaseDialogBuilder(context).setTitle(R.string.move_favorites_dialog_title).setItems(array, helper).show()
|
BaseDialogBuilder(context).setTitle(R.string.move_favorites_dialog_title).setItems(array, helper).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,11 +418,16 @@ class FavoritesScene : SearchBarScene() {
|
|||||||
scope.invalidate()
|
scope.invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val faves = arrayOf(
|
val localFav = stringResource(id = R.string.local_favorites) to localFavCount
|
||||||
stringResource(id = R.string.local_favorites) to localFavCount,
|
val faves = if (EhCookieStore.hasSignedIn()) {
|
||||||
stringResource(id = R.string.cloud_favorites) to Settings.favCloudCount,
|
arrayOf(
|
||||||
*Settings.favCat.zip(Settings.favCount.toTypedArray()).toTypedArray(),
|
localFav,
|
||||||
)
|
stringResource(id = R.string.cloud_favorites) to Settings.favCloudCount,
|
||||||
|
*Settings.favCat.zip(Settings.favCount.toTypedArray()).toTypedArray(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
arrayOf(localFav)
|
||||||
|
}
|
||||||
LazyColumn {
|
LazyColumn {
|
||||||
itemsIndexed(faves) { index, (name, count) ->
|
itemsIndexed(faves) { index, (name, count) ->
|
||||||
ListItem(
|
ListItem(
|
||||||
@@ -484,7 +493,7 @@ class FavoritesScene : SearchBarScene() {
|
|||||||
EhDB.removeLocalFavorites(info)
|
EhDB.removeLocalFavorites(info)
|
||||||
} else {
|
} else {
|
||||||
val delList = info.map { it.gid to it.token!! }
|
val delList = info.map { it.gid to it.token!! }
|
||||||
EhEngine.addFavoritesRange(delList, -1)
|
EhEngine.modifyFavoritesRange(delList, -1)
|
||||||
}
|
}
|
||||||
mAdapter?.refresh()
|
mAdapter?.refresh()
|
||||||
}
|
}
|
||||||
@@ -503,7 +512,7 @@ class FavoritesScene : SearchBarScene() {
|
|||||||
EhDB.removeLocalFavorites(info)
|
EhDB.removeLocalFavorites(info)
|
||||||
val galleryList = info.map { it.gid to it.token!! }
|
val galleryList = info.map { it.gid to it.token!! }
|
||||||
runCatching {
|
runCatching {
|
||||||
EhEngine.addFavoritesRange(galleryList, dstCat)
|
EhEngine.modifyFavoritesRange(galleryList, dstCat)
|
||||||
}
|
}
|
||||||
} else if (dstCat == FavListUrlBuilder.FAV_CAT_LOCAL) {
|
} else if (dstCat == FavListUrlBuilder.FAV_CAT_LOCAL) {
|
||||||
// Move from cloud to local
|
// Move from cloud to local
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.CloudDone
|
import androidx.compose.material.icons.filled.CloudDone
|
||||||
import androidx.compose.material.icons.filled.Difference
|
import androidx.compose.material.icons.filled.Difference
|
||||||
import androidx.compose.material.icons.filled.Favorite
|
|
||||||
import androidx.compose.material.icons.filled.FavoriteBorder
|
|
||||||
import androidx.compose.material.icons.filled.ImageSearch
|
import androidx.compose.material.icons.filled.ImageSearch
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
import androidx.compose.material.icons.filled.Share
|
import androidx.compose.material.icons.filled.Share
|
||||||
@@ -140,7 +138,7 @@ import com.hippo.ehviewer.spider.SpiderQueen.Companion.MODE_READ
|
|||||||
import com.hippo.ehviewer.ui.CommonOperations
|
import com.hippo.ehviewer.ui.CommonOperations
|
||||||
import com.hippo.ehviewer.ui.GalleryInfoBottomSheet
|
import com.hippo.ehviewer.ui.GalleryInfoBottomSheet
|
||||||
import com.hippo.ehviewer.ui.MainActivity
|
import com.hippo.ehviewer.ui.MainActivity
|
||||||
import com.hippo.ehviewer.ui.addToFavorites
|
import com.hippo.ehviewer.ui.getFavoriteIcon
|
||||||
import com.hippo.ehviewer.ui.legacy.BaseDialogBuilder
|
import com.hippo.ehviewer.ui.legacy.BaseDialogBuilder
|
||||||
import com.hippo.ehviewer.ui.legacy.CheckBoxDialogBuilder
|
import com.hippo.ehviewer.ui.legacy.CheckBoxDialogBuilder
|
||||||
import com.hippo.ehviewer.ui.legacy.CoilImageGetter
|
import com.hippo.ehviewer.ui.legacy.CoilImageGetter
|
||||||
@@ -150,6 +148,7 @@ import com.hippo.ehviewer.ui.main.EhPreviewItem
|
|||||||
import com.hippo.ehviewer.ui.main.GalleryDetailErrorTip
|
import com.hippo.ehviewer.ui.main.GalleryDetailErrorTip
|
||||||
import com.hippo.ehviewer.ui.main.GalleryDetailHeaderCard
|
import com.hippo.ehviewer.ui.main.GalleryDetailHeaderCard
|
||||||
import com.hippo.ehviewer.ui.main.GalleryTags
|
import com.hippo.ehviewer.ui.main.GalleryTags
|
||||||
|
import com.hippo.ehviewer.ui.modifyFavorites
|
||||||
import com.hippo.ehviewer.ui.navToReader
|
import com.hippo.ehviewer.ui.navToReader
|
||||||
import com.hippo.ehviewer.ui.openBrowser
|
import com.hippo.ehviewer.ui.openBrowser
|
||||||
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
|
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
|
||||||
@@ -694,7 +693,7 @@ class GalleryDetailScene : BaseScene() {
|
|||||||
onCheckedChange = { modifyFavourite() },
|
onCheckedChange = { modifyFavourite() },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if (favored) Icons.Default.Favorite else Icons.Default.FavoriteBorder,
|
imageVector = getFavoriteIcon(favored),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -875,7 +874,7 @@ class GalleryDetailScene : BaseScene() {
|
|||||||
favoritesLock.withLock {
|
favoritesLock.withLock {
|
||||||
var remove = false
|
var remove = false
|
||||||
runCatching {
|
runCatching {
|
||||||
remove = !dialogState.addToFavorites(galleryDetail.galleryInfo)
|
remove = !dialogState.modifyFavorites(galleryDetail.galleryInfo)
|
||||||
if (remove) {
|
if (remove) {
|
||||||
showTip(R.string.remove_from_favorite_success, LENGTH_SHORT)
|
showTip(R.string.remove_from_favorite_success, LENGTH_SHORT)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.hippo.ehviewer.BuildConfig
|
|||||||
import com.hippo.ehviewer.EhDB
|
import com.hippo.ehviewer.EhDB
|
||||||
import com.hippo.ehviewer.R
|
import com.hippo.ehviewer.R
|
||||||
import com.hippo.ehviewer.Settings
|
import com.hippo.ehviewer.Settings
|
||||||
|
import com.hippo.ehviewer.client.EhCookieStore
|
||||||
import com.hippo.ehviewer.client.EhEngine
|
import com.hippo.ehviewer.client.EhEngine
|
||||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder
|
import com.hippo.ehviewer.client.data.FavListUrlBuilder
|
||||||
import com.hippo.ehviewer.ui.LocalNavController
|
import com.hippo.ehviewer.ui.LocalNavController
|
||||||
@@ -176,41 +177,43 @@ fun AdvancedScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val backupNothing = stringResource(id = R.string.settings_advanced_backup_favorite_nothing)
|
if (EhCookieStore.hasSignedIn()) {
|
||||||
val backupFailed = stringResource(id = R.string.settings_advanced_backup_favorite_failed)
|
val backupNothing = stringResource(id = R.string.settings_advanced_backup_favorite_nothing)
|
||||||
val backupSucceed = stringResource(id = R.string.settings_advanced_backup_favorite_success)
|
val backupFailed = stringResource(id = R.string.settings_advanced_backup_favorite_failed)
|
||||||
Preference(
|
val backupSucceed = stringResource(id = R.string.settings_advanced_backup_favorite_success)
|
||||||
title = stringResource(id = R.string.settings_advanced_backup_favorite),
|
Preference(
|
||||||
summary = stringResource(id = R.string.settings_advanced_backup_favorite_summary),
|
title = stringResource(id = R.string.settings_advanced_backup_favorite),
|
||||||
) {
|
summary = stringResource(id = R.string.settings_advanced_backup_favorite_summary),
|
||||||
val favListUrlBuilder = FavListUrlBuilder()
|
) {
|
||||||
var favTotal = 0
|
val favListUrlBuilder = FavListUrlBuilder()
|
||||||
var favIndex = 0
|
var favTotal = 0
|
||||||
tailrec suspend fun doBackup() {
|
var favIndex = 0
|
||||||
val result = EhEngine.getFavorites(favListUrlBuilder.build())
|
tailrec suspend fun doBackup() {
|
||||||
if (result.galleryInfoList.isEmpty()) {
|
val result = EhEngine.getFavorites(favListUrlBuilder.build())
|
||||||
launchSnackBar(backupNothing)
|
if (result.galleryInfoList.isEmpty()) {
|
||||||
} else {
|
launchSnackBar(backupNothing)
|
||||||
if (favTotal == 0) favTotal = result.countArray.sum()
|
} else {
|
||||||
favIndex += result.galleryInfoList.size
|
if (favTotal == 0) favTotal = result.countArray.sum()
|
||||||
val status = "($favIndex/$favTotal)"
|
favIndex += result.galleryInfoList.size
|
||||||
EhDB.putLocalFavorites(result.galleryInfoList)
|
val status = "($favIndex/$favTotal)"
|
||||||
launchSnackBar(context.getString(R.string.settings_advanced_backup_favorite_start, status))
|
EhDB.putLocalFavorites(result.galleryInfoList)
|
||||||
if (result.next != null) {
|
launchSnackBar(context.getString(R.string.settings_advanced_backup_favorite_start, status))
|
||||||
delay(Settings.downloadDelay.toLong())
|
if (result.next != null) {
|
||||||
favListUrlBuilder.setIndex(result.next, true)
|
delay(Settings.downloadDelay.toLong())
|
||||||
doBackup()
|
favListUrlBuilder.setIndex(result.next, true)
|
||||||
|
doBackup()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
coroutineScope.launch {
|
||||||
coroutineScope.launch {
|
runSuspendCatching {
|
||||||
runSuspendCatching {
|
doBackup()
|
||||||
doBackup()
|
}.onSuccess {
|
||||||
}.onSuccess {
|
launchSnackBar(backupSucceed)
|
||||||
launchSnackBar(backupSucceed)
|
}.onFailure {
|
||||||
}.onFailure {
|
it.printStackTrace()
|
||||||
it.printStackTrace()
|
launchSnackBar(backupFailed)
|
||||||
launchSnackBar(backupFailed)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user