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
                 }
86
                 }
87
             }
87
             }
88
             UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
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
         catch (Exception e) {
91
         catch (Exception e) {
92
             promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);
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
     private String result;
37
     private String result;
38
     private Promise promise;
38
     private Promise promise;
39
     private Boolean snapshotContentContainer;
39
     private Boolean snapshotContentContainer;
40
+    private  ReactApplicationContext reactContext;
40
 
41
 
41
     public ViewShot(
42
     public ViewShot(
42
             int tag,
43
             int tag,
48
             File output,
49
             File output,
49
             String result,
50
             String result,
50
             Boolean snapshotContentContainer,
51
             Boolean snapshotContentContainer,
52
+            ReactApplicationContext reactContext,
51
             Promise promise) {
53
             Promise promise) {
52
         this.tag = tag;
54
         this.tag = tag;
53
         this.extension = extension;
55
         this.extension = extension;
58
         this.output = output;
60
         this.output = output;
59
         this.result = result;
61
         this.result = result;
60
         this.snapshotContentContainer = snapshotContentContainer;
62
         this.snapshotContentContainer = snapshotContentContainer;
63
+        this.reactContext = reactContext;
61
         this.promise = promise;
64
         this.promise = promise;
62
     }
65
     }
63
 
66
 
74
                 os = new FileOutputStream(output);
77
                 os = new FileOutputStream(output);
75
                 captureView(view, os);
78
                 captureView(view, os);
76
                 String uri = Uri.fromFile(output).toString();
79
                 String uri = Uri.fromFile(output).toString();
80
+                reactContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(uri)));
77
                 promise.resolve(uri);
81
                 promise.resolve(uri);
78
             }
82
             }
79
             else if ("base64".equals(result)) {
83
             else if ("base64".equals(result)) {