Beispiel #1
0
 /**
  * 用户登录或注销
  *
  * @param activity
  */
 public static void loginOrLogout(Activity activity) {
   AppContext ac = (AppContext) activity.getApplication();
   if (ac.isLogin()) {
     ac.Logout();
     // ToastMessage(activity, "已退出登录");
     AppContext.showToastShort(R.string.tip_logout_success);
   } else {
     // showLoginDialog(activity);
     UIHelper.showLogin(activity);
   }
 }
Beispiel #2
0
 public static String appendStyle(String body) {
   int fontSize = AppContext.getDetailFontSizePx();
   StringBuffer sb =
       new StringBuffer(UIHelper.WEB_STYLE)
           .append(String.format(WEB_FONT_SIZE, fontSize, fontSize + 4, fontSize + 2, fontSize))
           .append(body);
   return sb.toString();
 }
Beispiel #3
0
 /**
  * 打开浏览器
  *
  * @param context
  * @param url
  */
 public static void openBrowser(Context context, String url) {
   try {
     Uri uri = Uri.parse(url);
     Intent it = new Intent(Intent.ACTION_VIEW, uri);
     context.startActivity(it);
   } catch (Exception e) {
     e.printStackTrace();
     AppContext.showToastShort("无法浏览此网页");
   }
 }
Beispiel #4
0
 public static String setHtmlCotentSupportImagePreview(String body) {
   // 读取用户设置:是否加载文章图片--默认有wifi下始终加载图片
   if (AppContext.shouldLoadImage() || TDevice.isWifiOpen()) {
     // 过滤掉 img标签的width,height属性
     body = body.replaceAll("(<img[^>]*?)\\s+width\\s*=\\s*\\S+", "$1");
     body = body.replaceAll("(<img[^>]*?)\\s+height\\s*=\\s*\\S+", "$1");
     // 添加点击图片放大支持
     body =
         body.replaceAll("(<img[^>]+src=\")(\\S+)\"", "$1$2\" onClick=\"showImagePreview('$2')\"");
     // mWebViewImageListener.onImageClick
   } else {
     // 过滤掉 img标签
     body = body.replaceAll("<\\s*img\\s+([^>]*)\\s*>", "");
   }
   return body;
 }