register assetLibraryVersion to native

This commit is contained in:
Yueyu 2021-10-09 19:25:14 +08:00
parent e9120b0854
commit c74319cfe0
9 changed files with 25 additions and 9 deletions

View file

@ -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(","));
}

View file

@ -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);

View file

@ -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"];
}

View file

@ -155,6 +155,8 @@
@interface ScratchJr : NSObject
@property (class, nonatomic, assign) NSInteger assetLibraryVersion;
+ (void)sendBase64Image:(NSData *)imagedata;
+ (void)reportImageError;
+ (void)cameraInit;

View file

@ -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;

View file

@ -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':

View file

@ -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();
}

View file

@ -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

View file

@ -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();
})();
}