mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
lazily creating the voice directory references, avoid eagerly reading the file on the main thread
This commit is contained in:
parent
c2ce10f89c
commit
8525925732
2 changed files with 12 additions and 12 deletions
|
@ -26,17 +26,17 @@ abstract class AbstractVoiceRecorder(
|
|||
context: Context,
|
||||
private val filenameExt: String
|
||||
) : VoiceRecorder {
|
||||
private val outputDirectory = File(context.cacheDir, "voice_records")
|
||||
private val outputDirectory: File by lazy {
|
||||
File(context.cacheDir, "voice_records").also {
|
||||
if (!it.exists()) {
|
||||
it.mkdirs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var mediaRecorder: MediaRecorder? = null
|
||||
private var outputFile: File? = null
|
||||
|
||||
init {
|
||||
if (!outputDirectory.exists()) {
|
||||
outputDirectory.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun setOutputFormat(mediaRecorder: MediaRecorder)
|
||||
abstract fun convertFile(recordedFile: File?): File?
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ import javax.inject.Inject
|
|||
class VoicePlayerHelper @Inject constructor(
|
||||
context: Context
|
||||
) {
|
||||
private val outputDirectory = File(context.cacheDir, "voice_records")
|
||||
|
||||
init {
|
||||
if (!outputDirectory.exists()) {
|
||||
outputDirectory.mkdirs()
|
||||
private val outputDirectory: File by lazy {
|
||||
File(context.cacheDir, "voice_records").also {
|
||||
if (!it.exists()) {
|
||||
it.mkdirs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue