Skip to content

Commit

Permalink
glide version
Browse files Browse the repository at this point in the history
  • Loading branch information
gonojuarez committed Apr 28, 2022
1 parent 3041d75 commit 87bea40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class GlideAttatcher implements GlideModelTypes {

public GlideAttatcher(final @NonNull Context mContext) {
this.mContext = mContext;
glide = Glide.get(this.mContext);
getGlide();
}

public GlideAttatcher loadContext(Context mContext){
Expand Down Expand Up @@ -81,6 +81,8 @@ public void clearMemory() {


private Glide getGlide() {
if(isValidContextFromGlide(this.mContext)&& glide == null)
glide = Glide.get(this.mContext);
return glide;
}

Expand Down Expand Up @@ -116,71 +118,71 @@ public GlideAttatcher UseCornerRadius(boolean useCornerRadious) {
@NonNull
@Override
public Object loadDrawable(@Nullable Bitmap bitmap, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(bitmap)))))).fallback(R.drawable.ic_baseline_cloud_download_24).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(bitmap)))))).fallback(R.drawable.ic_baseline_cloud_download_24).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable Drawable drawable, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(drawable)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(drawable)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable String string, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(string)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(string)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable Uri uri, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(uri).error(R.drawable.ic_baseline_cloud_download_24)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(uri).error(R.drawable.ic_baseline_cloud_download_24)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable File file, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(file)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(file)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable Integer resourceId, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(resourceId)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(resourceId)))))).into(imageView).waitForLayout();
return this;
}

@Override
public Object loadDrawable(@Nullable URL url, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(url).signature(new ObjectKey(url)).error(R.drawable.ic_baseline_cloud_download_24)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(url).signature(new ObjectKey(url)).error(R.drawable.ic_baseline_cloud_download_24)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable byte[] model, ImageView imageView){
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(model)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(model)))))).into(imageView).waitForLayout();
return this;
}

@NonNull
@Override
public Object loadDrawable(@Nullable Object model, ImageView imageView) {
if(isValidContextFromGlide(glide.getContext()))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(glide.getContext()).load(model)))))).into(imageView).waitForLayout();
if(isValidContextFromGlide(mContext))
glideScaleItem(overrideMethod(cornerRadious(useDecodeFormat(useDiskCacheStrategic(getGlide().getRequestManagerRetriever().get(mContext).load(model)))))).into(imageView).waitForLayout();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class ValidateContext {
public static boolean isValidContextFromGlide(Context context) {
Activity activity = getmActivityFromContext(context);
if (activity == null){
return false;}
return false;
}
return !isActivityDestroyed(activity);
}

Expand Down

0 comments on commit 87bea40

Please sign in to comment.