Browse Source

Merge pull request #73 from lekenny/master

Save the picture to the album to broadcast the album refresh
Gaëtan Renaudeau 7 years ago
parent
commit
51a58ddbf8

+ 1
- 1
android/src/main/java/fr/greweb/reactnativeviewshot/RNViewShotModule.java View File

@@ -86,7 +86,7 @@ public class RNViewShotModule extends ReactContextBaseJavaModule {
86 86
                 }
87 87
             }
88 88
             UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
89
-            uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, file, result, snapshotContentContainer, promise));
89
+            uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, file, result, snapshotContentContainer,reactContext, promise));
90 90
         }
91 91
         catch (Exception e) {
92 92
             promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);

+ 4
- 0
android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java View File

@@ -37,6 +37,7 @@ public class ViewShot implements UIBlock {
37 37
     private String result;
38 38
     private Promise promise;
39 39
     private Boolean snapshotContentContainer;
40
+    private  ReactApplicationContext reactContext;
40 41
 
41 42
     public ViewShot(
42 43
             int tag,
@@ -48,6 +49,7 @@ public class ViewShot implements UIBlock {
48 49
             File output,
49 50
             String result,
50 51
             Boolean snapshotContentContainer,
52
+            ReactApplicationContext reactContext,
51 53
             Promise promise) {
52 54
         this.tag = tag;
53 55
         this.extension = extension;
@@ -58,6 +60,7 @@ public class ViewShot implements UIBlock {
58 60
         this.output = output;
59 61
         this.result = result;
60 62
         this.snapshotContentContainer = snapshotContentContainer;
63
+        this.reactContext = reactContext;
61 64
         this.promise = promise;
62 65
     }
63 66
 
@@ -74,6 +77,7 @@ public class ViewShot implements UIBlock {
74 77
                 os = new FileOutputStream(output);
75 78
                 captureView(view, os);
76 79
                 String uri = Uri.fromFile(output).toString();
80
+                reactContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(uri)));
77 81
                 promise.resolve(uri);
78 82
             }
79 83
             else if ("base64".equals(result)) {