當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.ad類代碼示例

本文整理匯總了TypeScript中tns-core-modules/utils/utils.ad的典型用法代碼示例。如果您正苦於以下問題:TypeScript ad類的具體用法?TypeScript ad怎麽用?TypeScript ad使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ad類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Promise

    return new Promise((resolve, reject) => {
      try {
        if (!this.keyguardManager || !this.keyguardManager.isKeyguardSecure()) {
          resolve({
            any: false
          });
          return;
        }

        // The fingerprint API is only available from Android 6.0 (M, Api level 23)
        if (android.os.Build.VERSION.SDK_INT < 23) {
          reject(`Your api version doesn't support fingerprint authentication`);
          return;
        }

        const fingerprintManager = utils.ad.getApplicationContext().getSystemService("fingerprint");
        if (!fingerprintManager.isHardwareDetected()) {
          // Device doesn't support fingerprint authentication
          reject(`Device doesn't support fingerprint authentication`);
        } else if (!fingerprintManager.hasEnrolledFingerprints()) {
          // User hasn't enrolled any fingerprints to authenticate with
          reject(`User hasn't enrolled any fingerprints to authenticate with`);
        } else {
          resolve({
            any: true,
            touch: true
          });
        }
      } catch (ex) {
        console.log(`fingerprint-auth.available: ${ex}`);
        reject(ex);
      }
    });
開發者ID:EddyVerbruggen,項目名稱:nativescript-touchid,代碼行數:33,代碼來源:fingerprint-auth.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:

        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());
        });
開發者ID:EddyVerbruggen,項目名稱:nativescript-3dtouch,代碼行數:20,代碼來源:app-shortcuts.android.ts

示例5: if

    p.on(placeholderModule.Placeholder.creatingViewEvent, (args: placeholderModule.CreateViewEventData) => {
        let nativeView;
        if (isIOS) {
            nativeView = UITextView.new();
            nativeView.text = "Native";
        } else if (isAndroid) {
            nativeView = new android.widget.TextView(utils.ad.getApplicationContext());
            nativeView.setText("Native");
        }

        args.view = nativeView;
    });
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:12,代碼來源:placeholder-tests.ts

示例6: creatingView

function creatingView(args) {
    let nativeView;
    if (isIOS) {
        nativeView = UITextView.new();
        nativeView.text = "Native";
    } else if (isAndroid) {
        nativeView = new android.widget.TextView(utils.ad.getApplicationContext());
        nativeView.setText("Native");
    }

    args.view = nativeView;
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:12,代碼來源:placeholder-tests.ts

示例7:

 navigationButton.on("tap", (args: EventData) => {
     ad.dismissSoftInput();
     this.routerExtensions.backToPreviousPage();
 });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:4,代碼來源:toggle-nav-button.directive.ts

示例8: constructor

 constructor() {
   this.keyguardManager = utils.ad.getApplicationContext().getSystemService("keyguard");
 }
開發者ID:EddyVerbruggen,項目名稱:nativescript-touchid,代碼行數:3,代碼來源:fingerprint-auth.android.ts

示例9: hideKeyboard

export function hideKeyboard() {
    if (isAndroid) {
        ad.dismissSoftInput();
    }
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:5,代碼來源:issue-2942.ts


注:本文中的tns-core-modules/utils/utils.ad類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。