build: update gulp-haxetool version

This commit is contained in:
2021-05-28 20:52:13 +03:00
parent e6a11efe64
commit bba9e69fb4
4 changed files with 7793 additions and 328 deletions

View File

@@ -1,41 +1,39 @@
package ru.m.android; package ru.m.android;
import android.app.Activity; import android.app.Activity;
import android.content.res.AssetManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.net.Uri; import android.net.Uri;
import android.util.Log; import android.util.Log;
import org.haxe.extension.Extension; import org.haxe.extension.Extension;
import org.haxe.lime.HaxeObject; import org.haxe.lime.HaxeObject;
import java.io.InputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
public class FileUtil extends Extension { public class FileUtil extends Extension {
final private static int REQUEST_CODE = 123;
private static HaxeObject callback; private static HaxeObject callback;
public static void browse(HaxeObject callback) { public static void browse(HaxeObject callback) {
FileUtil.callback = callback; FileUtil.callback = callback;
Intent intent = new Intent() Intent intent = new Intent()
.setType("*/*") .setType("image/*")
.setAction(Intent.ACTION_GET_CONTENT); .setAction(Intent.ACTION_GET_CONTENT);
Extension.mainActivity.startActivityForResult(Intent.createChooser(intent, "Select a file"), 123); Extension.mainActivity.startActivityForResult(Intent.createChooser(intent, "Select a file"), REQUEST_CODE);
} }
@Override @Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) { public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 123 && resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Uri uri = data.getData(); //The uri with the location of the file Uri uri = data.getData(); //The uri with the location of the file
try { try {
InputStream is = Extension.mainActivity.getContentResolver().openInputStream(uri); InputStream is = Extension.mainActivity.getContentResolver().openInputStream(uri);
byte[] result = getBytes(is); byte[] result = getBytes(is);
callback.call("execute", new Object[]{result}); callback.call("onSuccess", new Object[]{result});
} catch (IOException exception) { } catch (IOException exception) {
Log.e("FileUtil", "", exception); Log.e("FileUtil", "", exception);
callback.call("onFail", new Object[]{exception});
} }
return true; return true;
} else { } else {

8055
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,22 +4,22 @@
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"dateformat": "^3.0.3", "dateformat": "^3.0.3",
"fs-extra": "^10.0.0",
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-add": "0.0.2", "gulp-add": "0.0.2",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-cli": "^2.2.0", "gulp-cli": "^2.2.0",
"gulp-haxetool": "0.1.8", "gulp-haxetool": "^0.1.9",
"yargs": "^13.2.4" "yargs": "^13.2.4"
}, },
"haxeDependencies": { "haxeDependencies": {
"haxework": "git@bitbucket.org:shmyga/haxework.git", "haxework": "git@bitbucket.org:shmyga/haxework.git",
"lime": "7.7.0", "lime": "7.9.0",
"openfl": "8.9.6", "openfl": "9.1.0",
"hxcpp": "4.0.52", "hxcpp": "4.2.1",
"svg": "1.1.3", "svg": "1.1.3",
"protohx": "0.4.6", "protohx": "0.4.6",
"haxe-crypto": "0.0.7" "haxe-crypto": "0.0.7"
}, },
"haxe": "4.1.4", "haxe": "4.2.2"
"dependencies": {}
} }

View File

@@ -1,17 +1,24 @@
package ru.m; package ru.m;
import flash.net.FileFilter; import openfl.net.FileFilter;
import flash.net.FileReference; import openfl.net.FileReference;
import openfl.utils.ByteArray;
class Callback<T> { class Callback<T> {
private var callback:T -> Void; private var success:T -> Void;
private var fail:Dynamic -> Void;
public function new(callback: T -> Void) { public function new(success: T -> Void, fail: Dynamic -> Void) {
this.callback = callback; this.success = success;
this.fail = fail;
} }
public function execute(result:T):Void { public function onSuccess(result:T):Void {
this.callback(result); this.success(result);
}
public function onFail(error:Dynamic):Void {
this.fail(error);
} }
} }
@@ -24,12 +31,19 @@ class ModernFileReference extends FileReference {
); );
#end #end
override function browse(?typeFilter:Array<FileFilter>):Bool { override public function browse(?typeFilter:Array<FileFilter>):Bool {
#if android #if android
fileUtilBrowse(new Callback<haxe.io.BytesData>(function(result:haxe.io.BytesData):Void { fileUtilBrowse(new Callback<haxe.io.BytesData>(
data = result; function(result:haxe.io.BytesData):Void {
data = ByteArray.fromBytesData(result);
dispatchEvent(new flash.events.Event(flash.events.Event.COMPLETE)); dispatchEvent(new flash.events.Event(flash.events.Event.COMPLETE));
})); },
function(error:Dynamic):Void {
dispatchEvent(new flash.events.IOErrorEvent(
flash.events.IOErrorEvent.IO_ERROR, false, false, Std.string(error)
));
}
));
return true; return true;
#else #else
return super.browse(typeFilter); return super.browse(typeFilter);