All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.sceyt.chatuikit.extensions.ActivityResultLauncherExtensions.kt Maven / Gradle / Ivy

package com.sceyt.chatuikit.extensions

import android.content.Intent
import android.net.Uri
import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment

fun ComponentActivity.initPermissionLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.RequestPermission(), callback)
}

fun Fragment.initPermissionLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.RequestPermission(), callback)
}

fun ComponentActivity.initCameraLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.TakePicture(), callback)
}

fun ComponentActivity.initVideoCameraLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.CaptureVideo(), callback)
}

fun Fragment.initCameraLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.TakePicture(), callback)
}

fun Fragment.initVideoCameraLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.CaptureVideo(), callback)
}

fun ComponentActivity.initAttachmentLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.StartActivityForResult(), callback)
}

fun Fragment.initAttachmentLauncher(callback: ActivityResultCallback): ActivityResultLauncher {
    return registerForActivityResult(ActivityResultContracts.StartActivityForResult(), callback)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy