@SuppressWarnings("unchecked") @Override protected void onProgressUpdate(Map.Entry<String, String>... values) { Map.Entry<String, String> entry = values[0]; if (entry.getKey().equals("headline_title")) { mToolbarLayout.setTitle(entry.getValue()); } else if (entry.getKey().equals("content")) { // Log.d(TAG, entry.getValue()); mWebView.loadDataWithBaseURL(mUrl, entry.getValue(), "text/html", "uft-8", null); } else if (entry.getKey().equals("img")) { if (ThemeUtils.isLight) { Glide.with(App.getContext()).load(entry.getValue()).asBitmap().centerCrop().listener(mPaletteListenerImp).into(mHeaderImg); }else { Glide.with(App.getContext()).load(entry.getValue()).asBitmap().centerCrop().into(mHeaderImg); } } else if (entry.getKey().equals("img_source")) { mHeaderSource.setText(entry.getValue()); mHeaderSource.setVisibility(View.VISIBLE); } } }
@Override public void loadGson(DailyGson dailyGson) { mDailyGson = dailyGson; Glide.with(App.getContext()).load(dailyGson.image).asBitmap().fitCenter().listener(mPaletteListenerImp).into(mHeader); String head = "<head>\n" + "<meta charset=\"utf-8\">\n" + "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n" + "<title>" + dailyGson.title + "</title>\n" + "<meta name=\"viewport\" content=\"user-scalable=no, width=device-width\">\n" + "<link rel=\"stylesheet\" href=\"" + "http://7xk54v.com1.z0.glb.clouddn.com/app/bb/css/zhihu.css" + "\">\n" + "<style type=\"text/css\"></style>\n" + "<base target=\"_blank\">\n" + "</head>"; String bodyStart = "<body>"; String bodyEnd = "</body>"; mWebView.loadData(head + bodyStart + dailyGson.body.replaceAll("<div class=\"img-place-holder\"></div>", "") + bodyEnd, "text/html; charset=uft-8", "utf-8"); }
@Override public void displayImage(Activity activity, final ImageView imageView, String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final MQDisplayImageListener listener) { final String finalPath = getPath(path); Glide.with(activity).load(finalPath).asBitmap().placeholder(loadingResId).error(failResId).override(width, height).listener(new RequestListener<String, Bitmap>() { @Override public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(Bitmap resource, String model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) { if (listener != null) { listener.onSuccess(imageView, finalPath); } return false; } }).into(imageView); }
.asBitmap() .placeholder(R.drawable.pic_default) .listener(new RequestListener<String, Bitmap>() { @Override public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
priority(Priority.HIGH). dontAnimate(). listener(new RequestListener<Object, Bitmap>() { @Override public boolean onException(Exception e, Object model, Target<Bitmap> target, boolean isFirstResource) {
.asBitmap() .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(new RequestListener<String, Bitmap>() { @Override public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {