/** * @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); } }
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); }
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; } }