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 + preferences.context.getString(R.string.app_name),
|
||||
)
|
||||
saveCover(directory)
|
||||
val file = saveCover(directory)
|
||||
DiskUtil.scanMedia(preferences.context, file)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package eu.kanade.tachiyomi.util.storage
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.media.MediaScannerConnection
|
||||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -69,7 +68,7 @@ object DiskUtil {
|
|||
val nomedia = dir.findFile(".nomedia")
|
||||
if (nomedia == null) {
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
fun scanMedia(context: Context, uri: Uri) {
|
||||
val action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE
|
||||
val mediaScanIntent = Intent(action)
|
||||
mediaScanIntent.data = uri
|
||||
context.sendBroadcast(mediaScanIntent)
|
||||
fun scanMedia(context: Context, filePath: String?) {
|
||||
MediaScannerConnection.scanFile(context, arrayOf(filePath), null, null)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue