ugxemnql.zip

  • taE2hv
    了解作者
  • Windows_Unix
    开发工具
  • 6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2018-10-28 14:17
    上传日期
ssh实现简单的论坛帖子增删改查,分页,回复帖子的项目实例
ugxemnql.zip
  • OkHttpClientProvider.java
    1.6KB
  • ImageUtil.java
    14.1KB
  • AppAboutPresentImp.java
    718B
  • ClickableSpan.java
    2KB
  • StatusMentionPresentImp.java
    4.6KB
内容介绍
package com.caij.emore.utils; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.media.ExifInterface; import android.net.Uri; import android.os.Environment; import com.bumptech.glide.load.resource.bitmap.ImageHeaderParser; import com.caij.emore.utils.okhttp.OkHttpClientProvider; import com.caij.lib.util.FileUtil; import com.caij.lib.util.LogUtil; import com.caij.lib.util.MD5Util; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.concurrent.TimeUnit; import okhttp3.Call; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.ResponseBody; import static android.media.ExifInterface.ORIENTATION_FLIP_VERTICAL; import static android.media.ExifInterface.ORIENTATION_NORMAL; import static android.media.ExifInterface.ORIENTATION_ROTATE_180; import static android.media.ExifInterface.ORIENTATION_ROTATE_270; import static android.media.ExifInterface.ORIENTATION_ROTATE_90; import static android.media.ExifInterface.ORIENTATION_TRANSPOSE; import static android.media.ExifInterface.ORIENTATION_TRANSVERSE; import static android.media.ExifInterface.TAG_ORIENTATION; /** * Created by Caij on 2016/6/7. */ public class ImageUtil { public interface ImageType { public static final String GIF = "gif"; /** JPG type. */ public static final String JPEG = "jpeg"; /** PNG type with alpha. */ public static final String PNG = "png"; /** Unrecognized type. */ public static final String UNKNOWN = "png"; } private final static String PATTERN = "yyyyMMddHH_mmss"; private static final int TARGET_WIDTH = 1080; private static final int TARGET_HEIGHT = 1920; private static final int QUALITY_MEDIUM = 40; private static final int QUALITY_LOW = 20; public static BitmapFactory.Options getImageOptions(String url) throws IOException { OkHttpClient okHttpClient = OkHttpClientProvider.getDefaultOkHttpClient(false); okHttpClient = okHttpClient.newBuilder().readTimeout(3000, TimeUnit.MILLISECONDS) .writeTimeout(3000, TimeUnit.MILLISECONDS).build(); Request.Builder okHttpRequestBuilder = new Request.Builder(); okHttpRequestBuilder.url(url); Request okHttpRequest = okHttpRequestBuilder.build(); Call okHttpCall = okHttpClient.newCall(okHttpRequest); ResponseBody responseBody = okHttpCall.execute().body(); InputStream inputStream = responseBody.byteStream(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(inputStream, null, options); responseBody.close(); return options; } public static BitmapFactory.Options getImageOptions(File file) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(file.getAbsolutePath(), options); return options; } public static Bitmap zoomBitmap(Bitmap source, int width) { Matrix matrix = new Matrix(); float scale = (float)width * 1.0F / (float)source.getWidth(); matrix.setScale(scale, scale); Bitmap result = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); if (result != source) { source.recycle(); } return result; } public static String getImageType(File file) throws IOException { FileInputStream fileInputStream = new FileInputStream(file); ImageHeaderParser imageHeaderParser= new ImageHeaderParser(fileInputStream); ImageHeaderParser.ImageType imageType = imageHeaderParser.getType(); switch (imageType) { case GIF: return ImageType.GIF; case JPEG: return ImageType.JPEG; case PNG_A: return ImageType.PNG; case PNG: return ImageType.PNG; case UNKNOWN: return ImageType.UNKNOWN; } return ImageType.UNKNOWN; } public static String createCameraImagePath(Context context) { String imageName = createImageName("jpg"); String externalStorageState = Environment.getExternalStorageState(); if (externalStorageState.equals(Environment.MEDIA_MOUNTED)) { File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/" + imageName); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } return file.getAbsolutePath(); } else { return context.getFilesDir() + "/" +imageName; } } public static String createImageName(String type) { String timeStamp = new SimpleDateFormat(PATTERN, Locale.CHINA).format(new Date()); return "IMG_" + timeStamp + "." + type; } public static String compressImage(String sourcePath, Context context) throws IOException { String outPath = new File(CacheUtils.getCompressImageDir(context), MD5Util.string2MD5(sourcePath) + ".compress").getAbsolutePath(); compressImage(sourcePath, outPath); return outPath; } public static void compressImage(String sourcePath, String outPath) throws IOException { compressImage(sourcePath, outPath, TARGET_WIDTH, TARGET_HEIGHT); } public static void compressImage(String sourcePath, String outPath, int targetWidth, int targetHeight) throws IOException { File ourFile = new File(outPath); File sourceFile = new File(sourcePath); try { if (ourFile.exists()) { LogUtil.d("compressImage", "out file length %s", FileUtil.getFileSizeString(ourFile)); return; } if (!ourFile.getParentFile().exists()) { boolean isSuccess = ourFile.getParentFile().mkdirs(); if (!isSuccess) { throw new FileNotFoundException("文件夹创建失败"); } } LogUtil.d("compressImage", "source file length %s", FileUtil.getFileSizeString(sourceFile)); if (ImageType.GIF.equals(getImageType(sourceFile))) { FileUtil.copy(new File(sourcePath), new File(outPath)); LogUtil.d("compressImage", "source File file is gif "); return; } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(sourcePath, options); int rotation = getFileExifRotation(Uri.fromFile(sourceFile)); int inSampleSize; if (isLongImage(options.outWidth, options.outHeight)) { inSampleSize = calculateInSampleSize(options.outWidth, options.outHeight, targetWidth * 2, targetHeight * 2, rotation); }else { inSampleSize = calculateInSampleSize(options.outWidth, options.outHeight, targetWidth, targetHeight, rotation); } LogUtil.d("compressImage", "rotation %s, options.outWidth %s, options.outHeight %s", rotation, options.outWidth, options.outHeight); options.inJustDecodeBounds = false; options.inSampleSize = inSampleSize; LogUtil.d("compressImage", "inSampleSize %s", inSampleSize); Bitmap sourceBitmap = BitmapFactory.decodeFile(sourcePath, options); Bitmap rotationBitmap = sourceBitmap; if (rotation != 0 && rotation != 360) { Matrix matrix = new Matrix(); mat
评论
    相关推荐
    • 3DES加密算法源代码.rar
      DES加密源代码,用3DES加密算法。 加密强度高,到目前为止,还无人能够破解!
    • crc.zip
      CRC校验程序,使用了CRC-16和CRC-CCITT方法
    • rsa1.03.zip
      rsa算法实现,包含文档
    • fast-des3.0.tar.z
      des算法实现源码
    • des3_win32_vc.zip
      一个3des算法的库文件和使用库文件的例子
    • dcpcrypt.zip
      Delphi加密控件源码,包括对称钥匙加密控件和散列函数控件
    • rc.zip
      含有rc2、rc4、rc5、rc6算法的rc算法集合
    • oicqpass.zip
      读取OICQ用户保存在本地机器上的密码
    • elgamal.zip
      另一种公开密钥加密算法的Pascal实现和例子。实现了签名和确认
    • linuxscanners.zip
      linux下的端口扫描器