当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript knownFolders.currentApp方法代码示例

本文整理汇总了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;

  }
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:31,代码来源:helpers.ts

示例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.');
    }
  }
开发者ID:bradmartin,项目名称:nativescript-gif,代码行数:49,代码来源:gif.android.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: _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.');
    }
  }
开发者ID:bradmartin,项目名称:nativescript-gif,代码行数:39,代码来源:gif.ios.ts

示例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;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:24,代码来源:file-load-test.ts

示例6: currentApp

 public currentApp(): Folder {
     return knownFolders.currentApp();
 }
开发者ID:NathanWalker,项目名称:nativescript-angular,代码行数:3,代码来源:ns-file-system.ts

示例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);
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:31,代码来源:file-name-resolver-tests.ts

示例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() {
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:31,代码来源:query-params.ts


注:本文中的tns-core-modules/file-system.knownFolders.currentApp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。