private static Set<String> generateNewAssetPaths(Application application, String path) {
    Set<String> assetPaths = null;

    if ((path != null) && (assetPathsHistory != null && assetPathsHistory.contains(path))) {
      // already added, just return null
      return null;
    }

    assetPaths = new LinkedHashSet<String>();
    assetPaths.add(application.getApplicationInfo().sourceDir);
    if (ignoreOpt && Build.VERSION.SDK_INT > 20) {
      assetPaths.add(WebViewGoogleAssetPath);
    }

    // get original asset paths on android above 5.0 in case webview not
    // added
    try {
      if (mOriginAssetsPath == null && Build.VERSION.SDK_INT > 20 && !ignoreOpt) {
        mOriginAssetsPath = getOriginAssetsPath(application.getResources().getAssets());
        assetPaths.addAll(mOriginAssetsPath);
      }
    } catch (Throwable e) {
    }

    if (assetPathsHistory != null) assetPaths.addAll(assetPathsHistory);

    if (!TextUtils.isEmpty(path)) assetPaths.add(path);

    return assetPaths;
  }
  public BaseBetterLazyImageLoader(
      ImageCache<ImageSource> imageCache,
      ImageDownloader<ImageSource> imageDownloader,
      Application application,
      int noImageDrawableResourceId,
      int imageLoadingDrawableResourceId) {
    this.imageCache = imageCache;
    this.imageDownloader = imageDownloader;
    this.application = application;
    waitingViewsRepository = new WaitingViewsRepository<ImageSource, ImageView>();
    downloaderTasksMap = new HashMap<ImageSource, BitmapDownloaderTask<ImageSource>>();

    noImageDrawable =
        (noImageDrawableResourceId != 0)
            ? application.getResources().getDrawable(noImageDrawableResourceId)
            : null;
    imageLoadingDrawable =
        (imageLoadingDrawableResourceId != 0)
            ? application.getResources().getDrawable(imageLoadingDrawableResourceId)
            : null;
  }
Пример #3
0
 private void getServerConfig() {
   Properties pro = new Properties();
   InputStream is;
   try {
     // 读取配置文件里的内容,
     // 将配置文件里的Ip地址读取进入一个流
     is = mApp.getResources().openRawResource(R.raw.config);
     // 从输入流中读取属性列表(键和元素对)。
     pro.load(is);
     // 获取Ip的String
     plmsServerIP = pro.getProperty("PlmsServerIP", "");
     is.close();
   } catch (IOException e) {
     Toast.makeText(this, "config.property File Not Found!", Toast.LENGTH_SHORT).show();
   }
 }
Пример #4
0
 protected V8Engine(Application application, String path) {
   if (path != null) {
     scriptPath = path;
   }
   if (application != null) {
     assetManager = application.getAssets();
     final Resources r = application.getResources();
     if (r != null) {
       mDensity = r.getDisplayMetrics().density;
     }
   }
   Locale locale = Locale.getDefault();
   String country = locale.getCountry();
   if (country.isEmpty()) {
     mLocale = locale.getLanguage();
   } else {
     mLocale = locale.getLanguage() + "_" + country;
   }
   mLang = locale.getLanguage();
   mTimeZone = TimeZone.getDefault().getID();
 }
Пример #5
0
  public SmileProcessor(Application application) {
    long start = System.currentTimeMillis();
    this.application = application;
    processor = this;
    density = application.getResources().getDisplayMetrics().density;

    emojiSideSize = (int) (density * 20);

    Logger.d(TAG, "Emoji phase 0 in " + (System.currentTimeMillis() - start) + " ms");

    if (density >= 2 || density == 1) {
      if (density >= 2) {
        // XHDPI and more
        if (SmileysPack.PACK_2) {
          layoutType = LAYOUT_2X_1;
        } else if (SmileysPack.PACK_15) {
          layoutType = LAYOUT_15X_1;
        } else if (SmileysPack.PACK_1) {
          layoutType = LAYOUT_1X;
        } else {
          throw new RuntimeException("Unable to find smileys pack");
        }
      } else {
        // MDPI
        if (SmileysPack.PACK_1) {
          layoutType = LAYOUT_1X;
        } else if (SmileysPack.PACK_15) {
          layoutType = LAYOUT_15X_1;
        } else if (SmileysPack.PACK_2) {
          layoutType = LAYOUT_2X_2;
        } else {
          throw new RuntimeException("Unable to find smileys pack");
        }
      }
    } else {
      if (density > 1) { // 1.3333 and 1.5
        // HDPI & TVDPI
        if (SmileysPack.PACK_15) {
          layoutType = LAYOUT_15X_1;
        } else if (SmileysPack.PACK_2) {
          layoutType = LAYOUT_2X_1;
        } else if (SmileysPack.PACK_1) {
          layoutType = LAYOUT_1X;
        } else {
          throw new RuntimeException("Unable to find smileys pack");
        }
      } else { // 0.75
        // LDPI
        if (SmileysPack.PACK_15) {
          layoutType = LAYOUT_15X_2;
        } else if (SmileysPack.PACK_1) {
          layoutType = LAYOUT_1X;
        } else if (SmileysPack.PACK_2) {
          layoutType = LAYOUT_2X_2;
        } else {
          throw new RuntimeException("Unable to find smileys pack");
        }
      }
    }

    Logger.d(TAG, "Emoji phase 1 in " + (System.currentTimeMillis() - start) + " ms");
    start = System.currentTimeMillis();

    switch (layoutType) {
      default:
      case LAYOUT_1X:
        rectSize = 28;
        break;
      case LAYOUT_15X_1:
        rectSize = 36;
        break;
      case LAYOUT_15X_2:
        rectSize = 18;
        break;
      case LAYOUT_2X_1:
        rectSize = 56;
        break;
      case LAYOUT_2X_2:
        rectSize = 28;
        break;
    }

    indexes = new HashMap<Long, Integer>();
    emojiMap = new HashMap<Integer, Bitmap>();
    originalMetrics = new HashMap<Integer, Paint.FontMetricsInt>();

    TextPaint bodyPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    // bodyPaint.setTypeface(FontController.loadTypeface(application, "normal"));
    bodyPaint.setTextSize(getSp(16));
    bodyPaint.setColor(0xff000000);
    originalMetrics.put(CONFIGURATION_BUBBLES, bodyPaint.getFontMetricsInt());

    bodyPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    // bodyPaint.setTypeface(FontController.loadTypeface(application, "light"));
    bodyPaint.setColor(0xff808080);
    bodyPaint.setTextSize(getSp(15.5f));
    originalMetrics.put(CONFIGURATION_DIALOGS, bodyPaint.getFontMetricsInt());

    Logger.d(TAG, "Emoji phase 2 in " + (System.currentTimeMillis() - start) + " ms");
    start = System.currentTimeMillis();

    for (int i = 0; i < EMOJI_MAP.length; i++) {
      indexes.put(EMOJI_MAP[i], i);
    }

    Logger.d(TAG, "Emoji phase 3 in " + (System.currentTimeMillis() - start) + " ms");
  }
Пример #6
0
 protected int getSp(float sp) {
   return (int)
       TypedValue.applyDimension(
           TypedValue.COMPLEX_UNIT_SP, sp, application.getResources().getDisplayMetrics());
 }
 private static String getStringByKey(Application app, String key) {
   int resourceId = app.getResources().getIdentifier(key, "string", app.getPackageName());
   return app.getString(resourceId);
 }
Пример #8
0
 public Resources getResources() {
   return application.getResources();
 }