Bläddra i källkod

fix: other two functions

pu 4 år sedan
förälder
incheckning
a7d9ec460f
1 ändrade filer med 14 tillägg och 8 borttagningar
  1. 14
    8
      android/src/main/java/com/reactlibrary/AliyunUploadManager.java

+ 14
- 8
android/src/main/java/com/reactlibrary/AliyunUploadManager.java Visa fil

@@ -80,10 +80,13 @@ public class AliyunUploadManager {
80 80
         try {
81 81
             String[] proj = {MediaStore.Images.Media.DATA};
82 82
             cursor = context.getCurrentActivity().getContentResolver().query(selectedVideoUri, proj, null, null, null);
83
-            if (cursor == null) sourceFile = selectedVideoUri.getPath();
84
-            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
85
-            cursor.moveToFirst();
86
-            sourceFile = cursor.getString(column_index);
83
+            if (cursor == null) {
84
+                sourceFile = selectedVideoUri.getPath();
85
+            } else {
86
+                int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
87
+                cursor.moveToFirst();
88
+                sourceFile = cursor.getString(column_index);
89
+            }
87 90
         } catch (Exception e) {
88 91
             sourceFile = FileUtils.getFilePathFromURI(context.getCurrentActivity(), selectedVideoUri);
89 92
         } finally {
@@ -287,10 +290,13 @@ public class AliyunUploadManager {
287 290
         try {
288 291
             String[] proj = {MediaStore.Images.Media.DATA};
289 292
             cursor = context.getCurrentActivity().getContentResolver().query(selectedVideoUri, proj, null, null, null);
290
-            if (cursor == null) filepath = selectedVideoUri.getPath();
291
-            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
292
-            cursor.moveToFirst();
293
-            filepath = cursor.getString(column_index);
293
+            if (cursor == null) {
294
+                filepath = selectedVideoUri.getPath();
295
+            } else {
296
+                int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
297
+                cursor.moveToFirst();
298
+                filepath = cursor.getString(column_index);
299
+            }
294 300
         } catch (Exception e) {
295 301
             filepath = FileUtils.getFilePathFromURI(context.getCurrentActivity(), selectedVideoUri);
296 302
         } finally {