下面列出了com.bumptech.glide.request.target.DrawableImageViewTarget#jp.wasabeef.blurry.Blurry 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void onUserUpdated(@Nullable UserDetail user) {
if (user != null) {
if (binding.viewPager.getAdapter() == null) {
new Handler(Looper.myLooper()).postDelayed(this::initPager, 300);
}
binding.tvName.setText(user.getDisplayName());
binding.tvLink.setText(user.getHtmlUrl());
if (InputHelper.isEmpty(user.getBio())) {
binding.tvBio.setVisibility(View.GONE);
} else {
binding.tvBio.setVisibility(View.VISIBLE);
binding.tvBio.setText(user.getBio());
}
GlideUtils.loadImageBitmap(this, user.getAvatarUrl(), bitmap -> {
binding.imvAvatar.setImageBitmap(bitmap);
Blurry.with(this).radius(25).from(bitmap).into(binding.imvBackground);
});
}
}
public void showArt(String artUrl) {
if (!TextUtils.equals(lastArtUrl, artUrl)) {
lastArtUrl = artUrl;
Glide.with(getContext())
.load(artUrl)
.asBitmap()
.priority(Priority.IMMEDIATE)
.into(new ImageViewTarget<Bitmap>(smallImage) {
@Override
protected void setResource(Bitmap resource) {
smallImage.setImageBitmap(resource);
smallImage.post(() -> {
Blurry.with(getContext())
.async(bitmap -> {
background.setImageDrawable(bitmap);
getActivity().supportStartPostponedEnterTransition();
})
.from(resource)
.into(background);
});
}
});
}
}
private void Render(Activity activity) {
// Defaults
if(this.radius == 0)
setRadius(defaultRadius);
if(this.sampling == 0)
setSampling(defaultSampling);
Log.i(LOGTAG, String.format("activity %s", activity));
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
Log.i(LOGTAG, String.format("viewGroup %s", viewGroup));
Log.i(LOGTAG, String.format("this %s", this));
Blurry.Composer c = Blurry.with(activity)
.radius(this.radius)
.sampling(this.sampling);
if(this.color != null)
c = c.color(Color.parseColor(this.color));
//c.async()
c.capture(viewGroup)
.into(this);
}
@BindingAdapter("blurImage")
public static void setBlurImage(ImageView imageView, String url) {
Glide.with(imageView.getContext())
.applyDefaultRequestOptions(PicConfig.itemOptions)
.asBitmap()
.load(url)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Blurry.with(imageView.getContext()).from(resource).into(imageView);
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_slide:
// Blurry.with(this)
// .color(Color.argb(66, 255, 255, 0))
// .radius(25)
// .sampling(2)
// .async()
// .onto((ViewGroup) getWindow().getDecorView());
// BaseUtil.startActivityOnspecifiedAnimation(this, SlidToFinishActivity.class);
photoUtils.takePhoto(2222);
break;
case R.id.tv_browser:
Blurry.delete((ViewGroup) getWindow().getDecorView());
BaseUtil.startActivityOnspecifiedAnimation(this, ScrollingActivity.class);
// BaseUtil.startActivityOnspecifiedAnimation(this, BrowserActivity.class);
break;
case R.id.tv_browser2:
BaseUtil.startActivityOnspecifiedAnimation(this, ScrollingActivity.class);
break;
case R.id.scrollView:
BaseUtil.startActivityOnspecifiedAnimation(this, FangshiActivity.class);
break;
case R.id.bottom_sheet:
// BaseUtil.startActivityOnspecifiedAnimation(this, BottomSheetActivity.class);
JumpUtil.jumpToBottome(this);
break;
case R.id.button:
buttonOutAnimation(interpolator);
break;
}
}
private void init(Activity context, PeekViewOptions options, @NonNull View content, @Nullable OnPeek callbacks) {
this.options = options;
this.callbacks = callbacks;
FINGER_SIZE = DensityUtils.toPx(context, FINGER_SIZE_DP);
// get the main content view of the display
androidContentView = (FrameLayout) context.findViewById(android.R.id.content).getRootView();
// initialize the display size
Display display = context.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenHeight = size.y;
screenWidth = size.x;
// set up the content we want to show
this.content = content;
contentParams = content.getLayoutParams();
if (options.getAbsoluteHeight() != 0) {
setHeight(DensityUtils.toPx(context, options.getAbsoluteHeight()));
} else {
setHeightByPercent(options.getHeightPercent());
}
if (options.getAbsoluteWidth() != 0) {
setWidth(DensityUtils.toPx(context, options.getAbsoluteWidth()));
} else {
setWidthByPercent(options.getWidthPercent());
}
// tell the code that the view has been onInflated and let them use it to
// set up the layout.
if (callbacks != null) {
callbacks.onInflated(content);
}
// add the background dim to the frame
dim = new View(context);
dim.setBackgroundColor(Color.BLACK);
dim.setAlpha(options.getBackgroundDim());
FrameLayout.LayoutParams dimParams =
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
dim.setLayoutParams(dimParams);
if (options.shouldBlurBackground()) {
Blurry.with(context)
.radius(2)
.sampling(5)
.animate()
.color(options.getBlurOverlayColor())
.onto((ViewGroup) androidContentView.getRootView());
dim.setAlpha(0f);
}
// add the dim and the content view to the upper level frame layout
addView(dim);
addView(content);
}
private void init(Activity context, PeekViewOptions options, @NonNull View content,
@Nullable OnPeek callbacks) {
this.options = options;
this.callbacks = callbacks;
FINGER_SIZE = DensityUtils.toPx(context, FINGER_SIZE_DP);
// get the main content view of the display
androidContentView = (FrameLayout) context.findViewById(android.R.id.content).getRootView();
// initialize the display size
Display display = context.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenHeight = size.y;
screenWidth = size.x;
// set up the content we want to show
this.content = content;
contentParams = content.getLayoutParams();
if (options.getAbsoluteHeight() != 0) {
setHeight(DensityUtils.toPx(context, options.getAbsoluteHeight()));
} else {
setHeightByPercent(options.getHeightPercent());
}
if (options.getAbsoluteWidth() != 0) {
setWidth(DensityUtils.toPx(context, options.getAbsoluteWidth()));
} else {
setWidthByPercent(options.getWidthPercent());
}
// tell the code that the view has been onInflated and let them use it to
// set up the layout.
if (callbacks != null) {
callbacks.onInflated(this, content);
}
// add the background dim to the frame
dim = new View(context);
dim.setBackgroundColor(Color.BLACK);
dim.setAlpha(options.getBackgroundDim());
LayoutParams dimParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
dim.setLayoutParams(dimParams);
if (options.shouldBlurBackground()) {
try {
Blurry.with(context)
.radius(2)
.sampling(5)
.animate()
.color(options.getBlurOverlayColor())
.onto((ViewGroup) androidContentView.getRootView());
dim.setAlpha(0f);
} catch(Exception ignored){
}
}
// add the dim and the content view to the upper level frame layout
addView(dim);
addView(content);
}