mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: working android build
This commit is contained in:
@@ -9,111 +9,111 @@ if (global.__snapshot) {
|
||||
/**
|
||||
* Option 1: the exact es5 compiled version of what this normally looks like
|
||||
*/
|
||||
var NativeScriptActivity = (function (_super) {
|
||||
__extends(NativeScriptActivity, _super);
|
||||
function NativeScriptActivity() {
|
||||
console.log('construct NativeScriptActivity');
|
||||
var _this = _super.call(this) || this;
|
||||
return global.__native(_this);
|
||||
}
|
||||
NativeScriptActivity.prototype.init = function () {
|
||||
// return new NativeScriptActivity();
|
||||
};
|
||||
NativeScriptActivity.prototype.onCreate = function (savedInstanceState) {
|
||||
appModule.android.init(this.getApplication());
|
||||
this.isNativeScriptActivity = true;
|
||||
if (!this._callbacks) {
|
||||
setActivityCallbacks(this);
|
||||
}
|
||||
this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), _super.prototype.onCreate);
|
||||
};
|
||||
NativeScriptActivity.prototype.onNewIntent = function (intent) {
|
||||
this._callbacks.onNewIntent(this, intent, _super.prototype.setIntent, _super.prototype.onNewIntent);
|
||||
};
|
||||
NativeScriptActivity.prototype.onSaveInstanceState = function (outState) {
|
||||
this._callbacks.onSaveInstanceState(this, outState, _super.prototype.onSaveInstanceState);
|
||||
};
|
||||
NativeScriptActivity.prototype.onStart = function () {
|
||||
this._callbacks.onStart(this, _super.prototype.onStart);
|
||||
};
|
||||
NativeScriptActivity.prototype.onStop = function () {
|
||||
this._callbacks.onStop(this, _super.prototype.onStop);
|
||||
};
|
||||
NativeScriptActivity.prototype.onDestroy = function () {
|
||||
this._callbacks.onDestroy(this, _super.prototype.onDestroy);
|
||||
};
|
||||
NativeScriptActivity.prototype.onPostResume = function () {
|
||||
this._callbacks.onPostResume(this, _super.prototype.onPostResume);
|
||||
};
|
||||
NativeScriptActivity.prototype.onBackPressed = function () {
|
||||
this._callbacks.onBackPressed(this, _super.prototype.onBackPressed);
|
||||
};
|
||||
NativeScriptActivity.prototype.onRequestPermissionsResult = function (requestCode, permissions, grantResults) {
|
||||
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined);
|
||||
};
|
||||
NativeScriptActivity.prototype.onActivityResult = function (requestCode, resultCode, data) {
|
||||
this._callbacks.onActivityResult(this, requestCode, resultCode, data, _super.prototype.onActivityResult);
|
||||
};
|
||||
NativeScriptActivity = __decorate([JavaProxy('com.tns.NativeScriptActivity')], NativeScriptActivity);
|
||||
return NativeScriptActivity;
|
||||
})(androidx.appcompat.app.AppCompatActivity);
|
||||
|
||||
// Option 2: the manual es5 way - results in same as above
|
||||
// const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
|
||||
// const NativeScriptActivity = (<any>androidx.appcompat.app.AppCompatActivity).extend('com.tns.NativeScriptActivity', {
|
||||
// init() {
|
||||
// // superProto();
|
||||
// // return global.__native(this);
|
||||
// },
|
||||
// onCreate(savedInstanceState: android.os.Bundle): void {
|
||||
// appModule.android.init(this.getApplication());
|
||||
|
||||
// // Set isNativeScriptActivity in onCreate.
|
||||
// // The JS constructor might not be called because the activity is created from Android.
|
||||
// var NativeScriptActivity = (function (_super) {
|
||||
// __extends(NativeScriptActivity, _super);
|
||||
// function NativeScriptActivity() {
|
||||
// console.log('construct NativeScriptActivity');
|
||||
// var _this = _super.call(this) || this;
|
||||
// return global.__native(_this);
|
||||
// }
|
||||
// NativeScriptActivity.prototype.init = function () {
|
||||
// // return new NativeScriptActivity();
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onCreate = function (savedInstanceState) {
|
||||
// appModule.android.init(this.getApplication());
|
||||
// this.isNativeScriptActivity = true;
|
||||
// if (!this._callbacks) {
|
||||
// setActivityCallbacks(this);
|
||||
// }
|
||||
// this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), _super.prototype.onCreate);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onNewIntent = function (intent) {
|
||||
// this._callbacks.onNewIntent(this, intent, _super.prototype.setIntent, _super.prototype.onNewIntent);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onSaveInstanceState = function (outState) {
|
||||
// this._callbacks.onSaveInstanceState(this, outState, _super.prototype.onSaveInstanceState);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onStart = function () {
|
||||
// this._callbacks.onStart(this, _super.prototype.onStart);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onStop = function () {
|
||||
// this._callbacks.onStop(this, _super.prototype.onStop);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onDestroy = function () {
|
||||
// this._callbacks.onDestroy(this, _super.prototype.onDestroy);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onPostResume = function () {
|
||||
// this._callbacks.onPostResume(this, _super.prototype.onPostResume);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onBackPressed = function () {
|
||||
// this._callbacks.onBackPressed(this, _super.prototype.onBackPressed);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onRequestPermissionsResult = function (requestCode, permissions, grantResults) {
|
||||
// this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined);
|
||||
// };
|
||||
// NativeScriptActivity.prototype.onActivityResult = function (requestCode, resultCode, data) {
|
||||
// this._callbacks.onActivityResult(this, requestCode, resultCode, data, _super.prototype.onActivityResult);
|
||||
// };
|
||||
// NativeScriptActivity = __decorate([JavaProxy('com.tns.NativeScriptActivity')], NativeScriptActivity);
|
||||
// return NativeScriptActivity;
|
||||
// })(androidx.appcompat.app.AppCompatActivity);
|
||||
|
||||
// this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
|
||||
// },
|
||||
// Option 2: the manual es5 way - results in same as above
|
||||
const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
|
||||
const NativeScriptActivity = (<any>androidx.appcompat.app.AppCompatActivity).extend('com.tns.NativeScriptActivity', {
|
||||
init() {
|
||||
// superProto();
|
||||
// return global.__native(this);
|
||||
},
|
||||
onCreate(savedInstanceState: android.os.Bundle): void {
|
||||
appModule.android.init(this.getApplication());
|
||||
|
||||
// onNewIntent(intent: android.content.Intent): void {
|
||||
// this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent);
|
||||
// },
|
||||
// Set isNativeScriptActivity in onCreate.
|
||||
// The JS constructor might not be called because the activity is created from Android.
|
||||
this.isNativeScriptActivity = true;
|
||||
if (!this._callbacks) {
|
||||
setActivityCallbacks(this);
|
||||
}
|
||||
|
||||
// onSaveInstanceState(outState: android.os.Bundle): void {
|
||||
// this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState);
|
||||
// },
|
||||
this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
|
||||
},
|
||||
|
||||
// onStart(): void {
|
||||
// this._callbacks.onStart(this, superProto.onStart);
|
||||
// },
|
||||
onNewIntent(intent: android.content.Intent): void {
|
||||
this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent);
|
||||
},
|
||||
|
||||
// onStop(): void {
|
||||
// this._callbacks.onStop(this, superProto.onStop);
|
||||
// },
|
||||
onSaveInstanceState(outState: android.os.Bundle): void {
|
||||
this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState);
|
||||
},
|
||||
|
||||
// onDestroy(): void {
|
||||
// this._callbacks.onDestroy(this, superProto.onDestroy);
|
||||
// },
|
||||
onStart(): void {
|
||||
this._callbacks.onStart(this, superProto.onStart);
|
||||
},
|
||||
|
||||
// onPostResume(): void {
|
||||
// this._callbacks.onPostResume(this, superProto.onPostResume);
|
||||
// },
|
||||
onStop(): void {
|
||||
this._callbacks.onStop(this, superProto.onStop);
|
||||
},
|
||||
|
||||
// onBackPressed(): void {
|
||||
// this._callbacks.onBackPressed(this, superProto.onBackPressed);
|
||||
// },
|
||||
onDestroy(): void {
|
||||
this._callbacks.onDestroy(this, superProto.onDestroy);
|
||||
},
|
||||
|
||||
// onRequestPermissionsResult(requestCode: number, permissions: Array<string>, grantResults: Array<number>): void {
|
||||
// this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
|
||||
// },
|
||||
onPostResume(): void {
|
||||
this._callbacks.onPostResume(this, superProto.onPostResume);
|
||||
},
|
||||
|
||||
// onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
|
||||
// this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult);
|
||||
// },
|
||||
// });
|
||||
onBackPressed(): void {
|
||||
this._callbacks.onBackPressed(this, superProto.onBackPressed);
|
||||
},
|
||||
|
||||
onRequestPermissionsResult(requestCode: number, permissions: Array<string>, grantResults: Array<number>): void {
|
||||
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
|
||||
},
|
||||
|
||||
onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
|
||||
this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult);
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Option 3: The way which worked when using es5 compile target however when targeting es2017, this source code won't work due to the extends from native class so trying options 1 and 2 to achieve same
|
||||
|
||||
Reference in New Issue
Block a user