本文整理汇总了TypeScript中tns-core-modules/utils/types.isString函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isString函数的具体用法?TypeScript isString怎么用?TypeScript isString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isString函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetch
fetch("https://httpbin.org/get").then(response => response.text()).then(function (r) {
// Argument (r) is string!
// >> (hide)
TKUnit.assert(types.isString(r), "Result from text() should be string! Actual result is: " + r);
done(null);
// << (hide)
}).catch(failOnError(done));
示例2: 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;
}
示例3: getPlaceholderUIImage
public static getPlaceholderUIImage(value) {
if (types.isString(value)) {
if (utils.isFileOrResourcePath(value)) {
return imageSource.fromFileOrResource(value).ios;
}
}
return undefined;
}
示例4:
var imageLoaded = () => {
let currentValue = this.src;
if (!types.isString(this.src) || value !== currentValue.trim()) {
return;
}
this.imageSource = source;
// imageSourceProperty.nativeValueChange(this, source);
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
示例5: boolParse
export function boolParse(value: any) {
if (types.isString(value)) {
switch (value.toLowerCase()) {
case 'yes':
return true;
default:
return false;
}
} else if (types.isBoolean(value)) {
return value;
}
return false;
}
示例6: 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.");
}
}
}
示例7: 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();
}
}
示例8: _createImageSourceFromSrc
/**
* @internal
*/
_createImageSourceFromSrc(): void {
var value = this.src;
if (types.isString(value)) {
value = value.trim();
this.imageSource = null;
this["_url"] = value;
// this._setValue(SVGImage.isLoadingProperty, true);
this.isLoading = true;
var source = new definition.ImageSourceSVG();
var imageLoaded = () => {
let currentValue = this.src;
if (!types.isString(this.src) || value !== currentValue.trim()) {
return;
}
this.imageSource = source;
// imageSourceProperty.nativeValueChange(this, source);
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
//WRONG IMplementation, it can't load data uri, just base xml encode
if (utils.isDataURI(value)) {
var base64Data = value.split(",")[1];
if (types.isDefined(base64Data)) {
if (this.loadMode === SYNC) {
source.loadFromBase64(base64Data);
imageLoaded();
} else if (this.loadMode === ASYNC) {
source.fromBase64(base64Data).then(imageLoaded);
}
}
}
else if (definition.isFileOrResourcePath(value)) {
if (value.indexOf(utils.RESOURCE_PREFIX) === 0) {
let resPath = value.substr(utils.RESOURCE_PREFIX.length);
if (this.loadMode === SYNC) {
source.loadFromResource(resPath);
imageLoaded();
} else if (this.loadMode === ASYNC) {
this.imageSource = null;
source.fromResource(resPath).then(imageLoaded);
}
} else {
if (this.loadMode === SYNC) {
source.loadFromFile(value);
imageLoaded();
} else if (this.loadMode === ASYNC) {
this.imageSource = null;
source.fromFile(value).then(imageLoaded);
}
}
} else {
this.imageSource = null;
definition.fromUrl(value).then((r) => {
if (this["_url"] === value) {
this.imageSource = r;
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
});
}
}
else if (value instanceof definition.ImageSourceSVG) {
// Support binding the imageSource trough the src property
this.imageSource = value;
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
else {
this.imageSource = definition.fromNativeSource(value);
// this._setValue(SVGImage.isLoadingProperty, false);
this.isLoading = false;
}
}