# 88ir-android **Repository Path**: hf_2020/88ir-android ## Basic Information - **Project Name**: 88ir-android - **Description**: No description available - **Primary Language**: Android - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-10-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## [图片加载库Glide的封装GlideImageView介绍](#glideimageview) 1、布局中使用GlideImageView替代ImageView 2、使用 简单使用: ```java mGlideImageView.enableState(true).load(url); ``` 监听图片加载: ```java mGlideImageView.centerCrop().error(R.mipmap.image_load_err).diskCacheStrategy(DiskCacheStrategy.NONE).load(girl, R.color.placeholder, (isComplete, percentage, bytesRead, totalBytes) -> { if (isComplete) { progressView1.setVisibility(View.GONE); } else { progressView1.setVisibility(View.VISIBLE); progressView1.setProgress(percentage); } }); ``` 设置图片高斯模糊: ```java mGlideImageView.fitCenter().load(url, R.mipmap.image_loading, new BlurTransformation(this, 25, 1)); ``` ## [UCrop的使用](#ucrop) 1、传入需要剪切图片的uri ```java private void startCrop(@NonNull Uri uri) { String destinationFileName = System.currentTimeMillis() + ".jpg"; UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(getCacheDir(), destinationFileName))); uCrop = advancedConfig(uCrop); uCrop.start(this); } private UCrop advancedConfig(@NonNull UCrop uCrop) { uCrop = uCrop.useSourceImageAspectRatio(); UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setCompressionQuality(100); options.setHideBottomControls(false); options.setFreeStyleCropEnabled(true); return uCrop.withOptions(options); } ``` 2、获取剪切后图片路径 ```java @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case UCrop.REQUEST_CROP: handleCropResult(data); break; default: break; } } } private void handleCropResult(@NonNull Intent result) { final Uri resultUri = UCrop.getOutput(result); if (resultUri != null) { showCard(resultUri.getPath()); } else { Toast.makeText(this, R.string.toast_cannot_retrieve_cropped_image, Toast.LENGTH_SHORT).show(); } } ``` ## [Logger的使用](https://github.com/orhanobut/logger) And use ```java Logger.d("hello"); ``` ### Output ### Options ```java Logger.d("debug"); Logger.e("error"); Logger.w("warning"); Logger.v("verbose"); Logger.i("information"); Logger.wtf("What a Terrible Failure"); ``` String format arguments are supported ```java Logger.d("hello %s", "world"); ``` Collections are supported (only available for debug logs) ```java Logger.d(MAP); Logger.d(SET); Logger.d(LIST); Logger.d(ARRAY); ``` Json and Xml support (output will be in debug level) ```java Logger.json(JSON_CONTENT); Logger.xml(XML_CONTENT); ```