本文整理汇总了TypeScript中tns-core-modules/utils/utils.ad.getApplication方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ad.getApplication方法的具体用法?TypeScript ad.getApplication怎么用?TypeScript ad.getApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tns-core-modules/utils/utils.ad
的用法示例。
在下文中一共展示了ad.getApplication方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPlaceholderImageDrawable
public static getPlaceholderImageDrawable(value) {
let fileName = "",
drawable = null;
if (types.isString(value)) {
value = value.trim();
if (utils.isFileOrResourcePath(value)) {
if (0 === value.indexOf("~/")) {
fileName = fs.path.join(fs.knownFolders.currentApp().path, value.replace("~/", ""));
drawable = android.graphics.drawable.Drawable.createFromPath(fileName);
} else if (0 === value.indexOf("res")) {
fileName = value;
let res = utils.ad.getApplicationContext().getResources();
let resName = fileName.substr(utils.RESOURCE_PREFIX.length);
let identifier = res.getIdentifier(resName, 'drawable', utils.ad.getApplication().getPackageName());
drawable = res.getDrawable(identifier);
}
}
}
return drawable;
}
示例2: setSource
static setSource(image, value) {
image.nativeView.setImageURI(null, null);
if (types.isString(value)) {
value = value.trim();
if (utils.isFileOrResourcePath(value) || 0 === value.indexOf("http")) {
image.isLoading = true;
let fileName = "";
if (0 === value.indexOf("~/")) {
fileName = fs.path.join(fs.knownFolders.currentApp().path, value.replace("~/", ""));
fileName = "file:" + fileName;
} else if (0 === value.indexOf("res")) {
fileName = value;
let res = utils.ad.getApplicationContext().getResources();
let resName = fileName.substr(utils.RESOURCE_PREFIX.length);
let identifier = res.getIdentifier(resName, 'drawable', utils.ad.getApplication().getPackageName());
fileName = "res:/" + identifier;
} else if (0 === value.indexOf("http")) {
image.isLoading = true;
fileName = value;
}
image.nativeView.setImageURI(android.net.Uri.parse(fileName), null);
let controllerListener = new ProxyBaseControllerListener();
controllerListener.setNSCachedImage(image);
let controller = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder()
.setControllerListener(controllerListener)
.setUri(android.net.Uri.parse(fileName))
.build();
image.nativeView.setController(controller);
image.requestLayout();
} else {
throw new Error("Path \"" + "\" is not a valid file or resource.");
}
}
}
示例3:
actions.map((action, i) => {
const intent = new android.content.Intent(application.android.context, application.android.foregroundActivity.getClass());
intent.setAction(SHORTCUT_PREFIX + action.type);
const shortcutBuilder = new android.content.pm.ShortcutInfo.Builder(application.android.context, `id${i}`)
.setShortLabel(action.title)
.setLongLabel(action.title) // TODO add property some day
.setIntent(intent);
if (action.iconTemplate) {
let res = ad.getApplicationContext().getResources();
let identifier = res.getIdentifier(action.iconTemplate, "drawable", ad.getApplication().getPackageName());
if (identifier === 0) {
console.log(`No icon found for this device density for icon '${action.iconTemplate}'. Falling back to the default icon.`);
} else {
shortcutBuilder.setIcon(android.graphics.drawable.Icon.createWithResource(application.android.context, identifier));
}
}
shortcuts.add(shortcutBuilder.build());
});