@@ -79,7 +79,6 @@ class EasyPhoto {
79
79
}
80
80
81
81
82
-
83
82
/* *
84
83
* 选择文件
85
84
* 支持图片、音频、视频、联系人以及其它类型文件
@@ -188,7 +187,7 @@ class EasyPhoto {
188
187
buff.append(" (" ).append(MediaStore .Images .ImageColumns .DATA ).append(" =" ).append(" '$path '" ).append(" )" )
189
188
cr.query(MediaStore .Images .Media .EXTERNAL_CONTENT_URI , arrayOf(MediaStore .Images .ImageColumns ._ID ,
190
189
MediaStore .Images .ImageColumns .DATA ), buff.toString(), null , null ).apply {
191
- this ? : throw RuntimeException (" cursor is null" )
190
+ this ? : throw RuntimeException (" cursor is null" )
192
191
var dataIdx: Int
193
192
while (! this .isAfterLast) {
194
193
dataIdx = this .getColumnIndex(MediaStore .Images .ImageColumns .DATA )
@@ -203,7 +202,7 @@ class EasyPhoto {
203
202
" content" -> {
204
203
205
204
context.contentResolver.query(uri, arrayOf(MediaStore .Images .Media .DATA ), null , null , null ).apply {
206
- this ? : throw RuntimeException (" cursor is null" )
205
+ this ? : throw RuntimeException (" cursor is null" )
207
206
if (this .moveToFirst()) {
208
207
val columnIndex = this .getColumnIndexOrThrow(MediaStore .Images .Media .DATA )
209
208
path = this .getString(columnIndex)
@@ -431,8 +430,19 @@ class EasyPhoto {
431
430
*/
432
431
private fun takeFileInternal (takePhotoPath : File , intent : Intent , activity : Activity ) {
433
432
val fragment = PhotoFragment .findOrCreate(activity)
434
- fragment.start(intent, PhotoFragment .REQ_TAKE_FILE ) { requestCode: Int , _ : Intent ? ->
433
+ fragment.start(intent, PhotoFragment .REQ_TAKE_FILE ) { requestCode: Int , data : Intent ? ->
435
434
if (requestCode == PhotoFragment .REQ_TAKE_FILE ) {
435
+ if (data?.data != null ){
436
+ mFilePath = uriToFile(activity,data.data)
437
+ if (isCrop){
438
+ zoomPhoto(takePhotoPath, mFilePath
439
+ ? : File (generateFilePath(activity)), activity)
440
+ }else {
441
+ callback?.invoke(mFilePath!! )
442
+ mFilePath = null
443
+ }
444
+ return @start
445
+ }
436
446
if (isCrop) {
437
447
zoomPhoto(takePhotoPath, mFilePath
438
448
? : File (generateFilePath(activity)), activity)
@@ -554,7 +564,7 @@ class EasyPhoto {
554
564
/**
555
565
* 用于获取图片的Fragment
556
566
*/
557
- class PhotoFragment : Fragment() {
567
+ class PhotoFragment : Fragment() {
558
568
/**
559
569
* Fragment处理照片后返回接口
560
570
*/
@@ -585,7 +595,7 @@ class EasyPhoto {
585
595
const val REQ_TAKE_FILE = 10001
586
596
const val REQ_SELECT_FILE = 10002
587
597
const val REQ_ZOOM_PHOTO = 10003
588
- const val TAG = "EasyPhoto:PhotoFragment"
598
+ private const val TAG = "EasyPhoto:PhotoFragment"
589
599
590
600
@JvmStatic
591
601
fun findOrCreate(activity: Activity): PhotoFragment {
0 commit comments