// Path: lib_common/src/main/java/com/guiying/module/common/utils/Utils.java
// public class Utils {
// 
//     private static Context context;
// 
//     private Utils() {
//         throw new UnsupportedOperationException("u can't instantiate me...");
//     }
// 
//     /**
//      * 初始化工具类
//      *
//      * @param context 上下文
//      */
//     public static void init(Context context) {
//         Utils.context = context.getApplicationContext();
//     }
// 
//     /**
//      * 获取ApplicationContext
//      *
//      * @return ApplicationContext
//      */
//     public static Context getContext() {
//         if (context != null) return context;
//         throw new NullPointerException("u should init first");
//     }
// 
//     /**
//      * View获取Activity的工具
//      *
//      * @param view view
//      * @return Activity
//      */
//     public static
//     @NonNull
//     Activity getActivity(View view) {
//         Context context = view.getContext();
// 
//         while (context instanceof ContextWrapper) {
//             if (context instanceof Activity) {
//                 return (Activity) context;
//             }
//             context = ((ContextWrapper) context).getBaseContext();
//         }
// 
//         throw new IllegalStateException("View " + view + " is not attached to an Activity");
//     }
// 
//     /**
//      * 全局获取String的方法
//      *
//      * @param id 资源Id
//      * @return String
//      */
//     public static String getString(@StringRes int id) {
//         return context.getResources().getString(id);
//     }
// 
//     /**
//      * 判断App是否是Debug版本
//      *
//      * @return {@code true}: 是<br>{@code false}: 否
//      */
//     public static boolean isAppDebug() {
//         if (StringUtils.isSpace(context.getPackageName())) return false;
//         try {
//             PackageManager pm = context.getPackageManager();
//             ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
//             return ai != null && (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//             return false;
//         }
//     }
// 
// 
//     /**
//      * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
//      * performed by the {@code fragmentManager}.
//      */
//     public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
//                                              @NonNull Fragment fragment, int frameId) {
//         checkNotNull(fragmentManager);
//         checkNotNull(fragment);
//         FragmentTransaction transaction = fragmentManager.beginTransaction();
//         transaction.add(frameId, fragment);
//         transaction.commit();
//     }
// 
// 
//     public static <T> T checkNotNull(T obj) {
//         if (obj == null) {
//             throw new NullPointerException();
//         }
//         return obj;
//     }
// 
// }


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.guiying.module.common.utils.Utils;
package com.guiying.module.common.glide;



/**
 * <p> 图片加载工具类</p>
 *
 * @name ImageUtils
 */
public class ImageUtils {

    /**
     * 默认加载
     */
    public static void loadImageView(String path, ImageView mImageView) {
        Glide.with(mImageView.getContext()).load(path).into(mImageView);
    }

    public static void loadImageWithError(String path, int errorRes, ImageView mImageView) {
        Glide.with(mImageView.getContext())
                .load(path)
                .crossFade()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(errorRes)
                .into(mImageView);
    }

    /**
     * 设置加载中以及加载失败图片
     */
    public static void loadImageWithLoading(String path, ImageView mImageView, int lodingImage, int errorRes) {
        Glide.with(mImageView.getContext()).load(path).placeholder(lodingImage).
                error(errorRes).into(mImageView);
    }

    /**
     * 设置加载动画
     * api也提供了几个常用的动画：比如crossFade()
     */
    public static void loadImageViewAnim(String path, int anim, ImageView mImageView) {
        Glide.with(mImageView.getContext()).load(path).animate(anim).into(mImageView);
    }


    /**
     * 加载为bitmap
     *
     * @param path     图片地址
     * @param listener 回调
     */
    public static void loadBitMap(String path, final onLoadBitmap listener) {
// Path: lib_common/src/main/java/com/guiying/module/common/utils/Utils.java
// public class Utils {
// 
//     private static Context context;
// 
//     private Utils() {
//         throw new UnsupportedOperationException("u can't instantiate me...");
//     }
// 
//     /**
//      * 初始化工具类
//      *
//      * @param context 上下文
//      */
//     public static void init(Context context) {
//         Utils.context = context.getApplicationContext();
//     }
// 
//     /**
//      * 获取ApplicationContext
//      *
//      * @return ApplicationContext
//      */
//     public static Context getContext() {
//         if (context != null) return context;
//         throw new NullPointerException("u should init first");
//     }
// 
//     /**
//      * View获取Activity的工具
//      *
//      * @param view view
//      * @return Activity
//      */
//     public static
//     @NonNull
//     Activity getActivity(View view) {
//         Context context = view.getContext();
// 
//         while (context instanceof ContextWrapper) {
//             if (context instanceof Activity) {
//                 return (Activity) context;
//             }
//             context = ((ContextWrapper) context).getBaseContext();
//         }
// 
//         throw new IllegalStateException("View " + view + " is not attached to an Activity");
//     }
// 
//     /**
//      * 全局获取String的方法
//      *
//      * @param id 资源Id
//      * @return String
//      */
//     public static String getString(@StringRes int id) {
//         return context.getResources().getString(id);
//     }
// 
//     /**
//      * 判断App是否是Debug版本
//      *
//      * @return {@code true}: 是<br>{@code false}: 否
//      */
//     public static boolean isAppDebug() {
//         if (StringUtils.isSpace(context.getPackageName())) return false;
//         try {
//             PackageManager pm = context.getPackageManager();
//             ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
//             return ai != null && (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//             return false;
//         }
//     }
// 
// 
//     /**
//      * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
//      * performed by the {@code fragmentManager}.
//      */
//     public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
//                                              @NonNull Fragment fragment, int frameId) {
//         checkNotNull(fragmentManager);
//         checkNotNull(fragment);
//         FragmentTransaction transaction = fragmentManager.beginTransaction();
//         transaction.add(frameId, fragment);
//         transaction.commit();
//     }
// 
// 
//     public static <T> T checkNotNull(T obj) {
//         if (obj == null) {
//             throw new NullPointerException();
//         }
//         return obj;
//     }
// 
// }


// Path: lib_common/src/main/java/com/guiying/module/common/glide/ImageUtils.java
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.guiying.module.common.utils.Utils;

package com.guiying.module.common.glide;



/**
 * <p> 图片加载工具类</p>
 *
 * @name ImageUtils
 */
public class ImageUtils {

    /**
     * 默认加载
     */
    public static void loadImageView(String path, ImageView mImageView) {
        Glide.with(mImageView.getContext()).load(path).into(mImageView);
    }

    public static void loadImageWithError(String path, int errorRes, ImageView mImageView) {
        Glide.with(mImageView.getContext())
                .load(path)
                .crossFade()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(errorRes)
                .into(mImageView);
    }

    /**
     * 设置加载中以及加载失败图片
     */
    public static void loadImageWithLoading(String path, ImageView mImageView, int lodingImage, int errorRes) {
        Glide.with(mImageView.getContext()).load(path).placeholder(lodingImage).
                error(errorRes).into(mImageView);
    }

    /**
     * 设置加载动画
     * api也提供了几个常用的动画：比如crossFade()
     */
    public static void loadImageViewAnim(String path, int anim, ImageView mImageView) {
        Glide.with(mImageView.getContext()).load(path).animate(anim).into(mImageView);
    }


    /**
     * 加载为bitmap
     *
     * @param path     图片地址
     * @param listener 回调
     */
    public static void loadBitMap(String path, final onLoadBitmap listener) {
        Glide.with(Utils.getContext()).load(path).asBitmap().into(new SimpleTarget<Bitmap>() {