本文整理汇总了TypeScript中tns-core-modules/utils/utils.isFileOrResourcePath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isFileOrResourcePath函数的具体用法?TypeScript isFileOrResourcePath怎么用?TypeScript isFileOrResourcePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isFileOrResourcePath函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:31,代码来源:helpers.ts
示例2: getPlaceholderUIImage
public static getPlaceholderUIImage(value) {
if (types.isString(value)) {
if (utils.isFileOrResourcePath(value)) {
return imageSource.fromFileOrResource(value).ios;
}
}
return undefined;
}
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:9,代码来源:helpers.ts
示例3: 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.");
}
}
}
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:43,代码来源:helpers.ts
示例4: onSrcPropertySet
public static onSrcPropertySet(nativeWrapper, value) {
let image = nativeWrapper,
placeholder = nativeWrapper.placeholder,
placeholderImage = this.getPlaceholderUIImage(placeholder);
if (types.isString(value)) {
value = value.trim();
if (0 === value.indexOf("http")) {
image.isLoading = true;
image.nativeView.sd_setImageWithURLPlaceholderImageCompleted(value, placeholderImage, function() {
image.isLoading = false;
});
} else if (utils.isFileOrResourcePath(value)) {
image.isLoading = true;
let source: any = new imageSource.ImageSource();
if (0 === value.indexOf(utils.RESOURCE_PREFIX)) {
let path = value.substr(utils.RESOURCE_PREFIX.length);
source.fromResource(path).then(function() {
image.isLoading = false;
image.nativeView.image = source.ios || source.nativeView;
});
} else {
source.fromFile(value).then(function() {
image.isLoading = false;
image.nativeView.image = source.ios || source.nativeView;
});
}
}
image.requestLayout();
}
}
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:36,代码来源:helpers.ts
示例5: isFileOrResourcePath
export function isFileOrResourcePath(path: string): boolean {
return utils.isFileOrResourcePath(path);
}
开发者ID:peoplewareDo,项目名称:nativescript-svg,代码行数:3,代码来源:svg.common.ts
注:本文中的tns-core-modules/utils/utils.isFileOrResourcePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论