@@ -79,7 +79,6 @@ class EasyPhoto {
7979 }
8080
8181
82-
8382 /* *
8483 * 选择文件
8584 * 支持图片、音频、视频、联系人以及其它类型文件
@@ -188,7 +187,7 @@ class EasyPhoto {
188187 buff.append(" (" ).append(MediaStore .Images .ImageColumns .DATA ).append(" =" ).append(" '$path '" ).append(" )" )
189188 cr.query(MediaStore .Images .Media .EXTERNAL_CONTENT_URI , arrayOf(MediaStore .Images .ImageColumns ._ID ,
190189 MediaStore .Images .ImageColumns .DATA ), buff.toString(), null , null ).apply {
191- this ? : throw RuntimeException (" cursor is null" )
190+ this ? : throw RuntimeException (" cursor is null" )
192191 var dataIdx: Int
193192 while (! this .isAfterLast) {
194193 dataIdx = this .getColumnIndex(MediaStore .Images .ImageColumns .DATA )
@@ -203,7 +202,7 @@ class EasyPhoto {
203202 " content" -> {
204203
205204 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" )
207206 if (this .moveToFirst()) {
208207 val columnIndex = this .getColumnIndexOrThrow(MediaStore .Images .Media .DATA )
209208 path = this .getString(columnIndex)
@@ -431,8 +430,19 @@ class EasyPhoto {
431430 */
432431 private fun takeFileInternal (takePhotoPath : File , intent : Intent , activity : Activity ) {
433432 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 ? ->
435434 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+ }
436446 if (isCrop) {
437447 zoomPhoto(takePhotoPath, mFilePath
438448 ? : File (generateFilePath(activity)), activity)
@@ -554,7 +564,7 @@ class EasyPhoto {
554564 /**
555565 * 用于获取图片的Fragment
556566 */
557- class PhotoFragment : Fragment() {
567+ class PhotoFragment : Fragment() {
558568 /**
559569 * Fragment处理照片后返回接口
560570 */
@@ -585,7 +595,7 @@ class EasyPhoto {
585595 const val REQ_TAKE_FILE = 10001
586596 const val REQ_SELECT_FILE = 10002
587597 const val REQ_ZOOM_PHOTO = 10003
588- const val TAG = "EasyPhoto:PhotoFragment"
598+ private const val TAG = "EasyPhoto:PhotoFragment"
589599
590600 @JvmStatic
591601 fun findOrCreate(activity: Activity): PhotoFragment {
0 commit comments