File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
vector/src/main/java/im/vector/app/features/voice Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,17 @@ abstract class AbstractVoiceRecorder(
2626 context : Context ,
2727 private val filenameExt : String
2828) : VoiceRecorder {
29- private val outputDirectory = File (context.cacheDir, " voice_records" )
29+ private val outputDirectory: File by lazy {
30+ File (context.cacheDir, " voice_records" ).also {
31+ if (! it.exists()) {
32+ it.mkdirs()
33+ }
34+ }
35+ }
3036
3137 private var mediaRecorder: MediaRecorder ? = null
3238 private var outputFile: File ? = null
3339
34- init {
35- if (! outputDirectory.exists()) {
36- outputDirectory.mkdirs()
37- }
38- }
39-
4040 abstract fun setOutputFormat (mediaRecorder : MediaRecorder )
4141 abstract fun convertFile (recordedFile : File ? ): File ?
4242
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ import javax.inject.Inject
2727class VoicePlayerHelper @Inject constructor(
2828 context : Context
2929) {
30- private val outputDirectory = File (context.cacheDir, " voice_records " )
31-
32- init {
33- if ( ! outputDirectory.exists()) {
34- outputDirectory.mkdirs()
30+ private val outputDirectory: File by lazy {
31+ File (context.cacheDir, " voice_records " ). also {
32+ if ( ! it.exists()) {
33+ it.mkdirs()
34+ }
3535 }
3636 }
3737
You can’t perform that action at this time.
0 commit comments