本文整理匯總了TypeScript中tns-core-modules/image-source.ImageSource.setNativeSource方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ImageSource.setNativeSource方法的具體用法?TypeScript ImageSource.setNativeSource怎麽用?TypeScript ImageSource.setNativeSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tns-core-modules/image-source.ImageSource
的用法示例。
在下文中一共展示了ImageSource.setNativeSource方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const onResult = function(args) {
const requestCode = args.requestCode;
const resultCode = args.resultCode;
const data = args.intent;
// var _that = this;
if (resultCode === android.app.Activity.RESULT_OK && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) {
const resultUri: android.net.Uri = com.yalantis.ucrop.UCrop.getOutput(data);
const is: ImageSource = new ImageSource();
try {
is.setNativeSource(android.graphics.BitmapFactory.decodeFile(resultUri.getPath()));
} catch (e) {
console.error(e);
}
ImageCropper._cleanFiles();
application.android.off(application.AndroidApplication.activityResultEvent, onResult);
if (is.android) {
resolve({
response: "Success",
image: is,
});
} else {
reject({
response: "Error",
image: null
});
}
return;
}
else if (resultCode === android.app.Activity.RESULT_CANCELED && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) {
ImageCropper._cleanFiles();
application.android.off(application.AndroidApplication.activityResultEvent, onResult);
resolve({
response: "Cancelled",
image: null
});
return;
}
else if (resultCode === com.yalantis.ucrop.UCrop.RESULT_ERROR) {
ImageCropper._cleanFiles();
const cropError: java.lang.Throwable = com.yalantis.ucrop.UCrop.getError(data);
console.log(cropError.getMessage());
application.android.off(application.AndroidApplication.activityResultEvent, onResult);
reject({
response: "Error",
image: null
});
return;
}
};