Skip to content

Commit

Permalink
Merge pull request #193 from z-chu/master
Browse files Browse the repository at this point in the history
调整UI,真正的完全仿微信
  • Loading branch information
jeasonlzy committed Aug 30, 2017
2 parents 3fc97e0 + 6d3dc88 commit 880e72b
Show file tree
Hide file tree
Showing 64 changed files with 645 additions and 586 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/com/lzy/imagepickerdemo/GApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
public class GApp extends Application {

public static DisplayImageOptions imageLoaderOptions = new DisplayImageOptions.Builder()//
.showImageOnLoading(R.mipmap.default_image) //设置图片在下载期间显示的图片
.showImageForEmptyUri(R.mipmap.default_image) //设置图片Uri为空或是错误的时候显示的图片
.showImageOnFail(R.mipmap.default_image) //设置图片加载/解码过程中错误时候显示的图片
.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.mipmap.default_image) //下载中显示的图片
.setFailureDrawableId(R.mipmap.default_image) //下载失败显示的图片
.setLoadingDrawableId(R.drawable.ic_default_image) //下载中显示的图片
.setFailureDrawableId(R.drawable.ic_default_image) //下载失败显示的图片
.build(); //得到ImageOptions对象

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ public void displayImage(Activity activity, String path, ImageView imageView, in

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

@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
Glide.with(activity) //配置上下文
.load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@ public class PicassoImageLoader implements ImageLoader {
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)//
.placeholder(R.drawable.ic_default_image)//
.error(R.drawable.ic_default_image)//
.resize(width, height)//
.centerInside()//
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)//
.into(imageView);
}

@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
Picasso.with(activity)//
.load(Uri.fromFile(new File(path)))//
.resize(width, height)//
.centerInside()//
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public void displayImage(Activity activity, String path, ImageView imageView, in
com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), imageView, size);
}

@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
ImageSize size = new ImageSize(width, height);
com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), imageView, size);
}

@Override
public void clearMemoryCache() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ public class XUtils3ImageLoader implements ImageLoader {
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
ImageOptions options = new ImageOptions.Builder()//
.setLoadingDrawableId(R.mipmap.default_image)//
.setFailureDrawableId(R.mipmap.default_image)//
.setLoadingDrawableId(R.drawable.ic_default_image)//
.setFailureDrawableId(R.drawable.ic_default_image)//
.setConfig(Bitmap.Config.RGB_565)//
.setSize(width, height)//
.setCrop(false)//
.setUseMemCache(true)//
.build();
x.image().bind(imageView, Uri.fromFile(new File(path)).toString(), options);
}

@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
ImageOptions options = new ImageOptions.Builder()//
.setConfig(Bitmap.Config.RGB_565)//
.setSize(width, height)//
.setCrop(false)//
Expand Down
1 change: 1 addition & 0 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
Expand Down
4 changes: 4 additions & 0 deletions imagepicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
android:configChanges="orientation|screenSize"
android:theme="@style/ImagePickerThemeFullScreen"/>

<activity
android:name=".ui.ImagePreviewDelActivity"
android:theme="@style/ImagePickerThemeFullScreen"/>

<provider
android:authorities="${applicationId}.provider"
android:name=".ImagePickerProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (data.getCount() > 0) {
//构造所有图片的集合
ImageFolder allImagesFolder = new ImageFolder();
allImagesFolder.name = activity.getResources().getString(R.string.all_images);
allImagesFolder.name = activity.getResources().getString(R.string.ip_all_images);
allImagesFolder.path = "/";
allImagesFolder.cover = allImages.get(0);
allImagesFolder.images = allImages;
Expand Down
40 changes: 40 additions & 0 deletions imagepicker/src/main/java/com/lzy/imagepicker/ImagePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
Expand Down Expand Up @@ -352,4 +353,43 @@ private void notifyImageSelectedChanged(int position, ImageItem item, boolean is
}
}

/**
* 用于手机内存不足,进程被系统回收,重启时的状态恢复
*/
public void restoreInstanceState(Bundle savedInstanceState) {
cropCacheFolder = (File) savedInstanceState.getSerializable("cropCacheFolder");
takeImageFile = (File) savedInstanceState.getSerializable("takeImageFile");
imageLoader = (ImageLoader) savedInstanceState.getSerializable("imageLoader");
style = (CropImageView.Style) savedInstanceState.getSerializable("style");
multiMode = savedInstanceState.getBoolean("multiMode");
crop = savedInstanceState.getBoolean("crop");
showCamera = savedInstanceState.getBoolean("showCamera");
isSaveRectangle = savedInstanceState.getBoolean("isSaveRectangle");
selectLimit = savedInstanceState.getInt("selectLimit");
outPutX = savedInstanceState.getInt("outPutX");
outPutY = savedInstanceState.getInt("outPutY");
focusWidth = savedInstanceState.getInt("focusWidth");
focusHeight = savedInstanceState.getInt("focusHeight");
}

/**
* 用于手机内存不足,进程被系统回收时的状态保存
*/
public void saveInstanceState(Bundle outState) {
outState.putSerializable("cropCacheFolder", cropCacheFolder);
outState.putSerializable("takeImageFile", takeImageFile);
outState.putSerializable("imageLoader", imageLoader);
outState.putSerializable("style", style);
outState.putBoolean("multiMode", multiMode);
outState.putBoolean("crop", crop);
outState.putBoolean("showCamera", showCamera);
outState.putBoolean("isSaveRectangle", isSaveRectangle);
outState.putInt("selectLimit", selectLimit);
outState.putInt("outPutX", outPutX);
outState.putInt("outPutY", outPutY);
outState.putInt("focusWidth", focusWidth);
outState.putInt("focusHeight", focusHeight);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;


/**
* ================================================
* 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216
Expand Down Expand Up @@ -78,7 +79,7 @@ public View getView(int position, View convertView, ViewGroup parent) {

ImageFolder folder = getItem(position);
holder.folderName.setText(folder.name);
holder.imageCount.setText(mActivity.getString(R.string.folder_image_count, folder.images.size()));
holder.imageCount.setText(mActivity.getString(R.string.ip_folder_image_count, folder.images.size()));
imagePicker.getImageLoader().displayImage(mActivity, folder.cover.path, holder.cover, mImageSize, mImageSize);

if (lastSelected == position) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setPhotoViewClickListener(PhotoViewClickListener listener) {
public Object instantiateItem(ViewGroup container, int position) {
PhotoView photoView = new PhotoView(mActivity);
ImageItem imageItem = images.get(position);
imagePicker.getImageLoader().displayImage(mActivity, imageItem.path, photoView, screenWidth, screenHeight);
imagePicker.getImageLoader().displayImagePreview(mActivity, imageItem.path, photoView, screenWidth, screenHeight);
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
Expand Down
Loading

0 comments on commit 880e72b

Please sign in to comment.