Skip to content

Commit 51a58dd

Browse files
authored
Merge pull request #73 from lekenny/master
Save the picture to the album to broadcast the album refresh
2 parents 0b06991 + dd394a1 commit 51a58dd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

android/src/main/java/fr/greweb/reactnativeviewshot/RNViewShotModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void takeSnapshot(int tag, ReadableMap options, Promise promise) {
8686
}
8787
}
8888
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));
9090
}
9191
catch (Exception e) {
9292
promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);

android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class ViewShot implements UIBlock {
3737
private String result;
3838
private Promise promise;
3939
private Boolean snapshotContentContainer;
40+
private ReactApplicationContext reactContext;
4041

4142
public ViewShot(
4243
int tag,
@@ -48,6 +49,7 @@ public ViewShot(
4849
File output,
4950
String result,
5051
Boolean snapshotContentContainer,
52+
ReactApplicationContext reactContext,
5153
Promise promise) {
5254
this.tag = tag;
5355
this.extension = extension;
@@ -58,6 +60,7 @@ public ViewShot(
5860
this.output = output;
5961
this.result = result;
6062
this.snapshotContentContainer = snapshotContentContainer;
63+
this.reactContext = reactContext;
6164
this.promise = promise;
6265
}
6366

@@ -74,6 +77,7 @@ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
7477
os = new FileOutputStream(output);
7578
captureView(view, os);
7679
String uri = Uri.fromFile(output).toString();
80+
reactContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(uri)));
7781
promise.resolve(uri);
7882
}
7983
else if ("base64".equals(result)) {

0 commit comments

Comments
 (0)