示例#1
0
 public static boolean isAliInstalled() {
   String packageName = "com.eg.android.AlipayGphone";
   final PackageManager packageManager = MainApplication.getInstance().getPackageManager();
   // 获取所有已安装程序的包信息
   List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
   for (int i = 0; i < pinfo.size(); i++) {
     if (pinfo.get(i).packageName.equalsIgnoreCase(packageName)) return true;
   }
   return false;
 }
示例#2
0
  public Drawable getDrawable(String source) {
    if (urlMap.containsKey(source)) {
      return urlMap.get(source);
    }
    Drawable urlDrawable =
        MainApplication.getInstance().getResources().getDrawable(R.drawable.ct_default);

    // get the actual source
    ImageGetterAsyncTask asyncTask = new ImageGetterAsyncTask();

    asyncTask.execute(source);

    // return reference to URLDrawable where I will change with actual image from
    // the src tag

    return urlDrawable;
  }
示例#3
0
 /**
  * * Get the Drawable from URL
  *
  * @param urlString
  * @return
  */
 public Drawable fetchDrawable(String urlString) {
   try {
     Bitmap bitmap =
         ImageLoader.getInstance()
             .loadImageSync(urlString, ImageHelper.getDefaultDisplayImageOptions());
     //                InputStream is = fetch(urlString);
     //                Drawable drawable = Drawable.createFromStream(is, "src");
     Drawable drawable = new BitmapDrawable(bitmap);
     int tempWidth =
         bitmap.getScaledWidth(MainApplication.getInstance().getResources().getDisplayMetrics());
     int height =
         bitmap.getScaledHeight(MainApplication.getInstance().getResources().getDisplayMetrics())
             * 2
             / 3;
     //                drawable.setBounds(0,0,tempWidth,height);
     LogHelper.e("omg", "normal  " + tempWidth + " -" + height);
     LogHelper.e(
         "omg",
         "page  "
             + MainApplication.getInstance().getPageWidth()
             + " -"
             + MainApplication.getInstance().getPageHeight());
     int width = MainApplication.getInstance().getPageWidth();
     float leftPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_left_padding);
     float topPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_top_padding);
     //                height =  width * height /tempWidth ;
     drawable.setBounds(
         (int) leftPadding,
         0,
         (width > 0 ? width : 0) - (int) leftPadding * 2,
         (height > 0 ? height : 0));
     LogHelper.e(
         "omg", "bound " + drawable.getBounds().width() + " - " + drawable.getBounds().height());
     return drawable;
   } catch (Exception e) {
     return null;
   }
 }
示例#4
0
  public static String getDateFormat(long dateTime) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeZone(TimeZone.getTimeZone("GMT+800"));
    int day = calendar.get(Calendar.DAY_OF_YEAR);
    int year = calendar.get(Calendar.YEAR);
    calendar.setTimeInMillis(dateTime);
    int day1 = calendar.get(Calendar.DAY_OF_YEAR);
    int year1 = calendar.get(Calendar.YEAR);

    if (year == year1) {
      if (day == day1) {
        return H_M.format(dateTime);
      } else if (day - day1 == 1) {
        return MainApplication.getInstance().getString(R.string.ct_yestoday) + H_M.format(dateTime);
      } else {
        return Y_M_D_H_M.format(dateTime);
      }
    } else {
      return Y_M_D_H_M.format(dateTime);
    }
  }
示例#5
0
 public static float dp2pixelF(int i) {
   return (0.5F
       + MainApplication.getInstance().getResources().getDisplayMetrics().density * (float) i);
 }