pull/1215/head
deniscerri 1 month ago
parent c7ead2479b
commit 3e839e0819
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -321,9 +321,13 @@ object FolderSettingsModule: SettingModule {
}
clearCacheFolder(File(FileUtil.getCachePath(context)))
Snackbar.make(host.hostView!!, context.getString(R.string.cache_cleared), Snackbar.LENGTH_SHORT).show()
if (host.hostView != null && host.hostView!!.isAttachedToWindow) {
Snackbar.make(host.hostView!!, context.getString(R.string.cache_cleared), Snackbar.LENGTH_SHORT).show()
}
}else{
Snackbar.make(host.hostView!!, context.getString(R.string.downloads_running_try_later), Snackbar.LENGTH_SHORT).show()
if (host.hostView != null && host.hostView!!.isAttachedToWindow) {
Snackbar.make(host.hostView!!, context.getString(R.string.downloads_running_try_later), Snackbar.LENGTH_SHORT).show()
}
}
val cacheSize = File(FileUtil.getCachePath(context)).walkBottomUp().fold(0L) { acc, file -> acc + file.length() }

@ -104,8 +104,8 @@ object UpdateSettingsModule : SettingModule {
updateUtil.tryGetNewVersion()
}
if (res.isFailure) {
host.hostView?.apply {
Snackbar.make(this, res.exceptionOrNull()?.message ?: context.getString(R.string.network_error), Snackbar.LENGTH_LONG).show()
if (host.hostView != null && host.hostView!!.isAttachedToWindow) {
Snackbar.make(host.hostView!!, res.exceptionOrNull()?.message ?: context.getString(R.string.network_error), Snackbar.LENGTH_LONG).show()
}
}else{
if (preferences.getBoolean("automatic_backup", false)) {
@ -165,7 +165,7 @@ object UpdateSettingsModule : SettingModule {
) = host.hostLifecycleOwner.lifecycleScope.launch {
val view = host.hostView
view?.apply {
if (view != null && view.isAttachedToWindow) {
Snackbar.make(view, context.getString(R.string.ytdl_updating_started), Snackbar.LENGTH_LONG).show()
}
@ -173,7 +173,7 @@ object UpdateSettingsModule : SettingModule {
val res = updateUtil.updateYTDL(channel)
when (res.status) {
UpdateUtil.YTDLPUpdateStatus.DONE -> {
view?.apply {
if (view != null && view.isAttachedToWindow) {
Snackbar.make(view, res.message, Snackbar.LENGTH_LONG).show()
}
@ -182,7 +182,7 @@ object UpdateSettingsModule : SettingModule {
File(infoJsonPath).deleteRecursively()
}
UpdateUtil.YTDLPUpdateStatus.ALREADY_UP_TO_DATE -> {
view?.apply {
if (view != null && view.isAttachedToWindow) {
Snackbar.make(view,
context.getString(R.string.you_are_in_latest_version),
Snackbar.LENGTH_LONG).show()
@ -190,8 +190,8 @@ object UpdateSettingsModule : SettingModule {
}
UpdateUtil.YTDLPUpdateStatus.ERROR -> {
val msg = res.message
view?.apply {
val snackBar = Snackbar.make(this, msg, Snackbar.LENGTH_LONG)
if (view != null && view.isAttachedToWindow) {
val snackBar = Snackbar.make(view, msg, Snackbar.LENGTH_LONG)
snackBar.setAction(R.string.copy_log){
UiUtil.copyToClipboard(msg, host.getHostContext())
}
@ -207,8 +207,8 @@ object UpdateSettingsModule : SettingModule {
}
}.onFailure {
val msg = it.message ?: context.getString(R.string.errored)
view?.apply {
val snackBar = Snackbar.make(this, msg, Snackbar.LENGTH_LONG)
if (view != null && view.isAttachedToWindow) {
val snackBar = Snackbar.make(view, msg, Snackbar.LENGTH_LONG)
snackBar.setAction(R.string.copy_log){
UiUtil.copyToClipboard(msg, host.getHostContext())
}
@ -217,7 +217,6 @@ object UpdateSettingsModule : SettingModule {
snackTextView.maxLines = 9999999
snackBar.show()
}
}
}
}
Loading…
Cancel
Save