tgdrcyvq.zip

  • is863f
    了解作者
  • C/C++
    开发工具
  • 4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2018-10-27 12:25
    上传日期
ssm开发实现简单的oa办公管理系统,模板是网上下载,后端代码自己实现
tgdrcyvq.zip
  • GlideImageLoader.java
    10.5KB
  • InfoPageApi.java
    341B
  • BaseActivity.java
    3.8KB
  • PrimitiveConverterFactory.java
    2KB
  • AttitudeApi.java
    709B
内容介绍
package com.caij.emore.image.base; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.util.SparseArray; import android.widget.ImageView; import com.bumptech.glide.DrawableTypeRequest; import com.bumptech.glide.GenericRequestBuilder; import com.bumptech.glide.Glide; import com.bumptech.glide.load.MultiTransformation; import com.bumptech.glide.load.Transformation; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.FitCenter; import com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapper; import com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperTransformation; import com.caij.emore.image.glide.CropCircleTransformation; import com.caij.emore.image.glide.MaskTransformation; import com.caij.emore.image.glide.CropTopTransformation; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; /** * Created by Ca1j on 2016/12/29. */ public class GlideImageLoader extends BaseImageLoader { private CenterCrop mBitmapCenterCrop; private FitCenter mBitmapFitCenter; private CropCircleTransformation mBitmapCropCircle; private CropTopTransformation mBitmapCropTop; private MultiTransformation<Bitmap> mCropCircleBitmapMultiTransformation; private GifBitmapWrapperTransformation mDrawableCenterCrop; private GifBitmapWrapperTransformation mDrawableFitCenter; private GifBitmapWrapperTransformation mDrawableCropTop; private MultiTransformation<GifBitmapWrapper> mDrawableCropCircleMultiTransformation; private SparseArray<Transformation<GifBitmapWrapper>> mMaskDrawableTransformationSparseArray; private SparseArray<Transformation<Bitmap>> mMaskBitmapTransformationSparseArray; public GlideImageLoader() { mMaskDrawableTransformationSparseArray = new SparseArray<>(); mMaskBitmapTransformationSparseArray = new SparseArray<>(); } @SuppressWarnings("unchecked") @Override protected void internalLoadImage(Context context, ImageView view, String url, Drawable placeholder, ImageConfig imageConfig) { GenericRequestBuilder requestBuilder; if (imageConfig.isSupportGif()) { requestBuilder = load(context, url).transform(getDrawableTransformation(context, imageConfig)); }else { requestBuilder = load(context, url).asBitmap().transform(getBitmapTransformation(context, imageConfig)); } if (!imageConfig.isAnimate()) { requestBuilder.dontAnimate(); } if (imageConfig.getWidth() > 0 && imageConfig.getHeight() > 0) { requestBuilder.override(imageConfig.getWidth(), imageConfig.getHeight()); } requestBuilder.placeholder(placeholder) .diskCacheStrategy(getDiskCacheType(imageConfig.getDiskCacheStrategy())) .priority(getPriority(imageConfig.getPriority())) .skipMemoryCache(!imageConfig.isCacheMemory()) .into(view); } @Override public File getFile(Context context, String url, int width, int height) throws ExecutionException, InterruptedException { return load(context, url).downloadOnly(width, height).get(); } private DrawableTypeRequest<String> load(Context context, String url) { return Glide.with(context).load(url); } @Override public void onTrimMemory(Context context, int level) { Glide.with(context).onTrimMemory(level); } @Override public void onLowMemory(Context context) { Glide.with(context).onLowMemory(); } private Transformation<Bitmap> getBitmapTransformation(Context context, ImageConfig imageConfig) { if (imageConfig.getScaleType() == ScaleType.CIRCLE) { return bitmapCropCircle(context); }else if (imageConfig.getScaleType() == ScaleType.FIT_CENTER) { return bitmapFitCenter(context); }else if (imageConfig.getScaleType() == ScaleType.CENTER_CROP) { return bitmapCenterCrop(context); }else if (imageConfig.getScaleType() == ScaleType.MASK) { return bitmapMask(context, imageConfig.getMaskResourceId()); }else if (imageConfig.getScaleType() == ScaleType.TOP) { return bitmapCropTop(context); } return bitmapCenterCrop(context); } private Transformation<GifBitmapWrapper> getDrawableTransformation(Context context, ImageConfig imageConfig) { if (imageConfig.getScaleType() == ScaleType.CIRCLE) { return drawableCropCircle(context); }else if (imageConfig.getScaleType() == ScaleType.FIT_CENTER) { return drawableFitCenter(context); }else if (imageConfig.getScaleType() == ScaleType.CENTER_CROP) { return drawableCenterCrop(context); }else if (imageConfig.getScaleType() == ScaleType.MASK) { return drawableMask(context, imageConfig.getMaskResourceId()); }else if (imageConfig.getScaleType() == ScaleType.TOP) { return drawableCropTop(context); } return drawableCenterCrop(context); } private Transformation<GifBitmapWrapper> drawableCropCircle(Context context) { if (mDrawableCropCircleMultiTransformation == null) { List<GifBitmapWrapperTransformation> gifBitmapWrapperTransformations = new ArrayList<>(2); gifBitmapWrapperTransformations.add(new GifBitmapWrapperTransformation(Glide.get(context).getBitmapPool(), bitmapCenterCrop(context))); gifBitmapWrapperTransformations.add(new GifBitmapWrapperTransformation(Glide.get(context).getBitmapPool(), cropCircle(context))); mDrawableCropCircleMultiTransformation = new MultiTransformation<GifBitmapWrapper>(gifBitmapWrapperTransformations); } return mDrawableCropCircleMultiTransformation; } private Transformation<Bitmap> bitmapCropCircle(Context context) { if (mCropCircleBitmapMultiTransformation == null) { List<Transformation<Bitmap>> transformations = new ArrayList<>(2); transformations.add(bitmapCenterCrop(context)); transformations.add(cropCircle(context)); mCropCircleBitmapMultiTransformation = new MultiTransformation<Bitmap>(transformations); } return mCropCircleBitmapMultiTransformation; } private CropCircleTransformation cropCircle(Context context) { if (mBitmapCropCircle == null) { mBitmapCropCircle = new CropCircleTransformation(context); } return mBitmapCropCircle; } private GifBitmapWrapperTransformation drawableCenterCrop(Context context) { if (mDrawableCenterCrop == null) { mDrawableCenterCrop = new GifBitmapWrapperTransformation(Glide.get(context).getBitmapPool(), bitmapCenterCrop(context)); } return mDrawableCenterCrop; } private CenterCrop bitmapCenterCrop(Context context) { if (mBitmapCenterCrop == null) { mBitmapCenterCrop = new CenterCrop(context); } return mBitmapCenterCrop; } private FitCenter bitmapFitCenter(Context context) { if (mBitmapFitCenter == null) { mBitmapFitCenter = new FitCenter(context); } return mBitmapFitCenter; } private GifBitmapWrapperTransformation drawableFitCenter(Context context) { if (mDrawableFitCenter == null) { mDrawableFitCenter = new GifBitmapWrapperTransformation(Glide.get(context).getBitmapPool(), bitmapFitCenter(context)); } return mDrawableFitCenter; } private CropTopTransformation bitmapCropTop(Context context) { if (mBitmapCropTop == null) { mBitmapCropTop = new CropTopTransformation(context); } return mBitmapCropTop; } private GifBitmapWrapper
评论
    相关推荐