mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
register assetLibraryVersion to native
This commit is contained in:
parent
e9120b0854
commit
c74319cfe0
9 changed files with 25 additions and 9 deletions
|
@ -662,7 +662,8 @@ public class JavaScriptDirectInterface {
|
|||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void registerLibraryAssets(String assets) {
|
||||
public void registerLibraryAssets(int version, String assets) {
|
||||
_activity.assetLibraryVersion = version;
|
||||
_activity.registerLibraryAssets(assets.split(","));
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,8 @@ public class ScratchJrActivity
|
|||
*/
|
||||
private final HashSet<String> assetList = new HashSet<>(200);
|
||||
|
||||
public int assetLibraryVersion = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -208,7 +208,8 @@
|
|||
}
|
||||
|
||||
- (void) registerLibraryAssets: (JsRequest *) request {
|
||||
NSString *assets = request.params[0];
|
||||
ScratchJr.assetLibraryVersion = (NSInteger) request.params[0];
|
||||
NSString *assets = request.params[1];
|
||||
[ScratchJr registerLibraryAssets: [assets componentsSeparatedByString:@","]];
|
||||
[request callback:@"1"];
|
||||
}
|
||||
|
|
|
@ -155,6 +155,8 @@
|
|||
|
||||
@interface ScratchJr : NSObject
|
||||
|
||||
@property (class, nonatomic, assign) NSInteger assetLibraryVersion;
|
||||
|
||||
+ (void)sendBase64Image:(NSData *)imagedata;
|
||||
+ (void)reportImageError;
|
||||
+ (void)cameraInit;
|
||||
|
|
|
@ -14,6 +14,16 @@ AVCaptureVideoPreviewLayer* captureVideoPreviewLayer;
|
|||
|
||||
@implementation ScratchJr : NSObject
|
||||
|
||||
static NSInteger _assetLibraryVersion = 0;
|
||||
|
||||
+ (NSInteger) assetLibraryVersion {
|
||||
return _assetLibraryVersion;
|
||||
}
|
||||
|
||||
+ (void) setAssetLibraryVersion:(NSInteger)newValue {
|
||||
_assetLibraryVersion = newValue;
|
||||
}
|
||||
|
||||
NSString *oncomplete;
|
||||
|
||||
NSMutableSet *assets;
|
||||
|
|
|
@ -43,7 +43,7 @@ window.onload = () => {
|
|||
preprocessAndLoadCss('css', 'css/editor.css');
|
||||
entryFunction = () => OS.waitForInterface(function () {
|
||||
var assets = Object.keys(MediaLib.keys).join(',');
|
||||
OS.registerLibraryAssets(assets, indexMain);
|
||||
OS.registerLibraryAssets(MediaLib.version, assets, indexMain);
|
||||
});
|
||||
break;
|
||||
case 'home':
|
||||
|
|
|
@ -254,8 +254,8 @@ export default class Android {
|
|||
// return 1;
|
||||
// }
|
||||
|
||||
static registerLibraryAssets (assets, fcn) {
|
||||
AndroidInterface.registerLibraryAssets(assets);
|
||||
static registerLibraryAssets (version, assets, fcn) {
|
||||
AndroidInterface.registerLibraryAssets(version, assets);
|
||||
fcn && fcn();
|
||||
}
|
||||
|
||||
|
|
|
@ -247,8 +247,8 @@ export default class OS {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static registerLibraryAssets (assets, fcn) {
|
||||
tabletInterface.registerLibraryAssets(assets, fcn);
|
||||
static registerLibraryAssets (version, assets, fcn) {
|
||||
tabletInterface.registerLibraryAssets(version, assets, fcn);
|
||||
}
|
||||
|
||||
// Name of the device/iPad to display on the sharing dialog page
|
||||
|
|
|
@ -367,9 +367,9 @@ export default class iOS {
|
|||
iOS.call('sendSjrUsingShareDialog', fileName, emailSubject, emailBody, shareType);
|
||||
}
|
||||
|
||||
static registerLibraryAssets (assets, fcn) {
|
||||
static registerLibraryAssets (version, assets, fcn) {
|
||||
(async () => {
|
||||
await iOS.call('registerLibraryAssets', assets);
|
||||
await iOS.call('registerLibraryAssets', version, assets);
|
||||
fcn && fcn();
|
||||
})();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue