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

修复图片选中时的动画闪烁问题,调整一些UI #212

Open
wants to merge 2 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
24 changes: 12 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.lzy.imagepickerdemo"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand All @@ -20,17 +20,17 @@ android {
}

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'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:recyclerview-v7:26.0.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'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'org.xutils:xutils:3.3.36'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

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

//compile 'com.lzy.widget:imagepicker:0.6.0'
compile project(':imagepicker')
implementation project(':imagepicker')
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.1.0-beta1'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand All @@ -17,6 +18,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 19 17:17:17 CST 2017
#Wed Jan 31 14:59:22 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
16 changes: 8 additions & 8 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
Expand All @@ -20,10 +20,10 @@ android {
}

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.chrisbanes.photoview:library:1.2.4'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.github.chrisbanes.photoview:library:1.2.4'
}

//apply from: '../bintray.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ImageItem implements Serializable, Parcelable {
public boolean equals(Object o) {
if (o instanceof ImageItem) {
ImageItem item = (ImageItem) o;
return this.path.equalsIgnoreCase(item.path) && this.addTime == item.addTime;
return this.path.equalsIgnoreCase(item.path) ;
}

return super.equals(o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
Expand Down Expand Up @@ -240,6 +241,7 @@ public void onImagesLoaded(List<ImageFolder> imageFolders) {
// mImageGridAdapter.setOnImageItemClickListener(this);
mRecyclerAdapter.setOnImageItemClickListener(this);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
((SimpleItemAnimator)mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(3, Utils.dp2px(this, 2), false));
mRecyclerView.setAdapter(mRecyclerAdapter);
mImageFolderAdapter.refreshData(imageFolders);
Expand Down Expand Up @@ -333,39 +335,20 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//发送广播通知图片增加了
ImagePicker.galleryAddPic(this, imagePicker.getTakeImageFile());

/**
* 2017-03-21 对机型做旋转处理
*/
String path = imagePicker.getTakeImageFile().getAbsolutePath();
// int degree = BitmapUtil.getBitmapDegree(path);
// if (degree != 0){
// Bitmap bitmap = BitmapUtil.rotateBitmapByDegree(path,degree);
// if (bitmap != null){
// File file = new File(path);
// try {
// FileOutputStream bos = new FileOutputStream(file);
// bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
// bos.flush();
// bos.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }

ImageItem imageItem = new ImageItem();
imageItem.path = path;
imagePicker.clearSelectedImages();
//imagePicker.clearSelectedImages();
imagePicker.addSelectedImageItem(0, imageItem, true);
if (imagePicker.isCrop()) {
Intent intent = new Intent(ImageGridActivity.this, ImageCropActivity.class);
startActivityForResult(intent, ImagePicker.REQUEST_CODE_CROP); //单选需要裁剪,进入裁剪界面
} else {
} /*else {
Intent intent = new Intent();
intent.putExtra(ImagePicker.EXTRA_RESULT_ITEMS, imagePicker.getSelectedImages());
setResult(ImagePicker.RESULT_CODE_ITEMS, intent); //单选不需要裁剪,返回数据
finish();
}
//finish();
}*/
} else if (directPhoto) {
finish();
}
Expand Down
28 changes: 13 additions & 15 deletions imagepicker/src/main/res/layout/activity_image_grid.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<LinearLayout android:id="@+id/content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical">

<include
android:id="@+id/top_bar"
layout="@layout/include_top_bar"/>
layout="@layout/include_top_bar" />

<RelativeLayout
android:layout_width="match_parent"
Expand All @@ -18,11 +18,9 @@
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="50dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingTop="2dp"/>
android:paddingBottom="49dp"
android:paddingTop="1dp"
android:scrollbars="vertical" />

<RelativeLayout
android:id="@+id/footer_bar"
Expand All @@ -49,7 +47,7 @@
android:maxLines="1"
android:text="@string/ip_all_images"
android:textColor="#CFCFCF"
android:textSize="16sp"/>
android:textSize="16sp" />

<ImageView
android:layout_width="wrap_content"
Expand All @@ -58,7 +56,7 @@
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_toRightOf="@id/tv_dir"
android:src="@mipmap/text_indicator"/>
android:src="@mipmap/text_indicator" />

</RelativeLayout>

Expand All @@ -75,7 +73,7 @@
android:text="预览(3)"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="16sp"/>
android:textSize="16sp" />

</RelativeLayout>
</RelativeLayout>
Expand Down
6 changes: 2 additions & 4 deletions imagepicker/src/main/res/layout/pop_folder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
android:orientation="vertical">

<FrameLayout
android:id="@+id/masker"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#A000"
android:layout_weight="1">

<!-- <View
<View
android:id="@+id/masker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A000"/>
-->

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
Expand Down