Skip to content

Commit ce53db1

Browse files
committed
Issue in Navigation Component fragment solved
1 parent e2810eb commit ce53db1

File tree

5 files changed

+477
-53
lines changed

5 files changed

+477
-53
lines changed

EasyMediaPicker/src/main/java/com/bn/easypicker/EasyPicker.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import kotlin.random.Random
2929
class EasyPicker(
3030
builder: Builder,
3131
) : OnAttachmentTypeSelected {
32-
// private lateinit var resultLauncher: ActivityResultLauncher<Intent>
3332

3433
private val request: Int = builder.request
3534
private val mContext: Context = builder.act
@@ -42,12 +41,12 @@ class EasyPicker(
4241
private val btnBackground: Int = builder.btnBackground
4342

4443

45-
46-
private val resultLauncher = act.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
47-
if (result.resultCode == -1) {
48-
chooseImage()
44+
private val resultLauncher =
45+
act.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
46+
if (result.resultCode == -1) {
47+
chooseImage()
48+
}
4949
}
50-
}
5150

5251
private val mSelectImageSheet: SelectAttachmentsTypeSheet by lazy {
5352
SelectAttachmentsTypeSheet(
@@ -88,10 +87,10 @@ class EasyPicker(
8887
}
8988

9089
fun setIconsAndTextColor(
91-
cameraIcon: Int?=null,
92-
galleryIcon: Int?=null,
93-
textColor: Int?=null,
94-
btnBackground:Int?=null
90+
cameraIcon: Int? = null,
91+
galleryIcon: Int? = null,
92+
textColor: Int? = null,
93+
btnBackground: Int? = null
9594
): Builder {
9695
cameraIcon?.let { this.cameraIcon = cameraIcon }
9796
galleryIcon?.let { this.galleryIcon = galleryIcon }
@@ -106,10 +105,12 @@ class EasyPicker(
106105
}
107106

108107
fun build(): EasyPicker {
108+
Log.v("CurrentState", "${act.lifecycle.currentState}")
109109
return EasyPicker(this)
110110
}
111111
}
112112

113+
113114
private lateinit var mPath: Uri
114115

115116
private var imageLauncher =
@@ -278,7 +279,9 @@ class EasyPicker(
278279
uri = imageUri,
279280
path = FilesVersionUtil.getRealPathFromUri(mContext, imageUri)
280281
)
281-
} catch (e: Exception) { Log.e("ExceptionVideo", ">>> Exception Video: ${e.message}") }
282+
} catch (e: Exception) {
283+
Log.e("ExceptionVideo", ">>> Exception Video: ${e.message}")
284+
}
282285
}
283286
}.await()
284287
mListener.onCaptureMedia(request, resulting!!)
@@ -347,7 +350,7 @@ class EasyPicker(
347350
if (intent.resolveActivity(act.packageManager) != null) {
348351
fileLauncher.launch(intent)
349352
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) fileLauncher.launch(intent)
350-
} else PickActions.openStorageRequest(act, resultLauncher)
353+
} else PickActions.openStorageRequest(act, resultLauncher)
351354

352355
}
353356

0 commit comments

Comments
 (0)