/**
  * @param flag
  * @param bgColor
  * @param baseUrl
  * @param mEBrowserView
  * @author wanglei
  * @createAt 20151124
  * @ps 与原EBrowserView的setBrwViewBackground类似,原方法只设置EBrowserView的背景
  *     当网页设置弹动效果后,上下滑动到边缘后,会露出EBrowserView下面的网页,故应给EBrowserView 父对象EBounceView设置背景,
  *     EBrowserView背景设成透明。
  */
 public void setBounceViewBackground(
     boolean flag, String bgColor, String baseUrl, EBrowserView mEBrowserView) {
   if (flag) {
     if (bgColor.startsWith("#") || bgColor.startsWith("rgb")) {
       int color = BUtility.parseColor(bgColor);
       setBackgroundColor(color);
     } else {
       String path =
           BUtility.makeRealPath(
               BUtility.makeUrl(mEBrowserView.getCurrentUrl(baseUrl), bgColor),
               mEBrowserView.getCurrentWidget().m_widgetPath,
               mEBrowserView.getCurrentWidget().m_wgtType);
       Bitmap bitmap = BUtility.getLocalImg(mContext, path);
       Drawable d = null;
       if (bitmap != null) {
         d = new BitmapDrawable(mContext.getResources(), bitmap);
       }
       int version = Build.VERSION.SDK_INT;
       if (version < 16) {
         setBackgroundDrawable(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       } else {
         setBackground(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       }
     }
   } else {
     setBackgroundColor(Color.TRANSPARENT);
   }
 }
 /**
  * sd卡记录信息
  *
  * @param text
  */
 public static void log(String text) {
   Log.i("push", text);
   if (!isLog) {
     return;
   }
   if (!TextUtils.isEmpty(text) && BUtility.sdCardIsWork()) {
     String developPath = BUtility.getSdCardRootPath() + "widgetone/log/";
     File dir = new File(developPath);
     if (!dir.exists()) {
       dir.mkdirs();
     }
     File log = new File(developPath + "push_log_" + getCurYearAndMonth() + ".log");
     try {
       if (!log.exists()) {
         log.createNewFile();
       }
       BufferedWriter m_fout = new BufferedWriter(new FileWriter(log, true));
       m_fout.write("\r" + getNowTime() + "\r" + text);
       m_fout.flush();
       m_fout.close();
       m_fout = null;
     } catch (Exception e) {
       // TODO: handle exception
     }
   }
 }
Ejemplo n.º 3
0
 private void setData(PieChartVO chart) {
   List<PieUnit> list = chart.getData();
   if (list == null || list.size() == 0) {
     return;
   }
   int length = list.size();
   String[] titles = new String[length];
   ArrayList<Entry> entrys = new ArrayList<Entry>();
   int[] colors = new int[length];
   for (int i = 0; i < length; i++) {
     PieUnit bean = list.get(i);
     titles[i] = bean.getTitle();
     entrys.add(new Entry(bean.getValue(), i));
     colors[i] = BUtility.parseColor(bean.getColor());
   }
   PieDataSet set1 = new PieDataSet(entrys, "");
   set1.setSliceSpace(3f);
   set1.setDrawValues(chart.isShowValue());
   set1.setValueTextColor(chart.getValueTextColor());
   set1.setValueTextSize(chart.getValueTextSize());
   set1.setColors(colors);
   if (chart.isShowPercent()) {
     set1.setValueFormatter(new PercentFormatter());
   } else {
     if (chart.isShowUnit()) {
       set1.setValueFormatter(new ValueUnitFormatter(chart.getUnit()));
     }
   }
   PieData data = new PieData(titles, set1);
   mChart.setData(data);
   // undo all highlights
   mChart.highlightValues(null);
   mChart.invalidate();
 }
Ejemplo n.º 4
0
 public void installApp(String[] parm) {
   if (parm.length < 1) {
     return;
   }
   EBrowserWindow curWind = mBrwView.getBrowserWindow();
   if (null == curWind) {
     return;
   }
   String inAppPath = parm[0];
   if (null == inAppPath || 0 == inAppPath.trim().length()) {
     return;
   }
   inAppPath =
       BUtility.makeRealPath(
           inAppPath, mBrwView.getCurrentWidget().m_widgetPath, curWind.getWidgetType());
   if (inAppPath.contains("wgtRes")) {
     InputStream is;
     try {
       // String tPath = m_eContext.getCacheDir().getAbsolutePath() +
       // "/temp.apk";
       String tPath = Environment.getExternalStorageDirectory().getPath() + "/temp.apk";
       is = mContext.getAssets().open(inAppPath);
       File file = new File(tPath);
       file.createNewFile();
       FileOutputStream fos = new FileOutputStream(file);
       byte[] temp = new byte[8 * 1024];
       int i = 0;
       while ((i = is.read(temp)) > 0) {
         fos.write(temp, 0, i);
       }
       fos.close();
       is.close();
       inAppPath = tPath;
       // modify permission
       // String command = "chmod777" + " " + inAppPath;
       // Runtime.getRuntime().exec(command);
     } catch (IOException e) {
       Toast.makeText(
               mContext,
               ResoureFinder.getInstance().getString(mContext, "error_sdcard_is_not_available"),
               Toast.LENGTH_SHORT)
           .show();
       return;
     }
   }
   // install apk.
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   MimeTypeMap type = MimeTypeMap.getSingleton();
   String mime = type.getMimeTypeFromExtension("apk");
   intent.setDataAndType(Uri.parse("file://" + inAppPath), mime);
   mContext.startActivity(intent);
 }
Ejemplo n.º 5
0
 public void setCustomButton(final CustomButtonVO dataVO) {
   CustomButtonResultVO resultVO = new CustomButtonResultVO();
   resultVO.setId(dataVO.getId());
   if (!isAlreadyAdded(dataVO.getId())) {
     FrameLayout.LayoutParams lpParams =
         new FrameLayout.LayoutParams(dataVO.getWidth(), dataVO.getHeight());
     lpParams.leftMargin = dataVO.getX();
     lpParams.topMargin = dataVO.getY();
     Button btn = new Button(this);
     btn.setLayoutParams(lpParams);
     btn.setPadding(0, 0, 0, 0);
     if (!TextUtils.isEmpty(dataVO.getTitle())) {
       btn.setText(dataVO.getTitle());
     }
     if (dataVO.getTextSize() > 0) {
       btn.setTextSize(dataVO.getTextSize());
     }
     if (!TextUtils.isEmpty(dataVO.getTitleColor())) {
       btn.setTextColor(BUtility.parseColor(dataVO.getTitleColor()));
     }
     if (!TextUtils.isEmpty(dataVO.getBgImage())) {
       Drawable bg = new BitmapDrawable(GaodeUtils.getImage(this, dataVO.getBgImage()));
       int version = Build.VERSION.SDK_INT;
       if (version < 16) {
         btn.setBackgroundDrawable(bg);
       } else {
         btn.setBackground(bg);
       }
     }
     mContent.addView(btn);
     btn.setVisibility(View.GONE);
     btn.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             if (mListener != null) {
               EUExGaodeMap gaodeMap = mButtons.get(dataVO.getId()).getGaodeMap();
               mListener.onButtonClick(dataVO.getId(), gaodeMap);
             }
           }
         });
     CustomButtonBean button = new CustomButtonBean();
     button.setButton(btn);
     mButtons.put(dataVO.getId(), button);
     resultVO.setIsSuccess(true);
   } else {
     resultVO.setIsSuccess(false);
   }
   if (mListener != null) {
     mListener.cbSetCustomButton(resultVO);
   }
 }
Ejemplo n.º 6
0
  private void initPieChartView(PieChartVO chart) {
    mChart.animateXY(chart.getDuration(), chart.getDuration());
    String centerText = chart.getCenterTitle() + "\n" + chart.getCenterSummary();
    if (!centerText.equals("\n")) mChart.setCenterText(centerText);
    mChart.setCenterTextSize(chart.getDescTextSize());
    mChart.setCenterTextColor(chart.getDescTextColor());
    mChart.setDescription(chart.getDesc());
    mChart.setDescriptionColor(chart.getDescTextColor());
    mChart.setDescriptionTextSize(chart.getDescTextSize());
    mChart.setDrawHoleEnabled(chart.isShowCenter()); // center circle part
    mChart.setDrawCenterText(chart.isShowCenter());
    mChart.setDrawSliceText(chart.isShowTitle()); // is show title
    // mChart.setDrawUnitsInChart(chart.isShowUint());
    // mChart.setUnit(chart.getUnit());
    mChart.setBackgroundColor(chart.getBgColor());
    mChart.setHoleRadius(chart.getCenterRadius());
    mChart.setTransparentCircleRadius(chart.getCenterTransRadius());

    if (BUtility.parseColor(chart.getCenterColor()) == Color.TRANSPARENT) {
      mChart.setHoleColorTransparent(true);
    } else {
      mChart.setHoleColor(BUtility.parseColor(chart.getCenterColor()));
    }
    mChart.setUsePercentValues(chart.isShowPercent());

    // add a selection listener
    mChart.setOnChartValueSelectedListener(this);
    mChart.setRotationAngle(0);
    setData(chart);
    Legend l = mChart.getLegend();
    l.setEnabled(chart.isShowLegend()); // is show legend(tuli)
    l.setTextColor(chart.getDescTextColor());
    l.setTextSize(chart.getDescTextSize());
    l.setPosition(chart.getLegendPosition());
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
  }
  public void setBounceParms(int type, JSONObject json, String guestId) {

    String imagePath = null;
    String textColor = null;
    String levelText = null;
    String pullToReloadText = null;
    String releaseToReloadText = null;
    String loadingText = null;
    String loadingImagePath = null;
    imagePath = json.optString("imagePath");
    if (null != imagePath) {
      imagePath =
          BUtility.makeRealPath(
              imagePath,
              mBrwView.getCurrentWidget().m_widgetPath,
              mBrwView.getCurrentWidget().m_wgtType);
    }
    textColor = json.optString("textColor");
    levelText = json.optString("levelText");
    pullToReloadText = json.optString("pullToReloadText");
    releaseToReloadText = json.optString("releaseToReloadText");
    loadingText = json.optString("loadingText");
    if (null != guestId && guestId.equals("donghang")) {
      loadingImagePath = json.optString("loadingImagePath");
      if (null != loadingImagePath) {
        loadingImagePath =
            BUtility.makeRealPath(
                loadingImagePath,
                mBrwView.getCurrentWidget().m_widgetPath,
                mBrwView.getCurrentWidget().m_wgtType);
      }
    }
    switch (type) {
      case EViewEntry.F_BOUNCE_TYPE_TOP:
        if (null != imagePath && 0 != imagePath.trim().length()) {
          mHeaderView.setArrowhead(imagePath);
        }
        if (null != loadingImagePath && 0 != loadingImagePath.trim().length()) {
          mHeaderView.setLoadingPic(loadingImagePath);
        }
        if ((null == textColor || 0 == textColor.trim().length())
            && (null == pullToReloadText || 0 == pullToReloadText.trim().length())
            && (null == releaseToReloadText || 0 == releaseToReloadText.trim().length())
            && (null == loadingText || 0 == loadingText.trim().length())) {
          mHeaderView.setContentEmpty(true);
        } else {
          if (null != textColor && 0 != textColor.trim().length()) {
            int color = mBrwView.parseColor(textColor);
            mHeaderView.setTextColor(color);
          }
          if (null != levelText && 0 != levelText.trim().length()) {
            mHeaderView.setLevelText(levelText);
          }
          if (null != releaseToReloadText && 0 != releaseToReloadText.trim().length()) {
            mHeaderView.setReleaseToReloadText(releaseToReloadText);
          }
          if (null != loadingText && 0 != loadingText.trim().length()) {
            mHeaderView.setLoadingText(loadingText);
          }
          if (null != pullToReloadText && 0 != pullToReloadText.trim().length()) {
            mHeaderView.setPullToReloadText(pullToReloadText);
          }
        }
        break;
      case EViewEntry.F_BOUNCE_TYPE_BOTTOM:
        if (null != imagePath && 0 != imagePath.trim().length()) {
          mTailView.setArrowhead(imagePath);
        }
        if (null != loadingImagePath && 0 != loadingImagePath.trim().length()) {
          mTailView.setLoadingPic(loadingImagePath);
        }
        if ((null == textColor || 0 == textColor.trim().length())
            && (null == pullToReloadText || 0 == pullToReloadText.trim().length())
            && (null == releaseToReloadText || 0 == releaseToReloadText.trim().length())
            && (null == loadingText || 0 == loadingText.trim().length())) {
          mTailView.setContentEmpty(true);
        } else {
          if (null != textColor && 0 != textColor.trim().length()) {
            int color = mBrwView.parseColor(textColor);
            mTailView.setTextColor(color);
          }
          if (null != levelText && 0 != levelText.trim().length()) {
            mTailView.setLevelText(levelText);
          }
          if (null != releaseToReloadText && 0 != releaseToReloadText.trim().length()) {
            mTailView.setReleaseToReloadText(releaseToReloadText);
          }
          if (null != loadingText && 0 != loadingText.trim().length()) {
            mTailView.setLoadingText(loadingText);
          }
          if (null != pullToReloadText && 0 != pullToReloadText.trim().length()) {
            mTailView.setPullToReloadText(pullToReloadText);
          }
        }
        break;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
      Intent intent = getIntent();
      if (intent != null) {
        isTemp = intent.getBooleanExtra("isTemp", false);
      }
    } catch (Exception exception) {
    }
    FrameLayout rootLayout = new FrameLayout(this);
    FrameLayout.LayoutParams layoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    rootLayout.setLayoutParams(layoutParams);
    InputStream inputStream =
        getResources().openRawResource(EUExUtil.getResDrawableID("startup_bg_16_9"));
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    Bitmap bm = BUtility.createBitmapWithStream(inputStream, dm.widthPixels, dm.heightPixels);
    if (bm != null) {
      ImageView imageView = new ImageView(this);
      imageView.setScaleType(ImageView.ScaleType.FIT_XY);
      imageView.setImageBitmap(bm);
      rootLayout.addView(imageView);
    }
    setContentView(rootLayout);

    mHandler.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            if (!isTemp) {
              try {
                Intent intent = new Intent(LoadingActivity.this, EBrowserActivity.class);
                Bundle bundle = getIntent().getExtras();
                if (null != bundle) {
                  intent.putExtras(bundle);
                }
                startActivity(intent);
                overridePendingTransition(
                    EUExUtil.getResAnimID("platform_myspace_no_anim"),
                    EUExUtil.getResAnimID("platform_myspace_no_anim"));
              } catch (Exception e) {
              }
            }
          }
        },
        700);

    mBroadcastReceiver = new MyBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BROADCAST_ACTION);
    LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter);
    if (EBrowserActivity.develop) {
      TextView worn = new TextView(this);
      worn.setText(EUExUtil.getString("platform_only_test"));
      worn.setTextColor(0xffff0000);
      worn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
      FrameLayout.LayoutParams wornPa = new FrameLayout.LayoutParams(Compat.FILL, Compat.WRAP);
      wornPa.gravity = Gravity.TOP;
      wornPa.leftMargin = 10;
      wornPa.topMargin = 10;
      worn.setLayoutParams(wornPa);
      rootLayout.addView(worn);
    }
    try {
      getWindow()
          .clearFlags(
              WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
    } catch (Exception e) {
    }
  }