本文整理汇总了TypeScript中tns-core-modules/file-system.knownFolders.currentApp方法的典型用法代码示例。如果您正苦于以下问题:TypeScript knownFolders.currentApp方法的具体用法?TypeScript knownFolders.currentApp怎么用?TypeScript knownFolders.currentApp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tns-core-modules/file-system.knownFolders
的用法示例。
在下文中一共展示了knownFolders.currentApp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _setSrcProperty
private _setSrcProperty(value: string) {
if (value) {
value = value.trim();
let isUrl = false;
if (value.indexOf('://') !== -1) {
if (value.indexOf('res://') === -1) {
isUrl = true;
}
}
this._src = value;
if (!isUrl) {
const currentPath = knownFolders.currentApp().path;
if (value[1] === '/' && (value[0] === '.' || value[0] === '~')) {
value = value.substr(2);
}
if (value[0] !== '/') {
value = currentPath + '/' + value;
}
this._drawable = new pl.droidsonroids.gif.GifDrawable(value);
this.nativeView.setImageDrawable(this._drawable);
} else {
const requestOptions: any = { url: value, method: 'GET' };
if (this._headers !== null) {
requestOptions.headers = this._headers;
}
HttpRequest(requestOptions).then(
r => {
if (r.statusCode === 200) {
this._drawable = new pl.droidsonroids.gif.GifDrawable(
r.content.raw.toByteArray()
);
this.nativeView.setImageDrawable(this._drawable);
} else {
console.log('error getting image: ' + r.statusCode);
}
},
err => {
console.log(err);
}
);
}
} else {
console.log('No src property set for the Gif.');
}
}
示例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.");
}
}
}
示例4: _setSrcProperty
private _setSrcProperty(value: string) {
if (value) {
let isUrl = false;
if (value.indexOf('://') !== -1) {
if (value.indexOf('res://') === -1) {
isUrl = true;
}
}
this._src = value;
if (!isUrl) {
const currentPath = knownFolders.currentApp().path;
if (value[1] === '/' && (value[0] === '.' || value[0] === '~')) {
value = value.substr(2);
}
if (value[0] !== '/') {
value = currentPath + '/' + value;
}
// Using a local .gif
this._animatedImage = FLAnimatedImage.animatedImageWithGIFData(
NSData.dataWithContentsOfFile(NSString.stringWithString(value) as any)
);
// We need to set the image in case the GIF is not from an URL
this._setImage();
} else {
// Using a URL
if (this._headers) {
this._useAnimatedImageFromUrl(value, this._headers);
} else {
this._useAnimatedImageFromUrl(value);
}
}
} else {
console.log('No src value detected.');
}
}
示例5: createPage
export function createPage() {
var page = new pages.Page();
var lbl = new label.Label();
var moduleName = "tests/pages/files/test";
var resolver = new fileResolverModule.FileNameResolver({
width: 400,
height: 600,
os: "android",
deviceType: "phone"
});
// Current app full path.
var currentAppPath = fs.knownFolders.currentApp().path;
var moduleNamePath = fs.path.join(currentAppPath, moduleName);
var fileName = resolver.resolveFileName(moduleNamePath, "xml");
lbl.text = fileName;
lbl.textWrap = true;
page.content = lbl;
return page;
}
示例6: currentApp
public currentApp(): Folder {
return knownFolders.currentApp();
}
示例7: testTemplate
"test.land.xml",
"test.minH600.xml",
"test.minW600.xml",
"test.minWH600.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.minWH600.xml")
}
function testTemplate(candidates: Array<string>, context: resolver.PlatformContext, expected: string) {
var result = resolver._findFileMatch("test", ".xml", candidates, context);
TKUnit.assertEqual(result, expected, "File path");
}
var testFilePath = "~/file-name-resolver-tests/files/test".replace("~", fs.knownFolders.currentApp().path);
export function test_file_resolver_with_andorid_phone_portratit() {
var fileResolver = new resolver.FileNameResolver(androidPhonePortraitContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".xml", "File path");
}
export function test_file_resolver_with_andorid_phone_landscape() {
var fileResolver = new resolver.FileNameResolver(androidPhoneLandsacpeContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".land.xml", "File path");
}
export function test_file_resolver_with_andorid_tablet_portrait() {
var fileResolver = new resolver.FileNameResolver(androidTabletPortraitContext);
示例8: webViewLoaded
import { WebView } from "tns-core-modules/ui/web-view";
import * as fs from "tns-core-modules/file-system";
let webView: WebView;
export function webViewLoaded(args) {
webView = args.object;
}
const relUrl = "~/ui-tests-app/web-view/query.html" + "?foo=bar&urlType=relative";
const absoluteUrl = `${fs.knownFolders.currentApp().path}/ui-tests-app/web-view/query.html` + "?foo=bar&urlType=absolute";
const fileUrl = `file:///${fs.knownFolders.currentApp().path}/ui-tests-app/web-view/query.html` + "?foo=bar&urlType=filePrefix";
const htmlString = `<html>
<head>
<title>Test Page</title>
<meta charset="utf-8" />
</head>
<body>
<div style="color:green" id="result">Just a string ...</div>
</body>
</html>`;
export function loadRelative() {
setSrc(relUrl)
}
export function loadAbsolute() {
setSrc(absoluteUrl)
}
export function loadFile() {
setSrc(fileUrl)
}
export function loadString() {