mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fix manga cover download (#1292)
* Fix manga cover not downloaded * Change deprecated intent to MediaScannerConnection.scanFile
This commit is contained in:
parent
da0cd9dd73
commit
181e8f7292
2 changed files with 7 additions and 10 deletions
|
@ -837,7 +837,8 @@ class MangaDetailsPresenter(
|
||||||
File.separator + Environment.DIRECTORY_PICTURES +
|
File.separator + Environment.DIRECTORY_PICTURES +
|
||||||
File.separator + preferences.context.getString(R.string.app_name),
|
File.separator + preferences.context.getString(R.string.app_name),
|
||||||
)
|
)
|
||||||
saveCover(directory)
|
val file = saveCover(directory)
|
||||||
|
DiskUtil.scanMedia(preferences.context, file)
|
||||||
true
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.util.storage
|
package eu.kanade.tachiyomi.util.storage
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.media.MediaScannerConnection
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.os.StatFs
|
import android.os.StatFs
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -69,7 +68,7 @@ object DiskUtil {
|
||||||
val nomedia = dir.findFile(".nomedia")
|
val nomedia = dir.findFile(".nomedia")
|
||||||
if (nomedia == null) {
|
if (nomedia == null) {
|
||||||
dir.createFile(".nomedia")
|
dir.createFile(".nomedia")
|
||||||
context?.let { scanMedia(it, dir.uri) }
|
context?.let { scanMedia(it, dir.filePath) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,17 +77,14 @@ object DiskUtil {
|
||||||
* Scans the given file so that it can be shown in gallery apps, for example.
|
* Scans the given file so that it can be shown in gallery apps, for example.
|
||||||
*/
|
*/
|
||||||
fun scanMedia(context: Context, file: File) {
|
fun scanMedia(context: Context, file: File) {
|
||||||
scanMedia(context, Uri.fromFile(file))
|
scanMedia(context, file.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans the given file so that it can be shown in gallery apps, for example.
|
* Scans the given file so that it can be shown in gallery apps, for example.
|
||||||
*/
|
*/
|
||||||
fun scanMedia(context: Context, uri: Uri) {
|
fun scanMedia(context: Context, filePath: String?) {
|
||||||
val action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE
|
MediaScannerConnection.scanFile(context, arrayOf(filePath), null, null)
|
||||||
val mediaScanIntent = Intent(action)
|
|
||||||
mediaScanIntent.data = uri
|
|
||||||
context.sendBroadcast(mediaScanIntent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue