Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新库,添加英语适配,图片消失,裁剪锯齿,选中刷新 #270

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ImagePicker</name>
<comment>Project ImagePicker created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
# ImagePicker
Android自定义相册,完全仿微信UI,实现了拍照、图片选择(单选/多选)、 裁剪 、旋转、等功能。

### 由于个人时间有限,该项目停止维护
如果你发现有bug,或者好的建议,可以提merge request,我测试通过后会立即合并并发布新版本,确保该库处于可用的状态。

该项目参考了:

* [https://github.com/pengjianbo/GalleryFinal](https://github.com/pengjianbo/GalleryFinal)
* [https://github.com/easonline/AndroidImagePicker](https://github.com/easonline/AndroidImagePicker)

喜欢原作的可以去使用。同时欢迎大家下载体验本项目,如果使用过程中遇到什么问题,欢迎反馈。

## 联系方式
* email: [email protected]
* QQ群: 489873144 <a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=ba5dbb5115a165866ec77d96cb46685d1ad159ab765b796699d6763011ffe151"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="Android 格调小窝" title="Android 格调小窝"></a>(点击图标,可以直接加入,建议使用QQ群,邮箱使用较少,可能看的不及时)
* 如果遇到问题欢迎在群里提问,个人能力也有限,希望一起学习一起进步。

## 演示
![image](https://github.com/jeasonlzy/Screenshots/blob/master/ImagePicker/demo1.png)![image](https://github.com/jeasonlzy/Screenshots/blob/master/ImagePicker/demo2.gif)
![image](https://github.com/jeasonlzy/Screenshots/blob/master/ImagePicker/demo3.gif)![image](https://github.com/jeasonlzy/Screenshots/blob/master/ImagePicker/demo5.gif)

## 1.用法

使用前,对于Android Studio的用户,可以选择添加:
```java
compile 'com.lzy.widget:imagepicker:0.6.1' //指定版本
implementation 'com.mrtan.android:imagepicker:0.7.2'
```

## 2.功能和参数含义
Expand All @@ -49,25 +37,31 @@ Android自定义相册,完全仿微信UI,实现了拍照、图片选择(

更多使用,请下载demo参看源代码

1. 首先你需要继承 `com.lzy.imagepicker.loader.ImageLoader` 这个接口,实现其中的方法,比如以下代码是使用 `Picasso` 三方加载库实现的
1. 首先你需要继承 `com.lzy.imagepicker.loader.ImageLoader` 这个接口,实现其中的方法,比如以下代码是使用 `Glide` 三方加载库实现的
```java
public class PicassoImageLoader implements ImageLoader {
public class GlideImageLoader implements ImageLoader {

@Override
public void displayImage(Activity activity, Uri uri, ImageView imageView, int width, int height) {

GlideApp.with(activity) //配置上下文
.load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(R.drawable.ic_default_image) //设置错误图片
.placeholder(R.drawable.ic_default_image) //设置占位图片
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}

@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
Picasso.with(activity)//
                   .load(Uri.fromFile(new File(path)))//
.placeholder(R.mipmap.default_image)//
.error(R.mipmap.default_image)//
.resize(width, height)//
.centerInside()//
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)//
public void displayImagePreview(Activity activity, Uri uri, ImageView imageView, int width, int height) {
GlideApp.with(activity) //配置上下文
.load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}

@Override
public void clearMemoryCache() {
//这里是清除缓存的方法,根据需要自己实现
}
}
```
Expand Down Expand Up @@ -115,7 +109,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
if (data != null && requestCode == IMAGE_PICKER) {
ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
ArrayList<ImageItem> images = data.getParcelableArrayListExtra(ImagePicker.EXTRA_IMAGE_ITEMS);
MyAdapter adapter = new MyAdapter(images);
gridView.setAdapter(adapter);
} else {
Expand All @@ -127,7 +121,18 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

## 更新日志

V 0.7.1

* 修复AndroidQ 拍照问题
* 修复图片裁剪问题

V 0.7.0

* 适配 AndroidX
* 适配 AndroidQ

V 0.6.1

* [合并] [优化图片选择页UI, 适配预览页的横竖屏切换 #195](https://github.com/jeasonlzy/ImagePicker/pull/195)

V 0.6.0
Expand All @@ -150,29 +155,29 @@ V 0.5.1
* [更正] 由于原图功能其实还没有做,所以本版本隐去了原图的显示。以免用户误解原图问题。
* [修复] 使用RecyclerView替换GridView解决改变选中状态全局刷新的问题;
* [提示] 虽然本次解决了全局刷新,但是如果使用的是Picasso依然会出现重新加载一张图片的问题,这是Picasso自己的问题,建议使用Glide框架。

V 0.5.0
* [修复] 解决provider冲突问题;

V 0.4.8
* [修复] 解决demo中直接呼起相机并裁剪不会返回数据的bug,不需要这个功能的可以不更新;

V 0.4.7
* [新增] 新增可直接调起相机的功能;
* [修复] 解决可能和主项目provider冲突的潜在问题;
* [修复] 点击图片预览空指针崩溃问题;
* [修复] 使用Intent传值限制导致的崩溃问题;
* [修复] 部分机型拍照后图片旋转问题;
* [修复] 更改选择框图片背景为灰色,以免白色图看不清。

V 0.3.5
* [新增] 提供直接调起相机的方式,并可直接设置牌照是否裁剪;
* [修复] Android7.0设备调系统相机直接崩溃的问题;
* [注意] 如果出现 java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.SecurityException: Provider must not be exported,请直接clean再运行即可。

## Licenses
```
Copyright 2016 jeasonlzy(廖子尧)
Copyright 2019 freemrtan(谈晓龙)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
17 changes: 17 additions & 0 deletions app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions app/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
42 changes: 15 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "com.lzy.imagepickerdemo"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
signingConfigs {
release {
storeFile file('../release.jks')
storePassword 'VJP94nzjim'
keyAlias 'android'
keyPassword '6RHrfH6uir'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.xutils:xutils:3.3.36'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

compile 'com.lzy.widget:view-core:0.2.1'

//compile 'com.lzy.widget:imagepicker:0.6.1'
compile project(':imagepicker')
annotationProcessor deps.glide.compile
annotationProcessor deps.androidx.annotations
implementation deps.androidx.appCompat
implementation deps.androidx.annotations
implementation deps.androidx.recyclerView
implementation deps.glide.runtime
implementation project(':imagepicker')
}
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lzy.imagepickerdemo"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
Expand All @@ -8,7 +9,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:name=".GApp"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
>
<activity android:name=".ImagePickerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
27 changes: 0 additions & 27 deletions app/src/main/java/com/lzy/imagepickerdemo/GApp.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
package com.lzy.imagepickerdemo;

import android.app.Application;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import org.xutils.image.ImageOptions;
import org.xutils.x;

/**
* ================================================
Expand All @@ -21,27 +13,8 @@
*/
public class GApp extends Application {

public static DisplayImageOptions imageLoaderOptions = new DisplayImageOptions.Builder()//
.showImageOnLoading(R.drawable.ic_default_image) //设置图片在下载期间显示的图片
.showImageForEmptyUri(R.drawable.ic_default_image) //设置图片Uri为空或是错误的时候显示的图片
.showImageOnFail(R.drawable.ic_default_image) //设置图片加载/解码过程中错误时候显示的图片
.cacheInMemory(true) //设置下载的图片是否缓存在内存中
.cacheOnDisk(true) //设置下载的图片是否缓存在SD卡中
.build(); //构建完成

public static ImageOptions xUtilsOptions = new ImageOptions.Builder()//
.setIgnoreGif(false) //是否忽略GIF格式的图片
.setImageScaleType(ImageView.ScaleType.FIT_CENTER) //缩放模式
.setLoadingDrawableId(R.drawable.ic_default_image) //下载中显示的图片
.setFailureDrawableId(R.drawable.ic_default_image) //下载失败显示的图片
.build(); //得到ImageOptions对象

@Override
public void onCreate() {
super.onCreate();
ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this);

ImageLoader.getInstance().init(config); //UniversalImageLoader初始化
x.Ext.init(this); //xUtils3初始化
}
}
Loading