Skip to content

Commit

Permalink
Merge pull request #19 from ChochaNaresh/Dev
Browse files Browse the repository at this point in the history
- Android 10 createNewFile throws Exception bug fixed
  • Loading branch information
ChochaNaresh authored Jun 7, 2023
2 parents 9be5300 + ceb23d5 commit 3ba94d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package com.nareshchocha.filepickerlibrary.initializer

import android.content.Context
import androidx.startup.Initializer
import com.nareshchocha.filepickerlibrary.BuildConfig
import timber.log.Timber

class TimberInitializer : Initializer<Unit> {

override fun create(context: Context) {
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Timber.d("TimberInitializer is initialized.")
}
// if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Timber.d("TimberInitializer is initialized.")
// }
}

override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.core.content.FileProvider
import com.nareshchocha.filepickerlibrary.utilities.appConst.Const
import timber.log.Timber
import java.io.File
import java.io.IOException

object PickerUtils {

Expand All @@ -34,7 +35,13 @@ object PickerUtils {

fun Context.createFileGetUri(mFile: File): Uri? {
if (!mFile.exists()) {
mFile.createNewFile()
try {
mFile.createNewFile()
} catch (e: IOException) {
Timber.tag(Const.LogTag.FILE_PICKER_ERROR).d(e.toString())
} catch (e: SecurityException) {
Timber.tag(Const.LogTag.FILE_PICKER_ERROR).d(e.toString())
}
}
return getUriForFile(mFile)
}
Expand Down

0 comments on commit 3ba94d7

Please sign in to comment.