build: update gulp-haxetool version
This commit is contained in:
@@ -1,41 +1,39 @@
|
||||
package ru.m.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import org.haxe.extension.Extension;
|
||||
import org.haxe.lime.HaxeObject;
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class FileUtil extends Extension {
|
||||
final private static int REQUEST_CODE = 123;
|
||||
private static HaxeObject callback;
|
||||
|
||||
public static void browse(HaxeObject callback) {
|
||||
FileUtil.callback = callback;
|
||||
Intent intent = new Intent()
|
||||
.setType("*/*")
|
||||
.setType("image/*")
|
||||
.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
|
||||
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
|
||||
try {
|
||||
InputStream is = Extension.mainActivity.getContentResolver().openInputStream(uri);
|
||||
byte[] result = getBytes(is);
|
||||
callback.call("execute", new Object[]{result});
|
||||
callback.call("onSuccess", new Object[]{result});
|
||||
} catch (IOException exception) {
|
||||
Log.e("FileUtil", "", exception);
|
||||
callback.call("onFail", new Object[]{exception});
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
||||
8055
package-lock.json
generated
8055
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -4,22 +4,22 @@
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"dateformat": "^3.0.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-add": "0.0.2",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-cli": "^2.2.0",
|
||||
"gulp-haxetool": "0.1.8",
|
||||
"gulp-haxetool": "^0.1.9",
|
||||
"yargs": "^13.2.4"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
||||
"lime": "7.7.0",
|
||||
"openfl": "8.9.6",
|
||||
"hxcpp": "4.0.52",
|
||||
"lime": "7.9.0",
|
||||
"openfl": "9.1.0",
|
||||
"hxcpp": "4.2.1",
|
||||
"svg": "1.1.3",
|
||||
"protohx": "0.4.6",
|
||||
"haxe-crypto": "0.0.7"
|
||||
},
|
||||
"haxe": "4.1.4",
|
||||
"dependencies": {}
|
||||
"haxe": "4.2.2"
|
||||
}
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package ru.m;
|
||||
|
||||
import flash.net.FileFilter;
|
||||
import flash.net.FileReference;
|
||||
import openfl.net.FileFilter;
|
||||
import openfl.net.FileReference;
|
||||
import openfl.utils.ByteArray;
|
||||
|
||||
class Callback<T> {
|
||||
private var callback:T -> Void;
|
||||
private var success:T -> Void;
|
||||
private var fail:Dynamic -> Void;
|
||||
|
||||
public function new(callback: T -> Void) {
|
||||
this.callback = callback;
|
||||
public function new(success: T -> Void, fail: Dynamic -> Void) {
|
||||
this.success = success;
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
public function execute(result:T):Void {
|
||||
this.callback(result);
|
||||
public function onSuccess(result:T):Void {
|
||||
this.success(result);
|
||||
}
|
||||
|
||||
public function onFail(error:Dynamic):Void {
|
||||
this.fail(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +31,19 @@ class ModernFileReference extends FileReference {
|
||||
);
|
||||
#end
|
||||
|
||||
override function browse(?typeFilter:Array<FileFilter>):Bool {
|
||||
override public function browse(?typeFilter:Array<FileFilter>):Bool {
|
||||
#if android
|
||||
fileUtilBrowse(new Callback<haxe.io.BytesData>(function(result:haxe.io.BytesData):Void {
|
||||
data = result;
|
||||
fileUtilBrowse(new Callback<haxe.io.BytesData>(
|
||||
function(result:haxe.io.BytesData):Void {
|
||||
data = ByteArray.fromBytesData(result);
|
||||
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;
|
||||
#else
|
||||
return super.browse(typeFilter);
|
||||
|
||||
Reference in New Issue
Block a user