mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 23:58:47 +01:00
Convert MediaFileUtils to a non-object
This commit is contained in:
parent
8b66034af5
commit
da843443ef
@ -23,8 +23,8 @@ import android.provider.MediaStore
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.core.content.FileProvider
|
||||
import im.vector.lib.multipicker.entity.MultiPickerImageType
|
||||
import im.vector.lib.multipicker.utils.MediaFileUtils.MediaType.IMAGE
|
||||
import im.vector.lib.multipicker.utils.MediaFileUtils.createTemporaryMediaFile
|
||||
import im.vector.lib.multipicker.utils.MediaType
|
||||
import im.vector.lib.multipicker.utils.createTemporaryMediaFile
|
||||
import im.vector.lib.multipicker.utils.toMultiPickerImageType
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ class CameraPicker {
|
||||
|
||||
companion object {
|
||||
fun createPhotoUri(context: Context): Uri {
|
||||
val file = createTemporaryMediaFile(context, IMAGE)
|
||||
val file = createTemporaryMediaFile(context, MediaType.IMAGE)
|
||||
val authority = context.packageName + ".multipicker.fileprovider"
|
||||
return FileProvider.getUriForFile(context, authority, file)
|
||||
}
|
||||
|
@ -22,24 +22,21 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
object MediaFileUtils {
|
||||
|
||||
fun createTemporaryMediaFile(context: Context, mediaType: MediaType): File {
|
||||
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
||||
val storageDir: File = context.filesDir.also { it.mkdirs() }
|
||||
val fileSuffix = when (mediaType) {
|
||||
MediaType.IMAGE -> ".jpg"
|
||||
MediaType.VIDEO -> ".mp4"
|
||||
}
|
||||
|
||||
return File.createTempFile(
|
||||
"${timeStamp}_",
|
||||
fileSuffix,
|
||||
storageDir
|
||||
)
|
||||
fun createTemporaryMediaFile(context: Context, mediaType: MediaType): File {
|
||||
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
||||
val storageDir: File = context.filesDir.also { it.mkdirs() }
|
||||
val fileSuffix = when (mediaType) {
|
||||
MediaType.IMAGE -> ".jpg"
|
||||
MediaType.VIDEO -> ".mp4"
|
||||
}
|
||||
|
||||
enum class MediaType {
|
||||
IMAGE, VIDEO
|
||||
}
|
||||
return File.createTempFile(
|
||||
"${timeStamp}_",
|
||||
fileSuffix,
|
||||
storageDir
|
||||
)
|
||||
}
|
||||
|
||||
enum class MediaType {
|
||||
IMAGE, VIDEO
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user