From 3c330b94a9a318fb76df754454e755f749948786 Mon Sep 17 00:00:00 2001
From: LiuJun
Date: Thu, 3 Jan 2019 17:05:24 +0800
Subject: [PATCH 1/6] Add Fresco support
---
.../com/yanzhenjie/album/AlbumLoader.java | 25 +++-
.../album/app/album/AlbumActivity.java | 2 +-
.../album/app/gallery/GalleryView.java | 14 ++-
.../album/app/gallery/PreviewAdapter.java | 45 ++-----
.../widget/{photoview => }/FixViewPager.java | 2 +-
.../res/layout/album_activity_gallery.xml | 2 +-
build.gradle | 3 +
sample/build.gradle | 7 +-
.../yanzhenjie/album/sample/Application.java | 18 +--
.../yanzhenjie/album/sample/FrescoLoader.java | 119 ++++++++++++++++++
.../yanzhenjie/album/sample/MediaLoader.java | 55 ++++++--
.../sample}/photoview/AttacherImageView.java | 2 +-
.../album/sample}/photoview/Compat.java | 2 +-
.../photoview/DefaultOnDoubleTapListener.java | 2 +-
.../album/sample}/photoview/IPhotoView.java | 2 +-
.../sample}/photoview/PhotoViewAttacher.java | 10 +-
.../gestures/CupcakeGestureDetector.java | 2 +-
.../gestures/EclairGestureDetector.java | 4 +-
.../gestures/FroyoGestureDetector.java | 2 +-
.../photoview/gestures/GestureDetector.java | 2 +-
.../photoview/gestures/OnGestureListener.java | 2 +-
.../gestures/VersionedGestureDetector.java | 2 +-
.../scrollerproxy/GingerScroller.java | 2 +-
.../photoview/scrollerproxy/IcsScroller.java | 2 +-
.../scrollerproxy/PreGingerScroller.java | 2 +-
.../scrollerproxy/ScrollerProxy.java | 2 +-
.../src/main/res/layout/activity_camera.xml | 7 +-
.../main/res/layout/activity_list_content.xml | 2 +-
.../res/layout/album_item_content_image.xml | 54 ++++++++
.../res/layout/album_item_content_video.xml | 67 ++++++++++
.../res/layout/album_item_dialog_folder.xml | 53 ++++++++
.../main/res/layout/item_content_image.xml | 20 +--
.../main/res/layout/item_content_video.xml | 13 +-
33 files changed, 451 insertions(+), 97 deletions(-)
rename album/src/main/java/com/yanzhenjie/album/widget/{photoview => }/FixViewPager.java (96%)
create mode 100644 sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/AttacherImageView.java (95%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/Compat.java (96%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/DefaultOnDoubleTapListener.java (98%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/IPhotoView.java (99%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/PhotoViewAttacher.java (99%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/CupcakeGestureDetector.java (98%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/EclairGestureDetector.java (96%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/FroyoGestureDetector.java (97%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/GestureDetector.java (93%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/OnGestureListener.java (93%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/gestures/VersionedGestureDetector.java (96%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/scrollerproxy/GingerScroller.java (96%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/scrollerproxy/IcsScroller.java (93%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/scrollerproxy/PreGingerScroller.java (96%)
rename {album/src/main/java/com/yanzhenjie/album/widget => sample/src/main/java/com/yanzhenjie/album/sample}/photoview/scrollerproxy/ScrollerProxy.java (96%)
create mode 100644 sample/src/main/res/layout/album_item_content_image.xml
create mode 100644 sample/src/main/res/layout/album_item_content_video.xml
create mode 100644 sample/src/main/res/layout/album_item_dialog_folder.xml
diff --git a/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java b/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
index d6872cd..03c65bf 100644
--- a/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
+++ b/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
@@ -15,6 +15,10 @@
*/
package com.yanzhenjie.album;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
import android.widget.ImageView;
/**
@@ -31,6 +35,19 @@ public void load(ImageView imageView, AlbumFile albumFile) {
@Override
public void load(ImageView imageView, String url) {
}
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, AlbumFile albumFile, View.OnClickListener onClickListener, View.OnClickListener longClickListener) {
+ return new ImageView(context);
+ }
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, String url, View.OnClickListener onClickListener, View.OnClickListener longClickListener) {
+ return new ImageView(context);
+ }
+
};
/**
@@ -48,5 +65,11 @@ public void load(ImageView imageView, String url) {
* @param url The url of the file, local path or remote path.
*/
void load(ImageView imageView, String url);
-
+
+ @NonNull
+ View getPreviewView(Context context, AlbumFile albumFile, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener);
+
+ @NonNull
+ View getPreviewView(Context context, String url, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener);
+
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/app/album/AlbumActivity.java b/album/src/main/java/com/yanzhenjie/album/app/album/AlbumActivity.java
index 0cd4b54..6291b81 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/album/AlbumActivity.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/album/AlbumActivity.java
@@ -249,7 +249,7 @@ private void showFolderAlbumFiles(int position) {
@Override
public void clickCamera(View v) {
- int hasCheckSize = mCheckedList.size();
+ int hasCheckSize = mCheckedList == null ? 0 : mCheckedList.size();
if (hasCheckSize >= mLimitCount) {
int messageRes;
switch (mFunction) {
diff --git a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
index 6eeb562..2912eb6 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
@@ -16,8 +16,12 @@
package com.yanzhenjie.album.app.gallery;
import android.app.Activity;
+import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.AppCompatCheckBox;
import android.view.Menu;
@@ -107,12 +111,16 @@ public void onPageSelected(int position) {
@Override
public void bindData(List dataList) {
PreviewAdapter adapter = new PreviewAdapter(getContext(), dataList) {
+
+ @NonNull
@Override
- protected void loadPreview(ImageView imageView, Data item, int position) {
+ protected View getView(Context context, Data item, int position, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener) {
if (item instanceof String) {
- Album.getAlbumConfig().getAlbumLoader().load(imageView, (String)item);
+ return Album.getAlbumConfig().getAlbumLoader().getPreviewView(context, (String) item, onClickListener, longClickListener);
} else if (item instanceof AlbumFile) {
- Album.getAlbumConfig().getAlbumLoader().load(imageView, (AlbumFile)item);
+ return Album.getAlbumConfig().getAlbumLoader().getPreviewView(context, (AlbumFile) item, onClickListener, longClickListener);
+ } else {
+ return new ImageView(context);
}
}
};
diff --git a/album/src/main/java/com/yanzhenjie/album/app/gallery/PreviewAdapter.java b/album/src/main/java/com/yanzhenjie/album/app/gallery/PreviewAdapter.java
index d1dc3cf..a01a874 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/gallery/PreviewAdapter.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/gallery/PreviewAdapter.java
@@ -17,13 +17,10 @@
import android.content.Context;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import com.yanzhenjie.album.widget.photoview.AttacherImageView;
-import com.yanzhenjie.album.widget.photoview.PhotoViewAttacher;
import java.util.List;
@@ -31,8 +28,7 @@
* Adapter of preview the big picture.
* Created by Yan Zhenjie on 2016/10/19.
*/
-public abstract class PreviewAdapter extends PagerAdapter
- implements PhotoViewAttacher.OnViewTapListener, View.OnLongClickListener {
+public abstract class PreviewAdapter extends PagerAdapter {
private Context mContext;
private List mPreviewList;
@@ -76,38 +72,17 @@ public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
- AttacherImageView imageView = new AttacherImageView(mContext);
- imageView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
- loadPreview(imageView, mPreviewList.get(position), position);
- container.addView(imageView);
-
- final PhotoViewAttacher attacher = new PhotoViewAttacher(imageView);
- if (mItemClickListener != null) {
- attacher.setOnViewTapListener(this);
- }
- if (mItemLongClickListener != null) {
- attacher.setOnLongClickListener(this);
- }
- imageView.setAttacher(attacher);
-
- return imageView;
+ View view = getView(mContext, mPreviewList.get(position), position, mItemClickListener, mItemLongClickListener);
+ container.addView(view);
+ return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
- container.removeView(((View)object));
- }
-
- @Override
- public void onViewTap(View v, float x, float y) {
- mItemClickListener.onClick(v);
+ container.removeView(((View) object));
}
-
- @Override
- public boolean onLongClick(View v) {
- mItemLongClickListener.onClick(v);
- return true;
- }
-
- protected abstract void loadPreview(ImageView imageView, T item, int position);
+
+ @NonNull
+ protected abstract View getView(Context context, T item, int position, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener);
+
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/FixViewPager.java b/album/src/main/java/com/yanzhenjie/album/widget/FixViewPager.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/FixViewPager.java
rename to album/src/main/java/com/yanzhenjie/album/widget/FixViewPager.java
index f505811..12a6d66 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/FixViewPager.java
+++ b/album/src/main/java/com/yanzhenjie/album/widget/FixViewPager.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.widget;
import android.content.Context;
import android.support.v4.view.ViewPager;
diff --git a/album/src/main/res/layout/album_activity_gallery.xml b/album/src/main/res/layout/album_activity_gallery.xml
index 4aab2ba..e2a08a2 100644
--- a/album/src/main/res/layout/album_activity_gallery.xml
+++ b/album/src/main/res/layout/album_activity_gallery.xml
@@ -18,7 +18,7 @@
style="@style/Album.MatchParent"
android:background="@color/albumColorPrimaryBlack">
-
diff --git a/build.gradle b/build.gradle
index 05840ac..69fa189 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,9 @@ allprojects {
repositories {
google()
jcenter()
+ maven {
+ url "http://dl.bintray.com/piasy/maven"
+ }
}
}
diff --git a/sample/build.gradle b/sample/build.gradle
index ee9a379..3da51bd 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -14,7 +14,12 @@ android {
}
dependencies {
- implementation rootProject.ext.dependencies.album
+ implementation project(":album")
+ // implementation rootProject.ext.dependencies.album
+ implementation 'com.facebook.fresco:fresco:1.11.0'
+ implementation "com.github.piasy:BigImageViewer:1.5.6"
+ implementation "com.github.piasy:FrescoImageLoader:1.5.6"
+ implementation 'com.github.piasy:FrescoImageViewFactory:1.5.6'
implementation rootProject.ext.dependencies.appCompat
implementation rootProject.ext.dependencies.design
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/Application.java b/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
index 51b383a..a5b9e9d 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
@@ -15,6 +15,8 @@
*/
package com.yanzhenjie.album.sample;
+import com.github.piasy.biv.BigImageViewer;
+import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumConfig;
@@ -25,23 +27,25 @@
* Created by Yan Zhenjie on 2016/10/30.
*/
public class Application extends android.app.Application {
-
+
private static Application instance;
-
+
@Override
public void onCreate() {
super.onCreate();
if (instance == null) {
instance = this;
-
+ BigImageViewer.initialize(FrescoImageLoader.with(instance));
+
Album.initialize(AlbumConfig.newBuilder(this)
- .setAlbumLoader(new MediaLoader())
- .setLocale(Locale.getDefault())
- .build()
+ // .setAlbumLoader(new MediaLoader())
+ .setAlbumLoader(new FrescoLoader())
+ .setLocale(Locale.getDefault())
+ .build()
);
}
}
-
+
public static Application getInstance() {
return instance;
}
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
new file mode 100644
index 0000000..a7e495b
--- /dev/null
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2017 Yan Zhenjie.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yanzhenjie.album.sample;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import com.facebook.common.executors.UiThreadImmediateExecutorService;
+import com.facebook.common.references.CloseableReference;
+import com.facebook.datasource.DataSource;
+import com.facebook.drawee.backends.pipeline.Fresco;
+import com.facebook.drawee.view.SimpleDraweeView;
+import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
+import com.facebook.imagepipeline.image.CloseableImage;
+import com.facebook.imagepipeline.request.ImageRequest;
+import com.github.piasy.biv.view.BigImageView;
+import com.github.piasy.biv.view.FrescoImageViewFactory;
+import com.yanzhenjie.album.AlbumFile;
+import com.yanzhenjie.album.AlbumLoader;
+import com.yanzhenjie.album.sample.photoview.AttacherImageView;
+import com.yanzhenjie.album.sample.photoview.PhotoViewAttacher;
+
+/**
+ * Created by Yan Zhenjie on 2017/3/31.
+ */
+public class FrescoLoader implements AlbumLoader {
+
+ @Override
+ public void load(ImageView imageView, AlbumFile albumFile) {
+ load(imageView, "file://" + albumFile.getPath());
+ }
+
+ @Override
+ public void load(ImageView imageView, String url) {
+ if (imageView instanceof SimpleDraweeView) {
+ ((SimpleDraweeView) imageView).setImageURI(url);
+ }
+ }
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
+ final AttacherImageView view = new AttacherImageView(context);
+ view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ DataSource> dataSource = Fresco.getImagePipeline()
+ .fetchDecodedImage(ImageRequest.fromUri("file://" + albumFile.getPath()), context);
+ dataSource.subscribe(new BaseBitmapDataSubscriber() {
+ @Override
+ protected void onNewResultImpl(Bitmap bitmap) {
+ view.setImageDrawable(new BitmapDrawable(bitmap.copy(bitmap.getConfig(), bitmap.isMutable())));
+ }
+
+ @Override
+ protected void onFailureImpl(DataSource> dataSource) {
+ }
+ }, UiThreadImmediateExecutorService.getInstance());
+ final PhotoViewAttacher attacher = new PhotoViewAttacher(view);
+ if (onClickListener != null) {
+ attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
+ @Override
+ public void onViewTap(View v, float x, float y) {
+ onClickListener.onClick(v);
+ }
+ });
+ }
+ if (longClickListener != null) {
+ attacher.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ longClickListener.onClick(v);
+ return true;
+ }
+ });
+ }
+ view.setAttacher(attacher);
+ return view;
+ } else {
+ return getPreviewView(context, "file://" + albumFile.getPath(), onClickListener, longClickListener);
+ }
+ }
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, String url, View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ final BigImageView view = new BigImageView(context);
+ view.setImageViewFactory(new FrescoImageViewFactory());
+ view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ view.showImage(Uri.parse(url));
+ view.setOnClickListener(onClickListener);
+ view.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ longClickListener.onClick(view);
+ return true;
+ }
+ });
+ return view;
+ }
+}
\ No newline at end of file
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
index 331e096..efd47d9 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
@@ -15,30 +15,69 @@
*/
package com.yanzhenjie.album.sample;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.yanzhenjie.album.AlbumFile;
import com.yanzhenjie.album.AlbumLoader;
-import com.yanzhenjie.album.sample.R;
+import com.yanzhenjie.album.sample.photoview.AttacherImageView;
+import com.yanzhenjie.album.sample.photoview.PhotoViewAttacher;
/**
* Created by Yan Zhenjie on 2017/3/31.
*/
public class MediaLoader implements AlbumLoader {
-
+
@Override
public void load(ImageView imageView, AlbumFile albumFile) {
load(imageView, albumFile.getPath());
}
-
+
@Override
public void load(ImageView imageView, String url) {
Glide.with(imageView.getContext())
- .load(url)
- .error(R.drawable.placeholder)
- .placeholder(R.drawable.placeholder)
- .crossFade()
- .into(imageView);
+ .load(url)
+ .error(R.drawable.placeholder)
+ .placeholder(R.drawable.placeholder)
+ .crossFade()
+ .into(imageView);
+ }
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ return getPreviewView(context, albumFile.getPath(), onClickListener, longClickListener);
+ }
+
+ @NonNull
+ @Override
+ public View getPreviewView(Context context, String url, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ final AttacherImageView view = new AttacherImageView(context);
+ view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ load(view, url);
+ PhotoViewAttacher attacher = new PhotoViewAttacher(view);
+ if (onClickListener != null) {
+ attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
+ @Override
+ public void onViewTap(View v, float x, float y) {
+ onClickListener.onClick(v);
+ }
+ });
+ }
+ if (longClickListener != null) {
+ attacher.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ longClickListener.onClick(v);
+ return true;
+ }
+ });
+ }
+ view.setAttacher(attacher);
+ return view;
}
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/AttacherImageView.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
similarity index 95%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/AttacherImageView.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
index 71842d1..107532f 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/AttacherImageView.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
@@ -1,4 +1,4 @@
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.sample.photoview;
import android.content.Context;
import android.graphics.drawable.Drawable;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/Compat.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/Compat.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/Compat.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/Compat.java
index 7bf9dc1..70e7c92 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/Compat.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/Compat.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.sample.photoview;
import android.annotation.TargetApi;
import android.os.Build.VERSION;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/DefaultOnDoubleTapListener.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/DefaultOnDoubleTapListener.java
similarity index 98%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/DefaultOnDoubleTapListener.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/DefaultOnDoubleTapListener.java
index d1b120c..a0cbf05 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/DefaultOnDoubleTapListener.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/DefaultOnDoubleTapListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.sample.photoview;
import android.graphics.RectF;
import android.view.GestureDetector;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/IPhotoView.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/IPhotoView.java
similarity index 99%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/IPhotoView.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/IPhotoView.java
index ab27a5c..75c80dc 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/IPhotoView.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/IPhotoView.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.sample.photoview;
import android.graphics.Bitmap;
import android.graphics.Matrix;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/PhotoViewAttacher.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
similarity index 99%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/PhotoViewAttacher.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
index 53ba105..8b15d71 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/PhotoViewAttacher.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview;
+package com.yanzhenjie.album.sample.photoview;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -35,9 +35,9 @@
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
-import com.yanzhenjie.album.widget.photoview.gestures.OnGestureListener;
-import com.yanzhenjie.album.widget.photoview.gestures.VersionedGestureDetector;
-import com.yanzhenjie.album.widget.photoview.scrollerproxy.ScrollerProxy;
+import com.yanzhenjie.album.sample.photoview.gestures.OnGestureListener;
+import com.yanzhenjie.album.sample.photoview.gestures.VersionedGestureDetector;
+import com.yanzhenjie.album.sample.photoview.scrollerproxy.ScrollerProxy;
import java.lang.ref.WeakReference;
@@ -118,7 +118,7 @@ private static void setImageViewScaleTypeMatrix(ImageView imageView) {
// Gesture Detectors
private GestureDetector mGestureDetector;
- private com.yanzhenjie.album.widget.photoview.gestures.GestureDetector mScaleDragDetector;
+ private com.yanzhenjie.album.sample.photoview.gestures.GestureDetector mScaleDragDetector;
// These are set so we don't keep allocating them on the heap
private final Matrix mBaseMatrix = new Matrix();
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/CupcakeGestureDetector.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/CupcakeGestureDetector.java
similarity index 98%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/CupcakeGestureDetector.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/CupcakeGestureDetector.java
index 9f31c1c..b3ce78d 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/CupcakeGestureDetector.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/CupcakeGestureDetector.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
import android.content.Context;
import android.view.MotionEvent;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/EclairGestureDetector.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/EclairGestureDetector.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/EclairGestureDetector.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/EclairGestureDetector.java
index 32053b4..3b57f46 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/EclairGestureDetector.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/EclairGestureDetector.java
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
import android.annotation.TargetApi;
import android.content.Context;
import android.view.MotionEvent;
-import com.yanzhenjie.album.widget.photoview.Compat;
+import com.yanzhenjie.album.sample.photoview.Compat;
@TargetApi(5)
public class EclairGestureDetector extends CupcakeGestureDetector {
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/FroyoGestureDetector.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/FroyoGestureDetector.java
similarity index 97%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/FroyoGestureDetector.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/FroyoGestureDetector.java
index fd50b6e..4349ca2 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/FroyoGestureDetector.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/FroyoGestureDetector.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
import android.annotation.TargetApi;
import android.content.Context;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/GestureDetector.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/GestureDetector.java
similarity index 93%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/GestureDetector.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/GestureDetector.java
index 8cc90a5..e90c666 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/GestureDetector.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/GestureDetector.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
import android.view.MotionEvent;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/OnGestureListener.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/OnGestureListener.java
similarity index 93%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/OnGestureListener.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/OnGestureListener.java
index a6356c3..0bda9be 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/OnGestureListener.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/OnGestureListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
public interface OnGestureListener {
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/VersionedGestureDetector.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/VersionedGestureDetector.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/VersionedGestureDetector.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/VersionedGestureDetector.java
index b358c0b..05082ed 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/gestures/VersionedGestureDetector.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/gestures/VersionedGestureDetector.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.gestures;
+package com.yanzhenjie.album.sample.photoview.gestures;
import android.content.Context;
import android.os.Build;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/GingerScroller.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/GingerScroller.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/GingerScroller.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/GingerScroller.java
index 592c262..f8f3290 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/GingerScroller.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/GingerScroller.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.scrollerproxy;
+package com.yanzhenjie.album.sample.photoview.scrollerproxy;
import android.annotation.TargetApi;
import android.content.Context;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/IcsScroller.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/IcsScroller.java
similarity index 93%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/IcsScroller.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/IcsScroller.java
index d165aa6..3a3f2e9 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/IcsScroller.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/IcsScroller.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.scrollerproxy;
+package com.yanzhenjie.album.sample.photoview.scrollerproxy;
import android.annotation.TargetApi;
import android.content.Context;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/PreGingerScroller.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/PreGingerScroller.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/PreGingerScroller.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/PreGingerScroller.java
index 677c734..04b6b39 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/PreGingerScroller.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/PreGingerScroller.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.scrollerproxy;
+package com.yanzhenjie.album.sample.photoview.scrollerproxy;
import android.content.Context;
import android.widget.Scroller;
diff --git a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/ScrollerProxy.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/ScrollerProxy.java
similarity index 96%
rename from album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/ScrollerProxy.java
rename to sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/ScrollerProxy.java
index 2f2fd1a..652eb00 100644
--- a/album/src/main/java/com/yanzhenjie/album/widget/photoview/scrollerproxy/ScrollerProxy.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/scrollerproxy/ScrollerProxy.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.yanzhenjie.album.widget.photoview.scrollerproxy;
+package com.yanzhenjie.album.sample.photoview.scrollerproxy;
import android.content.Context;
import android.os.Build.VERSION;
diff --git a/sample/src/main/res/layout/activity_camera.xml b/sample/src/main/res/layout/activity_camera.xml
index ed5baaa..3e63d51 100644
--- a/sample/src/main/res/layout/activity_camera.xml
+++ b/sample/src/main/res/layout/activity_camera.xml
@@ -1,5 +1,4 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/album_item_content_video.xml b/sample/src/main/res/layout/album_item_content_video.xml
new file mode 100644
index 0000000..98ade1f
--- /dev/null
+++ b/sample/src/main/res/layout/album_item_content_video.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/album_item_dialog_folder.xml b/sample/src/main/res/layout/album_item_dialog_folder.xml
new file mode 100644
index 0000000..5e2e34e
--- /dev/null
+++ b/sample/src/main/res/layout/album_item_dialog_folder.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/item_content_image.xml b/sample/src/main/res/layout/item_content_image.xml
index 09fc0ef..41a6cae 100644
--- a/sample/src/main/res/layout/item_content_image.xml
+++ b/sample/src/main/res/layout/item_content_image.xml
@@ -1,5 +1,4 @@
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/sample/src/main/res/layout/item_content_video.xml b/sample/src/main/res/layout/item_content_video.xml
index 7755cde..6b66897 100644
--- a/sample/src/main/res/layout/item_content_video.xml
+++ b/sample/src/main/res/layout/item_content_video.xml
@@ -1,5 +1,4 @@
-
-
-
@@ -25,7 +25,7 @@
android:layout_alignParentBottom="true"
android:background="@color/albumSheetBottom">
-
-
-
-
diff --git a/album/src/main/res/layout/album_item_content_video.xml b/album/src/main/res/layout/album_item_content_video.xml
index 27b4de2..c1ca22a 100644
--- a/album/src/main/res/layout/album_item_content_video.xml
+++ b/album/src/main/res/layout/album_item_content_video.xml
@@ -30,7 +30,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
-
diff --git a/album/src/main/res/layout/album_item_dialog_folder.xml b/album/src/main/res/layout/album_item_dialog_folder.xml
index 88da0ab..2ddf7e4 100644
--- a/album/src/main/res/layout/album_item_dialog_folder.xml
+++ b/album/src/main/res/layout/album_item_dialog_folder.xml
@@ -29,7 +29,7 @@
android:contentDescription="@string/album_title"
android:scaleType="centerCrop"/>
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/album/src/main/res/layout/album_toolbar_light.xml b/album/src/main/res/layout/album_toolbar_light.xml
index 43b7a6c..15de099 100644
--- a/album/src/main/res/layout/album_toolbar_light.xml
+++ b/album/src/main/res/layout/album_toolbar_light.xml
@@ -14,12 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/config.gradle b/config.gradle
index 19a4349..53ac197 100644
--- a/config.gradle
+++ b/config.gradle
@@ -8,11 +8,11 @@ ext {
android = [
applicationId : "com.yanzhenjie.album.sample",
- compileSdkVersion: 28,
- buildToolsVersion: "28.0.3",
+ compileSdkVersion: 29,
+ buildToolsVersion: "29.0.3",
minSdkVersion : 14,
- targetSdkVersion : 28,
+ targetSdkVersion : 29,
versionCode : 27,
versionName : "2.1.3",
@@ -46,10 +46,10 @@ ext {
dependencies = [
mediaScanner: 'com.yanzhenjie:mediascanner:1.0.3',
- design : 'com.android.support:design:28.0.0',
- appCompat : 'com.android.support:appcompat-v7:28.0.0',
- recyclerView: 'com.android.support:recyclerview-v7:28.0.0',
- cardView : 'com.android.support:cardview-v7:28.0.0',
+ design : 'com.google.android.material:material:1.0.0',
+ appCompat : 'androidx.appcompat:appcompat:1.0.0',
+ recyclerView: 'androidx.recyclerview:recyclerview:1.0.0',
+ cardView : 'androidx.cardview:cardview:1.0.0',
album : 'com.yanzhenjie:album:2.1.3',
glide : 'com.github.bumptech.glide:glide:3.8.0'
diff --git a/gradle.properties b/gradle.properties
index 01e0ac2..a964ca0 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,5 @@
+android.enableJetifier=true
+android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=12333
diff --git a/sample/build.gradle b/sample/build.gradle
index 3da51bd..0f533df 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -11,15 +11,20 @@ android {
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
}
+
+ //解决 More than one file was found with OS independent path 'META-INF/DEPENDENCIES'
+ packagingOptions {
+ exclude 'META-INF/proguard/androidx-annotations.pro'
+ }
}
dependencies {
implementation project(":album")
// implementation rootProject.ext.dependencies.album
- implementation 'com.facebook.fresco:fresco:1.11.0'
- implementation "com.github.piasy:BigImageViewer:1.5.6"
- implementation "com.github.piasy:FrescoImageLoader:1.5.6"
- implementation 'com.github.piasy:FrescoImageViewFactory:1.5.6'
+ implementation 'com.facebook.fresco:fresco:2.1.0'
+ implementation "com.github.piasy:BigImageViewer:1.6.2"
+ implementation "com.github.piasy:FrescoImageLoader:1.6.2"
+ implementation 'com.github.piasy:FrescoImageViewFactory:1.6.2'
implementation rootProject.ext.dependencies.appCompat
implementation rootProject.ext.dependencies.design
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
index a7e495b..6acd484 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
@@ -19,7 +19,6 @@
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
-import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -39,6 +38,9 @@
import com.yanzhenjie.album.sample.photoview.AttacherImageView;
import com.yanzhenjie.album.sample.photoview.PhotoViewAttacher;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Created by Yan Zhenjie on 2017/3/31.
*/
@@ -46,13 +48,13 @@ public class FrescoLoader implements AlbumLoader {
@Override
public void load(ImageView imageView, AlbumFile albumFile) {
- load(imageView, "file://" + albumFile.getPath());
+ load(imageView, albumFile.getUri());
}
@Override
- public void load(ImageView imageView, String url) {
+ public void load(ImageView imageView, Uri uri) {
if (imageView instanceof SimpleDraweeView) {
- ((SimpleDraweeView) imageView).setImageURI(url);
+ ((SimpleDraweeView) imageView).setImageURI(uri);
}
}
@@ -63,7 +65,7 @@ public View getPreviewView(Context context, AlbumFile albumFile, final View.OnCl
final AttacherImageView view = new AttacherImageView(context);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
DataSource> dataSource = Fresco.getImagePipeline()
- .fetchDecodedImage(ImageRequest.fromUri("file://" + albumFile.getPath()), context);
+ .fetchDecodedImage(ImageRequest.fromUri(albumFile.getUri()), context);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
@@ -95,25 +97,28 @@ public boolean onLongClick(View v) {
view.setAttacher(attacher);
return view;
} else {
- return getPreviewView(context, "file://" + albumFile.getPath(), onClickListener, longClickListener);
+ return getPreviewView(context, albumFile.getUri(), onClickListener, longClickListener);
}
}
@NonNull
@Override
- public View getPreviewView(Context context, String url, View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ public View getPreviewView(Context context, Uri uri, @Nullable View.OnClickListener onClickListener, final @Nullable View.OnClickListener longClickListener) {
final BigImageView view = new BigImageView(context);
view.setImageViewFactory(new FrescoImageViewFactory());
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- view.showImage(Uri.parse(url));
+ view.showImage(uri);
view.setOnClickListener(onClickListener);
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
- longClickListener.onClick(view);
+ if (longClickListener != null) {
+ longClickListener.onClick(view);
+ }
return true;
}
});
return view;
}
+
}
\ No newline at end of file
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/MainActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/MainActivity.java
index e99e465..3ff9f05 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/MainActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/MainActivity.java
@@ -17,9 +17,9 @@
import android.content.Intent;
import android.os.Bundle;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
import android.view.View;
import com.yanzhenjie.album.sample.app.AlbumActivity;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
index efd47d9..10938ce 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
@@ -16,7 +16,9 @@
package com.yanzhenjie.album.sample;
import android.content.Context;
-import android.support.annotation.NonNull;
+import android.net.Uri;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -34,13 +36,13 @@ public class MediaLoader implements AlbumLoader {
@Override
public void load(ImageView imageView, AlbumFile albumFile) {
- load(imageView, albumFile.getPath());
+ load(imageView, albumFile.getUri());
}
@Override
- public void load(ImageView imageView, String url) {
+ public void load(ImageView imageView, Uri uri) {
Glide.with(imageView.getContext())
- .load(url)
+ .load(uri)
.error(R.drawable.placeholder)
.placeholder(R.drawable.placeholder)
.crossFade()
@@ -50,15 +52,15 @@ public void load(ImageView imageView, String url) {
@NonNull
@Override
public View getPreviewView(Context context, AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
- return getPreviewView(context, albumFile.getPath(), onClickListener, longClickListener);
+ return getPreviewView(context, albumFile.getUri(), onClickListener, longClickListener);
}
@NonNull
@Override
- public View getPreviewView(Context context, String url, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ public View getPreviewView(Context context, Uri uri, @Nullable final View.OnClickListener onClickListener, @Nullable final View.OnClickListener longClickListener) {
final AttacherImageView view = new AttacherImageView(context);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- load(view, url);
+ load(view, uri);
PhotoViewAttacher attacher = new PhotoViewAttacher(view);
if (onClickListener != null) {
attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@@ -80,4 +82,5 @@ public boolean onLongClick(View v) {
view.setAttacher(attacher);
return view;
}
+
}
\ No newline at end of file
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/Adapter.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/Adapter.java
index 8ac9ae7..76c2c90 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/Adapter.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/Adapter.java
@@ -16,8 +16,8 @@
package com.yanzhenjie.album.sample.app;
import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumActivity.java
index 4145100..71638ef 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumActivity.java
@@ -17,12 +17,12 @@
import android.graphics.Color;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumFilterActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumFilterActivity.java
index 0a02914..0adca4b 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumFilterActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/AlbumFilterActivity.java
@@ -18,13 +18,13 @@
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/CameraActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/CameraActivity.java
index 54c0850..fcbc5a2 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/CameraActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/CameraActivity.java
@@ -15,12 +15,8 @@
*/
package com.yanzhenjie.album.sample.app;
+import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
@@ -29,16 +25,23 @@
import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.Album;
+import com.yanzhenjie.album.AlbumCameraFile;
import com.yanzhenjie.album.sample.R;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
/**
* Created by YanZhenjie on 2017/8/17.
*/
public class CameraActivity extends AppCompatActivity {
-
+
TextView mTextView;
private ImageView mImageView;
-
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -48,66 +51,65 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
-
+
mTextView = findViewById(R.id.tv_message);
mImageView = findViewById(R.id.image_view);
}
-
+
private void takePicture() {
Album.camera(this)
- .image()
-// .filePath()
- .onResult(new Action() {
- @Override
- public void onAction(@NonNull String result) {
- mTextView.setText(result);
-
- Album.getAlbumConfig()
- .getAlbumLoader()
- .load(mImageView, result);
- }
- })
- .onCancel(new Action() {
- @Override
- public void onAction(@NonNull String result) {
- Toast.makeText(CameraActivity.this, R.string.canceled, Toast.LENGTH_LONG).show();
- }
- })
- .start();
+ .image()
+ // .filePath()
+ .onResult(new Action() {
+ @Override
+ public void onAction(@NonNull AlbumCameraFile result) {
+ mTextView.setText(result.toString());
+ Album.getAlbumConfig()
+ .getAlbumLoader()
+ .load(mImageView, result.getUri());
+ }
+ })
+ .onCancel(new Action() {
+ @Override
+ public void onAction(@NonNull String result) {
+ Toast.makeText(CameraActivity.this, R.string.canceled, Toast.LENGTH_LONG).show();
+ }
+ })
+ .start();
}
-
+
private void recordVideo() {
Album.camera(this)
- .video()
-// .filePath()
- .quality(1)
- .limitDuration(Integer.MAX_VALUE)
- .limitBytes(Integer.MAX_VALUE)
- .onResult(new Action() {
- @Override
- public void onAction(@NonNull String result) {
- mTextView.setText(result);
-
- Album.getAlbumConfig()
- .getAlbumLoader()
- .load(mImageView, result);
- }
- })
- .onCancel(new Action() {
- @Override
- public void onAction(@NonNull String result) {
- Toast.makeText(CameraActivity.this, R.string.canceled, Toast.LENGTH_LONG).show();
- }
- })
- .start();
+ .video()
+ // .filePath()
+ .quality(1)
+ .limitDuration(Integer.MAX_VALUE)
+ .limitBytes(Integer.MAX_VALUE)
+ .onResult(new Action() {
+ @Override
+ public void onAction(@NonNull AlbumCameraFile result) {
+ mTextView.setText(result.toString());
+
+ Album.getAlbumConfig()
+ .getAlbumLoader()
+ .load(mImageView, result.getUri());
+ }
+ })
+ .onCancel(new Action() {
+ @Override
+ public void onAction(@NonNull String result) {
+ Toast.makeText(CameraActivity.this, R.string.canceled, Toast.LENGTH_LONG).show();
+ }
+ })
+ .start();
}
-
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_album_camera, menu);
return true;
}
-
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/DefineStyleActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/DefineStyleActivity.java
index bdd0886..40bd1d4 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/DefineStyleActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/DefineStyleActivity.java
@@ -17,12 +17,12 @@
import android.graphics.Color;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
index 63496d9..8e7f5d1 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
@@ -16,10 +16,10 @@
package com.yanzhenjie.album.sample.app;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/ImageActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/ImageActivity.java
index a08c964..f985915 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/ImageActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/ImageActivity.java
@@ -17,12 +17,12 @@
import android.graphics.Color;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/VideoActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/VideoActivity.java
index d1894c1..9aaac05 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/VideoActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/VideoActivity.java
@@ -17,12 +17,12 @@
import android.graphics.Color;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
index 107532f..582a76e 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/AttacherImageView.java
@@ -2,14 +2,14 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
import android.util.AttributeSet;
/**
* Created by Yan Zhenjie on 2017/3/31.
*/
-public class AttacherImageView extends android.support.v7.widget.AppCompatImageView {
+public class AttacherImageView extends androidx.appcompat.widget.AppCompatImageView {
private PhotoViewAttacher mAttacher;
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
index 8b15d71..72d8608 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/photoview/PhotoViewAttacher.java
@@ -22,8 +22,8 @@
import android.graphics.Matrix.ScaleToFit;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
-import android.support.annotation.Nullable;
-import android.support.v4.view.MotionEventCompat;
+import androidx.annotation.Nullable;
+import androidx.core.view.MotionEventCompat;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
diff --git a/sample/src/main/res/layout/activity_album.xml b/sample/src/main/res/layout/activity_album.xml
index 030c2ea..79ae7eb 100644
--- a/sample/src/main/res/layout/activity_album.xml
+++ b/sample/src/main/res/layout/activity_album.xml
@@ -14,11 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_album_filter.xml b/sample/src/main/res/layout/activity_album_filter.xml
index c914c76..23a7c11 100644
--- a/sample/src/main/res/layout/activity_album_filter.xml
+++ b/sample/src/main/res/layout/activity_album_filter.xml
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
@@ -32,11 +32,11 @@
android:text="@string/hint_image_preview_click"
android:visibility="gone" />
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_album_ui.xml b/sample/src/main/res/layout/activity_album_ui.xml
index 061233b..aa9b0ba 100644
--- a/sample/src/main/res/layout/activity_album_ui.xml
+++ b/sample/src/main/res/layout/activity_album_ui.xml
@@ -13,10 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_camera.xml b/sample/src/main/res/layout/activity_camera.xml
index 3e63d51..33d813d 100644
--- a/sample/src/main/res/layout/activity_camera.xml
+++ b/sample/src/main/res/layout/activity_camera.xml
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
@@ -38,4 +38,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_gallery.xml b/sample/src/main/res/layout/activity_gallery.xml
index dde472a..2500b6a 100644
--- a/sample/src/main/res/layout/activity_gallery.xml
+++ b/sample/src/main/res/layout/activity_gallery.xml
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
@@ -26,12 +26,12 @@
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_list_content.xml b/sample/src/main/res/layout/activity_list_content.xml
index 44b594e..3a4b12d 100644
--- a/sample/src/main/res/layout/activity_list_content.xml
+++ b/sample/src/main/res/layout/activity_list_content.xml
@@ -31,7 +31,7 @@
android:id="@+id/image_view"
style="@style/Album.WrapContent" />
-
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index 992c0c2..db123c0 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -14,13 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
@@ -28,7 +28,7 @@
style="@style/Album.WrapContent.WidthMatchParent"
android:orientation="vertical">
-
@@ -37,39 +37,39 @@
style="@style/Album.WrapContent.WidthMatchParent"
android:orientation="horizontal">
-
-
-
-
-
-
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/album_item_content_image.xml b/sample/src/main/res/layout/album_item_content_image.xml
index 483ad62..2e7df31 100644
--- a/sample/src/main/res/layout/album_item_content_image.xml
+++ b/sample/src/main/res/layout/album_item_content_image.xml
@@ -30,7 +30,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
-
diff --git a/sample/src/main/res/layout/album_item_content_video.xml b/sample/src/main/res/layout/album_item_content_video.xml
index 98ade1f..3c0ec35 100644
--- a/sample/src/main/res/layout/album_item_content_video.xml
+++ b/sample/src/main/res/layout/album_item_content_video.xml
@@ -29,7 +29,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
-
diff --git a/sample/src/main/res/layout/album_item_dialog_folder.xml b/sample/src/main/res/layout/album_item_dialog_folder.xml
index 5e2e34e..24b03d4 100644
--- a/sample/src/main/res/layout/album_item_dialog_folder.xml
+++ b/sample/src/main/res/layout/album_item_dialog_folder.xml
@@ -27,7 +27,7 @@
android:contentDescription="@string/album_title"
android:scaleType="centerCrop" />
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sample/src/main/res/layout/toolbar_scroll.xml b/sample/src/main/res/layout/toolbar_scroll.xml
index 6b8a9f3..1b19495 100644
--- a/sample/src/main/res/layout/toolbar_scroll.xml
+++ b/sample/src/main/res/layout/toolbar_scroll.xml
@@ -14,14 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-
-
\ No newline at end of file
+
\ No newline at end of file
From ffa0fdde696f4aa25950b8ba3705ab362e02e19c Mon Sep 17 00:00:00 2001
From: LiuJun
Date: Thu, 23 Jul 2020 19:09:16 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E9=83=A8?=
=?UTF-8?q?=E5=88=86=E8=AD=A6=E5=91=8A=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8DGallery=E7=BD=91=E7=BB=9C=E5=9B=BE=E7=89=87=E5=8A=A0?=
=?UTF-8?q?=E8=BD=BDURI=20=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
album/build.gradle | 29 ++++-
.../main/java/com/yanzhenjie/album/Album.java | 87 +++++++++----
.../java/com/yanzhenjie/album/AlbumFile.java | 27 ++--
.../album/api/AlbumMultipleWrapper.java | 11 +-
.../album/api/BasicAlbumWrapper.java | 19 ++-
.../album/api/BasicCameraWrapper.java | 27 ++--
.../album/api/BasicChoiceWrapper.java | 9 +-
.../album/api/BasicGalleryWrapper.java | 3 +-
.../album/api/GalleryAlbumWrapper.java | 4 +-
.../album/api/ImageCameraWrapper.java | 5 +-
.../album/api/ImageMultipleWrapper.java | 11 +-
.../album/api/VideoCameraWrapper.java | 7 +-
.../album/api/camera/AlbumCamera.java | 6 +-
.../com/yanzhenjie/album/app/Contract.java | 6 +-
.../album/app/album/AlbumActivity.java | 122 +++++++++---------
.../album/app/album/GalleryActivity.java | 4 +-
.../album/app/album/data/MediaReadTask.java | 12 +-
.../app/album/data/ThumbnailBuildTask.java | 32 +++--
.../album/app/camera/CameraActivity.java | 4 +-
.../app/gallery/GalleryAlbumActivity.java | 31 ++++-
.../album/app/gallery/GalleryView.java | 17 ++-
build.gradle | 2 +-
gradle.properties | 6 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
sample/build.gradle | 6 +-
.../yanzhenjie/album/sample/Application.java | 8 +-
.../yanzhenjie/album/sample/FrescoLoader.java | 2 +-
.../album/sample/app/GalleryActivity.java | 105 +++++++++------
28 files changed, 384 insertions(+), 222 deletions(-)
diff --git a/album/build.gradle b/album/build.gradle
index de3d1fa..a248f6b 100644
--- a/album/build.gradle
+++ b/album/build.gradle
@@ -1,5 +1,7 @@
apply plugin: rootProject.ext.plugins.library
+group = 'com.github.imliujun'
+
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
@@ -20,4 +22,29 @@ dependencies {
api rootProject.ext.dependencies.mediaScanner
}
-apply from: 'https://raw.githubusercontent.com/yanzhenjie/bintray/master/maven.gradle'
\ No newline at end of file
+//apply from: 'https://raw.githubusercontent.com/yanzhenjie/bintray/master/maven.gradle'
+
+
+// build a jar with source files
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+task javadoc(type: Javadoc) {
+ failOnError false
+ source = android.sourceSets.main.java.sourceFiles
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ classpath += configurations.compile
+}
+
+// build a jar with javadoc
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/Album.java b/album/src/main/java/com/yanzhenjie/album/Album.java
index 385df8b..f703b93 100644
--- a/album/src/main/java/com/yanzhenjie/album/Album.java
+++ b/album/src/main/java/com/yanzhenjie/album/Album.java
@@ -18,7 +18,6 @@
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
-import androidx.annotation.IntDef;
import android.util.Log;
import com.yanzhenjie.album.api.AlbumMultipleWrapper;
@@ -42,6 +41,10 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Entrance.
* Created by Yan Zhenjie on 2016/10/23.
@@ -103,14 +106,18 @@ public final class Album {
*
* @param albumConfig {@link AlbumConfig}.
*/
- public static void initialize(AlbumConfig albumConfig) {
- if (sAlbumConfig == null) sAlbumConfig = albumConfig;
- else Log.w("Album", new IllegalStateException("Illegal operation, only allowed to configure once."));
+ public static void initialize(@Nullable AlbumConfig albumConfig) {
+ if (sAlbumConfig == null) {
+ sAlbumConfig = albumConfig;
+ } else {
+ Log.w("Album", new IllegalStateException("Illegal operation, only allowed to configure once."));
+ }
}
/**
* Get the album configuration.
*/
+ @NonNull
public static AlbumConfig getAlbumConfig() {
if (sAlbumConfig == null) {
sAlbumConfig = AlbumConfig.newBuilder(null).build();
@@ -121,168 +128,192 @@ public static AlbumConfig getAlbumConfig() {
/**
* Open the camera from the activity.
*/
- public static Camera camera(Context context) {
+ @NonNull
+ public static Camera camera(@NonNull Context context) {
return new AlbumCamera(context);
}
/**
* Select images.
*/
- public static Choice image(Context context) {
+ @NonNull
+ public static Choice image(@NonNull Context context) {
return new ImageChoice(context);
}
/**
* Select videos.
*/
- public static Choice video(Context context) {
+ @NonNull
+ public static Choice video(@NonNull Context context) {
return new VideoChoice(context);
}
/**
* Select images and videos.
*/
- public static Choice album(Context context) {
+ @NonNull
+ public static Choice album(@NonNull Context context) {
return new AlbumChoice(context);
}
/**
* Preview picture.
*/
- public static GalleryWrapper gallery(Context context) {
+ @NonNull
+ public static GalleryWrapper gallery(@NonNull Context context) {
return new GalleryWrapper(context);
}
/**
* Preview Album.
*/
- public static GalleryAlbumWrapper galleryAlbum(Context context) {
+ @NonNull
+ public static GalleryAlbumWrapper galleryAlbum(@NonNull Context context) {
return new GalleryAlbumWrapper(context);
}
/**
* Open the camera from the activity.
*/
- public static Camera camera(Activity activity) {
+ @NonNull
+ public static Camera camera(@NonNull Activity activity) {
return new AlbumCamera(activity);
}
/**
* Select images.
*/
- public static Choice image(Activity activity) {
+ @NonNull
+ public static Choice image(@NonNull Activity activity) {
return new ImageChoice(activity);
}
/**
* Select videos.
*/
- public static Choice video(Activity activity) {
+ @NonNull
+ public static Choice video(@NonNull Activity activity) {
return new VideoChoice(activity);
}
/**
* Select images and videos.
*/
- public static Choice album(Activity activity) {
+ @NonNull
+ public static Choice album(@NonNull Activity activity) {
return new AlbumChoice(activity);
}
/**
* Preview picture.
*/
- public static BasicGalleryWrapper gallery(Activity activity) {
+ @NonNull
+ public static BasicGalleryWrapper gallery(@NonNull Activity activity) {
return new GalleryWrapper(activity);
}
/**
* Preview Album.
*/
- public static BasicGalleryWrapper galleryAlbum(Activity activity) {
+ @NonNull
+ public static BasicGalleryWrapper galleryAlbum(@NonNull Activity activity) {
return new GalleryAlbumWrapper(activity);
}
/**
* Open the camera from the activity.
*/
- public static Camera camera(Fragment fragment) {
+ @NonNull
+ public static Camera camera(@NonNull Fragment fragment) {
return new AlbumCamera(fragment.getActivity());
}
/**
* Select images.
*/
- public static Choice image(Fragment fragment) {
+ @NonNull
+ public static Choice image(@NonNull Fragment fragment) {
return new ImageChoice(fragment.getActivity());
}
/**
* Select videos.
*/
- public static Choice video(Fragment fragment) {
+ @NonNull
+ public static Choice video(@NonNull Fragment fragment) {
return new VideoChoice(fragment.getActivity());
}
/**
* Select images and videos.
*/
- public static Choice album(Fragment fragment) {
+ @NonNull
+ public static Choice album(@NonNull Fragment fragment) {
return new AlbumChoice(fragment.getActivity());
}
/**
* Preview picture.
*/
- public static BasicGalleryWrapper gallery(Fragment fragment) {
+ @NonNull
+ public static BasicGalleryWrapper gallery(@NonNull Fragment fragment) {
return new GalleryWrapper(fragment.getActivity());
}
/**
* Preview Album.
*/
- public static BasicGalleryWrapper galleryAlbum(Fragment fragment) {
+ @NonNull
+ public static BasicGalleryWrapper galleryAlbum(@NonNull Fragment fragment) {
return new GalleryAlbumWrapper(fragment.getActivity());
}
/**
* Open the camera from the activity.
*/
- public static Camera camera(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static Camera camera(@NonNull androidx.fragment.app.Fragment fragment) {
return new AlbumCamera(fragment.getContext());
}
/**
* Select images.
*/
- public static Choice image(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static Choice image(@NonNull androidx.fragment.app.Fragment fragment) {
return new ImageChoice(fragment.getContext());
}
/**
* Select videos.
*/
- public static Choice video(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static Choice video(@NonNull androidx.fragment.app.Fragment fragment) {
return new VideoChoice(fragment.getContext());
}
/**
* Select images and videos.
*/
- public static Choice album(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static Choice album(@NonNull androidx.fragment.app.Fragment fragment) {
return new AlbumChoice(fragment.getContext());
}
/**
* Preview picture.
*/
- public static BasicGalleryWrapper gallery(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static BasicGalleryWrapper gallery(@NonNull androidx.fragment.app.Fragment fragment) {
return new GalleryWrapper(fragment.getContext());
}
/**
* Preview Album.
*/
- public static BasicGalleryWrapper galleryAlbum(androidx.fragment.app.Fragment fragment) {
+ @NonNull
+ public static BasicGalleryWrapper galleryAlbum(@NonNull androidx.fragment.app.Fragment fragment) {
return new GalleryAlbumWrapper(fragment.getContext());
}
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/AlbumFile.java b/album/src/main/java/com/yanzhenjie/album/AlbumFile.java
index 351be81..953dfbc 100644
--- a/album/src/main/java/com/yanzhenjie/album/AlbumFile.java
+++ b/album/src/main/java/com/yanzhenjie/album/AlbumFile.java
@@ -18,11 +18,12 @@
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
/**
* Created by YanZhenjie on 2017/8/15.
*/
@@ -35,6 +36,7 @@ public class AlbumFile implements Parcelable, Comparable {
@IntDef({TYPE_IMAGE, TYPE_VIDEO})
public @interface MediaType {
}
+
/**
* File uri.
*/
@@ -90,10 +92,11 @@ public AlbumFile() {
@Override
public int compareTo(AlbumFile o) {
long time = o.getAddDate() - getAddDate();
- if (time > Integer.MAX_VALUE)
+ if (time > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
- else if (time < -Integer.MAX_VALUE)
+ } else if (time < -Integer.MAX_VALUE) {
return -Integer.MAX_VALUE;
+ }
return (int) time;
}
@@ -113,11 +116,11 @@ public boolean equals(Object obj) {
public int hashCode() {
return uri != null ? uri.hashCode() : super.hashCode();
}
-
+
public Uri getUri() {
return uri;
}
-
+
public void setUri(Uri uri) {
this.uri = uri;
}
@@ -182,7 +185,7 @@ public Uri getThumbUri() {
return mThumbUri;
}
- public void setThumbPath(Uri thumbUri) {
+ public void setThumbUri(Uri thumbUri) {
mThumbUri = thumbUri;
}
@@ -210,7 +213,7 @@ public boolean isDisable() {
public void setDisable(boolean disable) {
this.isDisable = disable;
}
-
+
@Override
public String toString() {
return "AlbumFile{" +
@@ -228,12 +231,12 @@ public String toString() {
", isDisable=" + isDisable +
'}';
}
-
+
@Override
public int describeContents() {
return 0;
}
-
+
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.uri, flags);
@@ -249,7 +252,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
dest.writeByte(this.isDisable ? (byte) 1 : (byte) 0);
}
-
+
protected AlbumFile(Parcel in) {
this.uri = in.readParcelable(Uri.class.getClassLoader());
this.mBucketName = in.readString();
@@ -264,13 +267,13 @@ protected AlbumFile(Parcel in) {
this.isChecked = in.readByte() != 0;
this.isDisable = in.readByte() != 0;
}
-
+
public static final Creator CREATOR = new Creator() {
@Override
public AlbumFile createFromParcel(Parcel source) {
return new AlbumFile(source);
}
-
+
@Override
public AlbumFile[] newArray(int size) {
return new AlbumFile[size];
diff --git a/album/src/main/java/com/yanzhenjie/album/api/AlbumMultipleWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/AlbumMultipleWrapper.java
index b879bb2..29902c7 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/AlbumMultipleWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/AlbumMultipleWrapper.java
@@ -18,6 +18,8 @@
import android.content.Context;
import android.content.Intent;
import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumFile;
@@ -35,7 +37,7 @@ public class AlbumMultipleWrapper extends BasicChoiceAlbumWrapper mDurationFilter;
- public AlbumMultipleWrapper(Context context) {
+ public AlbumMultipleWrapper(@NonNull Context context) {
super(context);
}
@@ -44,7 +46,8 @@ public AlbumMultipleWrapper(Context context) {
*
* @param checked the data list.
*/
- public final AlbumMultipleWrapper checkedList(ArrayList checked) {
+ @NonNull
+ public final AlbumMultipleWrapper checkedList(@Nullable ArrayList checked) {
this.mChecked = checked;
return this;
}
@@ -54,6 +57,7 @@ public final AlbumMultipleWrapper checkedList(ArrayList checked) {
*
* @param count the maximum number.
*/
+ @NonNull
public AlbumMultipleWrapper selectCount(@IntRange(from = 1, to = Integer.MAX_VALUE) int count) {
this.mLimitCount = count;
return this;
@@ -64,7 +68,8 @@ public AlbumMultipleWrapper selectCount(@IntRange(from = 1, to = Integer.MAX_VAL
*
* @param filter filter.
*/
- public AlbumMultipleWrapper filterDuration(Filter filter) {
+ @NonNull
+ public AlbumMultipleWrapper filterDuration(@Nullable Filter filter) {
this.mDurationFilter = filter;
return this;
}
diff --git a/album/src/main/java/com/yanzhenjie/album/api/BasicAlbumWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/BasicAlbumWrapper.java
index e78a15a..ca839b1 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/BasicAlbumWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/BasicAlbumWrapper.java
@@ -16,11 +16,13 @@
package com.yanzhenjie.album.api;
import android.content.Context;
-import androidx.annotation.Nullable;
import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.api.widget.Widget;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Album basic wrapper.
* Created by yanzhenjie on 17-3-29.
@@ -28,12 +30,16 @@
public abstract class BasicAlbumWrapper {
final Context mContext;
+ @Nullable
Action mResult;
+ @Nullable
Action mCancel;
+ @NonNull
Widget mWidget;
+ @Nullable
Checked mChecked;
- BasicAlbumWrapper(Context context) {
+ BasicAlbumWrapper(@NonNull Context context) {
this.mContext = context;
mWidget = Widget.getDefaultWidget(context);
}
@@ -43,7 +49,8 @@ public abstract class BasicAlbumWrapper result) {
+ @NonNull
+ public final Returner onResult(@Nullable Action result) {
this.mResult = result;
return (Returner) this;
}
@@ -53,7 +60,8 @@ public final Returner onResult(Action result) {
*
* @param cancel action when canceled.
*/
- public final Returner onCancel(Action cancel) {
+ @NonNull
+ public final Returner onCancel(@Nullable Action cancel) {
this.mCancel = cancel;
return (Returner) this;
}
@@ -63,7 +71,8 @@ public final Returner onCancel(Action cancel) {
*
* @param widget the widget.
*/
- public final Returner widget(@Nullable Widget widget) {
+ @NonNull
+ public final Returner widget(@NonNull Widget widget) {
this.mWidget = widget;
return (Returner) this;
}
diff --git a/album/src/main/java/com/yanzhenjie/album/api/BasicCameraWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/BasicCameraWrapper.java
index 40a52eb..d5869c3 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/BasicCameraWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/BasicCameraWrapper.java
@@ -20,55 +20,62 @@
import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.AlbumCameraFile;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Created by YanZhenjie on 2017/8/18.
*/
public abstract class BasicCameraWrapper {
-
+ @NonNull
Context mContext;
+ @Nullable
Action mResult;
+ @Nullable
Action mCancel;
+ @Nullable
String mFilePath;
-
- public BasicCameraWrapper(Context context) {
+
+ public BasicCameraWrapper(@NonNull Context context) {
this.mContext = context;
}
-
+
/**
* Set the action when result.
*
* @param result action when producing result.
*/
- public final Returner onResult(Action result) {
+ @NonNull
+ public final Returner onResult(@Nullable Action result) {
this.mResult = result;
return (Returner) this;
}
-
+
/**
* Set the action when canceling.
*
* @param cancel action when canceled.
*/
- public final Returner onCancel(Action cancel) {
+ @NonNull
+ public final Returner onCancel(@Nullable Action cancel) {
this.mCancel = cancel;
return (Returner) this;
}
-
+
/**
* Set the image storage path.
*
* @param filePath storage path.
*/
+ @NonNull
public Returner filePath(@Nullable String filePath) {
this.mFilePath = filePath;
return (Returner) this;
}
-
+
/**
* Start up.
*/
public abstract void start();
-
+
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/api/BasicChoiceWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/BasicChoiceWrapper.java
index b824689..d74b277 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/BasicChoiceWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/BasicChoiceWrapper.java
@@ -17,6 +17,8 @@
import android.content.Context;
import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.yanzhenjie.album.Filter;
@@ -40,6 +42,7 @@ public abstract class BasicChoiceWrapper filter) {
+ @NonNull
+ public Returner filterSize(@Nullable Filter filter) {
this.mSizeFilter = filter;
return (Returner) this;
}
@@ -70,7 +75,7 @@ public Returner filterSize(Filter filter) {
*
* @param filter filter.
*/
- public Returner filterMimeType(Filter filter) {
+ public Returner filterMimeType(@Nullable Filter filter) {
this.mMimeTypeFilter = filter;
return (Returner) this;
}
diff --git a/album/src/main/java/com/yanzhenjie/album/api/BasicGalleryWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/BasicGalleryWrapper.java
index cf3a0a4..3347031 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/BasicGalleryWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/BasicGalleryWrapper.java
@@ -17,6 +17,7 @@
import android.content.Context;
import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
import com.yanzhenjie.album.ItemAction;
@@ -32,7 +33,7 @@ public abstract class BasicGalleryWrapperGallery wrapper.
* Created by yanzhenjie on 17-3-29.
*/
public class GalleryAlbumWrapper extends BasicGalleryWrapper {
- public GalleryAlbumWrapper(Context context) {
+ public GalleryAlbumWrapper(@NonNull Context context) {
super(context);
}
diff --git a/album/src/main/java/com/yanzhenjie/album/api/ImageCameraWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/ImageCameraWrapper.java
index b548016..f5ca62e 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/ImageCameraWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/ImageCameraWrapper.java
@@ -21,16 +21,19 @@
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.app.camera.CameraActivity;
+import androidx.annotation.NonNull;
+
/**
* Camera wrapper.
* Created by Yan Zhenjie on 2017/4/18.
*/
public class ImageCameraWrapper extends BasicCameraWrapper {
- public ImageCameraWrapper(Context context) {
+ public ImageCameraWrapper(@NonNull Context context) {
super(context);
}
+ @Override
public void start() {
CameraActivity.sResult = mResult;
CameraActivity.sCancel = mCancel;
diff --git a/album/src/main/java/com/yanzhenjie/album/api/ImageMultipleWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/ImageMultipleWrapper.java
index 1b2c92b..2ddf6a6 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/ImageMultipleWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/ImageMultipleWrapper.java
@@ -17,7 +17,6 @@
import android.content.Context;
import android.content.Intent;
-import androidx.annotation.IntRange;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumFile;
@@ -25,6 +24,10 @@
import java.util.ArrayList;
+import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Created by YanZhenjie on 2017/8/16.
*/
@@ -33,7 +36,7 @@ public final class ImageMultipleWrapper extends BasicChoiceWrapper checked) {
+ @NonNull
+ public final ImageMultipleWrapper checkedList(@Nullable ArrayList checked) {
this.mChecked = checked;
return this;
}
@@ -52,6 +56,7 @@ public final ImageMultipleWrapper checkedList(ArrayList checked) {
*
* @param count the maximum number.
*/
+ @NonNull
public ImageMultipleWrapper selectCount(@IntRange(from = 1, to = Integer.MAX_VALUE) int count) {
this.mLimitCount = count;
return this;
diff --git a/album/src/main/java/com/yanzhenjie/album/api/VideoCameraWrapper.java b/album/src/main/java/com/yanzhenjie/album/api/VideoCameraWrapper.java
index bb6126e..240d0b0 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/VideoCameraWrapper.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/VideoCameraWrapper.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.Intent;
import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.app.camera.CameraActivity;
@@ -32,7 +33,7 @@ public class VideoCameraWrapper extends BasicCameraWrapper {
private long mLimitDuration = Integer.MAX_VALUE;
private long mLimitBytes = Integer.MAX_VALUE;
- public VideoCameraWrapper(Context context) {
+ public VideoCameraWrapper(@NonNull Context context) {
super(context);
}
@@ -41,6 +42,7 @@ public VideoCameraWrapper(Context context) {
*
* @param quality should be 0 or 1.
*/
+ @NonNull
public VideoCameraWrapper quality(@IntRange(from = 0, to = 1) int quality) {
this.mQuality = quality;
return this;
@@ -51,6 +53,7 @@ public VideoCameraWrapper quality(@IntRange(from = 0, to = 1) int quality) {
*
* @param duration the maximum number of seconds.
*/
+ @NonNull
public VideoCameraWrapper limitDuration(@IntRange(from = 1) long duration) {
this.mLimitDuration = duration;
return this;
@@ -61,11 +64,13 @@ public VideoCameraWrapper limitDuration(@IntRange(from = 1) long duration) {
*
* @param bytes the size of the byte.
*/
+ @NonNull
public VideoCameraWrapper limitBytes(@IntRange(from = 1) long bytes) {
this.mLimitBytes = bytes;
return this;
}
+ @Override
public void start() {
CameraActivity.sResult = mResult;
CameraActivity.sCancel = mCancel;
diff --git a/album/src/main/java/com/yanzhenjie/album/api/camera/AlbumCamera.java b/album/src/main/java/com/yanzhenjie/album/api/camera/AlbumCamera.java
index df4a41f..2a846cf 100644
--- a/album/src/main/java/com/yanzhenjie/album/api/camera/AlbumCamera.java
+++ b/album/src/main/java/com/yanzhenjie/album/api/camera/AlbumCamera.java
@@ -20,6 +20,8 @@
import com.yanzhenjie.album.api.ImageCameraWrapper;
import com.yanzhenjie.album.api.VideoCameraWrapper;
+import androidx.annotation.NonNull;
+
/**
* Created by YanZhenjie on 2017/8/18.
*/
@@ -27,15 +29,17 @@ public class AlbumCamera implements Camera sSizeFilter;
+ @Nullable
public static Filter sMimeFilter;
+ @Nullable
public static Filter sDurationFilter;
-
+
+ @Nullable
public static Action> sResult;
+ @Nullable
public static Action sCancel;
-
+
private List mAlbumFolders;
private int mCurrentFolder;
-
+
private Widget mWidget;
private int mFunction;
private int mChoiceMode;
private int mColumnCount;
private boolean mHasCamera;
private int mLimitCount;
-
+
private int mQuality;
private long mLimitDuration;
private long mLimitBytes;
-
+
private boolean mFilterVisibility;
-
+
private ArrayList mCheckedList;
private MediaScanner mMediaScanner;
-
+
private Contract.AlbumView mView;
private FolderDialog mFolderDialog;
private PopupMenu mCameraPopupMenu;
private LoadingDialog mLoadingDialog;
-
+
private MediaReadTask mMediaReadTask;
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -108,10 +114,10 @@ protected void onCreate(Bundle savedInstanceState) {
mView.setTitle(mWidget.getTitle());
mView.setCompleteDisplay(false);
mView.setLoadingDisplay(true);
-
+
requestPermission(PERMISSION_STORAGE, CODE_PERMISSION_STORAGE);
}
-
+
private void initializeArgument() {
Bundle argument = getIntent().getExtras();
assert argument != null;
@@ -126,7 +132,7 @@ private void initializeArgument() {
mLimitBytes = argument.getLong(Album.KEY_INPUT_CAMERA_BYTES);
mFilterVisibility = argument.getBoolean(Album.KEY_INPUT_FILTER_VISIBILITY);
}
-
+
/**
* Use different layouts depending on the style.
*
@@ -145,7 +151,7 @@ private int createView() {
}
}
}
-
+
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@@ -154,7 +160,7 @@ public void onConfigurationChanged(Configuration newConfig) {
mFolderDialog = null;
}
}
-
+
@Override
protected void onPermissionGranted(int code) {
ArrayList checkedList = getIntent().getParcelableArrayListExtra(Album.KEY_INPUT_CHECKED_LIST);
@@ -162,7 +168,7 @@ protected void onPermissionGranted(int code) {
mMediaReadTask = new MediaReadTask(mFunction, checkedList, mediaReader, this);
mMediaReadTask.execute();
}
-
+
@Override
protected void onPermissionDenied(int code) {
new AlertDialog.Builder(this)
@@ -177,9 +183,9 @@ public void onClick(DialogInterface dialog, int which) {
})
.show();
}
-
+
@Override
- public void onScanCallback(ArrayList albumFolders, ArrayList checkedFiles) {
+ public void onScanCallback(@NonNull ArrayList albumFolders, @NonNull ArrayList checkedFiles) {
mMediaReadTask = null;
switch (mChoiceMode) {
case Album.MODE_MULTIPLE: {
@@ -194,11 +200,11 @@ public void onScanCallback(ArrayList albumFolders, ArrayList albumFolders, ArrayList= mLimitCount) {
int messageRes;
@@ -313,7 +319,7 @@ public boolean onMenuItemClick(MenuItem item) {
}
}
}
-
+
private void takePicture() {
String filePath;
filePath = AlbumUtils.randomJPGPath(this.getApplicationContext());
@@ -329,7 +335,7 @@ private void takePicture() {
.onResult(mCameraAction)
.start();
}
-
+
private void takeVideo() {
String filePath;
// if (mCurrentFolder == 0) {
@@ -348,7 +354,7 @@ private void takeVideo() {
.onResult(mCameraAction)
.start();
}
-
+
private Action mCameraAction = new Action() {
@Override
public void onAction(@NonNull AlbumCameraFile result) {
@@ -361,13 +367,13 @@ public void onAction(@NonNull AlbumCameraFile result) {
task.execute(result.getPath());
}
};
-
+
@Override
public void onConvertStart() {
showLoadingDialog();
mLoadingDialog.setMessage(R.string.album_converting);
}
-
+
@Override
public void onConvertCallback(AlbumFile albumFile) {
albumFile.setChecked(!albumFile.isDisable());
@@ -380,10 +386,10 @@ public void onConvertCallback(AlbumFile albumFile) {
} else {
addFileToList(albumFile);
}
-
+
dismissLoadingDialog();
}
-
+
private void addFileToList(AlbumFile albumFile) {
if (mCurrentFolder != 0) {
List albumFiles = mAlbumFolders.get(0).getAlbumFiles();
@@ -393,7 +399,7 @@ private void addFileToList(AlbumFile albumFile) {
albumFiles.add(albumFile);
}
}
-
+
AlbumFolder albumFolder = mAlbumFolders.get(mCurrentFolder);
List albumFiles = albumFolder.getAlbumFiles();
if (albumFiles.isEmpty()) {
@@ -403,12 +409,12 @@ private void addFileToList(AlbumFile albumFile) {
albumFiles.add(0, albumFile);
mView.notifyInsertItem(mHasCamera ? 1 : 0);
}
-
+
mCheckedList.add(albumFile);
int count = mCheckedList.size();
mView.setCheckedCount(count);
mView.setSubTitle(count + "/" + mLimitCount);
-
+
switch (mChoiceMode) {
case Album.MODE_SINGLE: {
callbackResult();
@@ -423,9 +429,9 @@ private void addFileToList(AlbumFile albumFile) {
}
}
}
-
+
@Override
- public void tryCheckItem(CompoundButton button, int position) {
+ public void tryCheckItem(@NonNull CompoundButton button, int position) {
AlbumFile albumFile = mAlbumFolders.get(mCurrentFolder).getAlbumFiles().get(position);
if (button.isChecked()) {
if (mCheckedList.size() >= mLimitCount) {
@@ -460,13 +466,13 @@ public void tryCheckItem(CompoundButton button, int position) {
setCheckedCount();
}
}
-
+
private void setCheckedCount() {
int count = mCheckedList.size();
mView.setCheckedCount(count);
mView.setSubTitle(count + "/" + mLimitCount);
}
-
+
@Override
public void tryPreviewItem(int position) {
switch (mChoiceMode) {
@@ -476,7 +482,7 @@ public void tryPreviewItem(int position) {
// mView.notifyItem(position);
mCheckedList.add(albumFile);
setCheckedCount();
-
+
callbackResult();
break;
}
@@ -495,7 +501,7 @@ public void tryPreviewItem(int position) {
}
}
}
-
+
@Override
public void tryPreviewChecked() {
if (mCheckedList.size() > 0) {
@@ -508,31 +514,29 @@ public void tryPreviewChecked() {
startActivity(intent);
}
}
-
+
@Override
public void onPreviewComplete() {
callbackResult();
}
-
+
@Override
- public void onPreviewChanged(AlbumFile albumFile) {
+ public void onPreviewChanged(@NonNull AlbumFile albumFile) {
ArrayList albumFiles = mAlbumFolders.get(mCurrentFolder).getAlbumFiles();
int position = albumFiles.indexOf(albumFile);
int notifyPosition = mHasCamera ? position + 1 : position;
mView.notifyItem(notifyPosition);
-
+
if (albumFile.isChecked()) {
if (!mCheckedList.contains(albumFile)) {
mCheckedList.add(albumFile);
}
} else {
- if (mCheckedList.contains(albumFile)) {
- mCheckedList.remove(albumFile);
- }
+ mCheckedList.remove(albumFile);
}
setCheckedCount();
}
-
+
@Override
public void complete() {
if (mCheckedList.isEmpty()) {
@@ -559,7 +563,7 @@ public void complete() {
callbackResult();
}
}
-
+
@Override
public void onBackPressed() {
if (mMediaReadTask != null) {
@@ -567,7 +571,7 @@ public void onBackPressed() {
}
callbackCancel();
}
-
+
/**
* Callback result action.
*/
@@ -575,22 +579,22 @@ private void callbackResult() {
ThumbnailBuildTask task = new ThumbnailBuildTask(this.getApplicationContext(), mCheckedList, this);
task.execute();
}
-
+
@Override
public void onThumbnailStart() {
showLoadingDialog();
mLoadingDialog.setMessage(R.string.album_thumbnail);
}
-
+
@Override
- public void onThumbnailCallback(ArrayList albumFiles) {
+ public void onThumbnailCallback(@NonNull ArrayList albumFiles) {
if (sResult != null) {
sResult.onAction(albumFiles);
}
dismissLoadingDialog();
finish();
}
-
+
/**
* Callback cancel action.
*/
@@ -600,7 +604,7 @@ private void callbackCancel() {
}
finish();
}
-
+
/**
* Display loading dialog.
*/
@@ -613,7 +617,7 @@ private void showLoadingDialog() {
mLoadingDialog.show();
}
}
-
+
/**
* Dismiss loading dialog.
*/
@@ -622,7 +626,7 @@ public void dismissLoadingDialog() {
mLoadingDialog.dismiss();
}
}
-
+
@Override
public void finish() {
sSizeFilter = null;
diff --git a/album/src/main/java/com/yanzhenjie/album/app/album/GalleryActivity.java b/album/src/main/java/com/yanzhenjie/album/app/album/GalleryActivity.java
index a4e1ae0..6b9dd85 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/album/GalleryActivity.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/album/GalleryActivity.java
@@ -16,6 +16,8 @@
package com.yanzhenjie.album.app.album;
import android.os.Bundle;
+
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.yanzhenjie.album.Album;
@@ -193,6 +195,6 @@ public interface Callback {
*
* @param albumFile target item.
*/
- void onPreviewChanged(AlbumFile albumFile);
+ void onPreviewChanged(@NonNull AlbumFile albumFile);
}
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/app/album/data/MediaReadTask.java b/album/src/main/java/com/yanzhenjie/album/app/album/data/MediaReadTask.java
index 055c343..f4b551f 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/album/data/MediaReadTask.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/album/data/MediaReadTask.java
@@ -24,6 +24,9 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Image scan task.
* Created by Yan Zhenjie on 2017/3/28.
@@ -36,7 +39,7 @@ public interface Callback {
*
* @param albumFolders album folder list.
*/
- void onScanCallback(ArrayList albumFolders, ArrayList checkedFiles);
+ void onScanCallback(@NonNull ArrayList albumFolders, @NonNull ArrayList checkedFiles);
}
static class ResultWrapper {
@@ -49,15 +52,16 @@ static class ResultWrapper {
private MediaReader mMediaReader;
private Callback mCallback;
- public MediaReadTask(int function, List checkedFiles, MediaReader mediaReader, Callback callback) {
+ public MediaReadTask(int function, @Nullable List checkedFiles, @NonNull MediaReader mediaReader, @NonNull Callback callback) {
this.mFunction = function;
this.mCheckedFiles = checkedFiles;
this.mMediaReader = mediaReader;
this.mCallback = callback;
}
+ @NonNull
@Override
- protected ResultWrapper doInBackground(Void... params) {
+ protected ResultWrapper doInBackground(@Nullable Void... params) {
ArrayList albumFolders;
switch (mFunction) {
case Album.FUNCTION_CHOICE_IMAGE: {
@@ -98,7 +102,7 @@ protected ResultWrapper doInBackground(Void... params) {
}
@Override
- protected void onPostExecute(ResultWrapper wrapper) {
+ protected void onPostExecute(@NonNull ResultWrapper wrapper) {
mCallback.onScanCallback(wrapper.mAlbumFolders, wrapper.mAlbumFiles);
}
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/app/album/data/ThumbnailBuildTask.java b/album/src/main/java/com/yanzhenjie/album/app/album/data/ThumbnailBuildTask.java
index 8b6f1be..bedf4e2 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/album/data/ThumbnailBuildTask.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/album/data/ThumbnailBuildTask.java
@@ -22,32 +22,35 @@
import java.util.ArrayList;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Created by YanZhenjie on 2017/10/15.
*/
public class ThumbnailBuildTask extends AsyncTask> {
-
+
public interface Callback {
/**
* The task begins.
*/
void onThumbnailStart();
-
+
/**
* Callback results.
*
* @param albumFiles result.
*/
- void onThumbnailCallback(ArrayList albumFiles);
+ void onThumbnailCallback(@NonNull ArrayList albumFiles);
}
-
+
private ArrayList mAlbumFiles;
private Callback mCallback;
-
+
private ThumbnailBuilder mThumbnailBuilder;
private Context mContext;
-
- public ThumbnailBuildTask(Context context, ArrayList albumFiles, Callback callback) {
+
+ public ThumbnailBuildTask(@NonNull Context context, @Nullable ArrayList albumFiles, @NonNull Callback callback) {
this.mAlbumFiles = albumFiles;
if (mAlbumFiles == null) {
mAlbumFiles = new ArrayList<>();
@@ -56,27 +59,28 @@ public ThumbnailBuildTask(Context context, ArrayList albumFiles, Call
this.mContext = context;
this.mThumbnailBuilder = new ThumbnailBuilder(mContext);
}
-
+
@Override
protected void onPreExecute() {
mCallback.onThumbnailStart();
}
-
+
+ @NonNull
@Override
- protected ArrayList doInBackground(Void... params) {
+ protected ArrayList doInBackground(@NonNull Void... params) {
for (AlbumFile albumFile : mAlbumFiles) {
int mediaType = albumFile.getMediaType();
if (mediaType == AlbumFile.TYPE_IMAGE) {
- albumFile.setThumbPath(mThumbnailBuilder.createThumbnailForImage(mContext, albumFile.getUri(), albumFile.getMimeType()));
+ albumFile.setThumbUri(mThumbnailBuilder.createThumbnailForImage(mContext, albumFile.getUri(), albumFile.getMimeType()));
} else if (mediaType == AlbumFile.TYPE_VIDEO) {
- albumFile.setThumbPath(mThumbnailBuilder.createThumbnailForVideo(mContext, albumFile.getUri()));
+ albumFile.setThumbUri(mThumbnailBuilder.createThumbnailForVideo(mContext, albumFile.getUri()));
}
}
return mAlbumFiles;
}
-
+
@Override
- protected void onPostExecute(ArrayList albumFiles) {
+ protected void onPostExecute(@NonNull ArrayList albumFiles) {
mCallback.onThumbnailCallback(albumFiles);
}
}
\ No newline at end of file
diff --git a/album/src/main/java/com/yanzhenjie/album/app/camera/CameraActivity.java b/album/src/main/java/com/yanzhenjie/album/app/camera/CameraActivity.java
index 64a6c5c..6e4fefc 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/camera/CameraActivity.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/camera/CameraActivity.java
@@ -50,8 +50,10 @@ public class CameraActivity extends BaseActivity {
private static final int CODE_ACTIVITY_TAKE_IMAGE = 1;
private static final int CODE_ACTIVITY_TAKE_VIDEO = 2;
-
+
+ @Nullable
public static Action sResult;
+ @Nullable
public static Action sCancel;
private int mFunction;
diff --git a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryAlbumActivity.java b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryAlbumActivity.java
index 9ace4db..25080d3 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryAlbumActivity.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryAlbumActivity.java
@@ -16,7 +16,6 @@
package com.yanzhenjie.album.app.gallery;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.Album;
@@ -30,15 +29,21 @@
import java.util.ArrayList;
+import androidx.annotation.Nullable;
+
/**
* Created by YanZhenjie on 2017/8/16.
*/
public class GalleryAlbumActivity extends BaseActivity implements Contract.GalleryPresenter {
+ @Nullable
public static Action> sResult;
+ @Nullable
public static Action sCancel;
+ @Nullable
public static ItemAction sClick;
+ @Nullable
public static ItemAction sLongClick;
private Widget mWidget;
@@ -75,7 +80,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
private void setCheckedCount() {
int checkedCount = 0;
for (AlbumFile albumFile : mAlbumFiles) {
- if (albumFile.isChecked()) checkedCount += 1;
+ if (albumFile.isChecked()) {
+ checkedCount += 1;
+ }
}
String completeText = getString(R.string.album_menu_finish);
@@ -103,15 +110,21 @@ public void onCurrentChanged(int position) {
mView.setSubTitle(position + 1 + " / " + mAlbumFiles.size());
AlbumFile albumFile = mAlbumFiles.get(position);
- if (mCheckable) mView.setChecked(albumFile.isChecked());
+ if (mCheckable) {
+ mView.setChecked(albumFile.isChecked());
+ }
mView.setLayerDisplay(albumFile.isDisable());
if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
- if (!mCheckable) mView.setBottomDisplay(true);
+ if (!mCheckable) {
+ mView.setBottomDisplay(true);
+ }
mView.setDuration(AlbumUtils.convertDuration(albumFile.getDuration()));
mView.setDurationDisplay(true);
} else {
- if (!mCheckable) mView.setBottomDisplay(false);
+ if (!mCheckable) {
+ mView.setBottomDisplay(false);
+ }
mView.setDurationDisplay(false);
}
}
@@ -129,7 +142,9 @@ public void complete() {
if (sResult != null) {
ArrayList checkedList = new ArrayList<>();
for (AlbumFile albumFile : mAlbumFiles) {
- if (albumFile.isChecked()) checkedList.add(albumFile);
+ if (albumFile.isChecked()) {
+ checkedList.add(albumFile);
+ }
}
sResult.onAction(checkedList);
}
@@ -138,7 +153,9 @@ public void complete() {
@Override
public void onBackPressed() {
- if (sCancel != null) sCancel.onAction("User canceled.");
+ if (sCancel != null) {
+ sCancel.onAction("User canceled.");
+ }
finish();
}
diff --git a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
index c866a42..d8e7bfe 100644
--- a/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
+++ b/album/src/main/java/com/yanzhenjie/album/app/gallery/GalleryView.java
@@ -20,11 +20,6 @@
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.view.ViewCompat;
-import androidx.viewpager.widget.ViewPager;
-import androidx.appcompat.widget.AppCompatCheckBox;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -42,6 +37,12 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatCheckBox;
+import androidx.core.widget.CompoundButtonCompat;
+import androidx.viewpager.widget.ViewPager;
+
/**
* Created by YanZhenjie on 2018/4/9.
*/
@@ -97,7 +98,7 @@ public void setupViews(Widget widget, boolean checkable) {
mCheckBox.setVisibility(View.GONE);
} else {
ColorStateList itemSelector = widget.getMediaItemCheckSelector();
- mCheckBox.setSupportButtonTintList(itemSelector);
+ CompoundButtonCompat.setButtonTintList(mCheckBox, itemSelector);
mCheckBox.setTextColor(itemSelector);
}
@@ -112,12 +113,14 @@ public void onPageSelected(int position) {
@Override
public void bindData(List dataList) {
PreviewAdapter adapter = new PreviewAdapter(getContext(), dataList) {
-
+
@NonNull
@Override
protected View getView(Context context, Data item, int position, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener) {
if (item instanceof Uri) {
return Album.getAlbumConfig().getAlbumLoader().getPreviewView(context, (Uri) item, onClickListener, longClickListener);
+ } else if (item instanceof String) {
+ return Album.getAlbumConfig().getAlbumLoader().getPreviewView(context, Uri.parse((String) item), onClickListener, longClickListener);
} else if (item instanceof AlbumFile) {
return Album.getAlbumConfig().getAlbumLoader().getPreviewView(context, (AlbumFile) item, onClickListener, longClickListener);
} else {
diff --git a/build.gradle b/build.gradle
index 69fa189..ab2f6cd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
diff --git a/gradle.properties b/gradle.properties
index a964ca0..f32badb 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,7 +1,3 @@
android.enableJetifier=true
android.useAndroidX=true
-org.gradle.jvmargs=-Xmx1536m
-#systemProp.http.proxyHost=127.0.0.1
-#systemProp.http.proxyPort=12333
-#systemProp.https.proxyHost=127.0.0.1
-#systemProp.https.proxyPort=12333
\ No newline at end of file
+org.gradle.jvmargs=-Xmx1536m
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 4eafe8e..b1db12b 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Thu Jul 23 17:11:57 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
\ No newline at end of file
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/sample/build.gradle b/sample/build.gradle
index 0f533df..8307a4f 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -22,9 +22,9 @@ dependencies {
implementation project(":album")
// implementation rootProject.ext.dependencies.album
implementation 'com.facebook.fresco:fresco:2.1.0'
- implementation "com.github.piasy:BigImageViewer:1.6.2"
- implementation "com.github.piasy:FrescoImageLoader:1.6.2"
- implementation 'com.github.piasy:FrescoImageViewFactory:1.6.2'
+ implementation "com.github.piasy:BigImageViewer:1.6.5"
+ implementation "com.github.piasy:FrescoImageLoader:1.6.5"
+ implementation 'com.github.piasy:FrescoImageViewFactory:1.6.5'
implementation rootProject.ext.dependencies.appCompat
implementation rootProject.ext.dependencies.design
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/Application.java b/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
index a5b9e9d..38eaa77 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/Application.java
@@ -27,16 +27,16 @@
* Created by Yan Zhenjie on 2016/10/30.
*/
public class Application extends android.app.Application {
-
+
private static Application instance;
-
+
@Override
public void onCreate() {
super.onCreate();
if (instance == null) {
instance = this;
BigImageViewer.initialize(FrescoImageLoader.with(instance));
-
+
Album.initialize(AlbumConfig.newBuilder(this)
// .setAlbumLoader(new MediaLoader())
.setAlbumLoader(new FrescoLoader())
@@ -45,7 +45,7 @@ public void onCreate() {
);
}
}
-
+
public static Application getInstance() {
return instance;
}
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
index 6acd484..0675797 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
@@ -54,7 +54,7 @@ public void load(ImageView imageView, AlbumFile albumFile) {
@Override
public void load(ImageView imageView, Uri uri) {
if (imageView instanceof SimpleDraweeView) {
- ((SimpleDraweeView) imageView).setImageURI(uri);
+ imageView.setImageURI(uri);
}
}
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java b/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
index 8e7f5d1..51feb37 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/app/GalleryActivity.java
@@ -16,10 +16,6 @@
package com.yanzhenjie.album.sample.app;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
@@ -32,32 +28,56 @@
import java.util.ArrayList;
import java.util.Collections;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
/**
* Created by YanZhenjie on 2017/8/17.
*/
public class GalleryActivity extends AppCompatActivity {
private static final String[] IMAGE_PATH_LIST = {
- "http://pic1.win4000.com/mobile/1/520d9410ebc79.jpg", "http://pic1.win4000.com/mobile/1/520d941218b04.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925tn4a5sz3at2.jpg", "http://wapfile.desktx.com/7681280/0925/160925ruuqfaqwuvx.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925a0x5knyt3ue.jpg", "http://wapfile.desktx.com/7681280/0925/160925jrfl5dnvln1.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925csx5pu2ysam.jpg", "http://wapfile.desktx.com/7681280/0925/160925m4lgeuakuc5.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925gcmbg5gycqw.jpg", "http://wapfile.desktx.com/7681280/0925/160925o0zf2pbozw1.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925danhsef1uzu.jpg", "http://wapfile.desktx.com/7681280/0925/160925y5lmcrqslm4.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925njt3dm2hlw0.jpg", "http://wapfile.desktx.com/7681280/0925/160925xgesspjxztt.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925a5dg2zsddtx.jpg", "http://wapfile.desktx.com/7681280/0925/1609252fupmrdasrp.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925lasaphesxkd.jpg", "http://wapfile.desktx.com/7681280/0925/160925ti2kged45bp.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925dsx3uyapoen.jpg", "http://wapfile.desktx.com/7681280/0925/160925largrb3p2l4.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925l0vaht45uy1.jpg", "http://wapfile.desktx.com/7681280/0925/160925054jrhaerro.jpg",
- "http://wapfile.desktx.com/7681280/0925/1609255mlt2so5yp2.jpg", "http://wapfile.desktx.com/7681280/0925/160925bm3jmwdptie.jpg",
- "http://wapfile.desktx.com/7681280/0925/1609251brfaryoizu.jpg", "http://wapfile.desktx.com/7681280/0925/1609254qfjkbwjlox.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925memb5c4pcnt.jpg", "http://wapfile.desktx.com/7681280/0925/160925c5i4dbhh2rh.jpg",
- "http://wapfile.desktx.com/7681280/0925/1609254pmjqhppmah.jpg", "http://wapfile.desktx.com/7681280/0925/16092505gvkuoampz.jpg",
- "http://wapfile.desktx.com/7681280/0925/1609254dxk3vpsrvj.jpg", "http://wapfile.desktx.com/7681280/0925/160925bgyxuik3j4y.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925jbhhtendosg.jpg", "http://wapfile.desktx.com/7681280/0925/160925knnv51uglia.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925vajxn2aqfkc.jpg", "http://wapfile.desktx.com/7681280/0925/160925xehnehy5frf.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925e2rajc4zi4k.jpg", "http://wapfile.desktx.com/7681280/0925/160925dfxg2wlarga.jpg",
- "http://wapfile.desktx.com/7681280/0925/160925vuifhcqactt.jpg", "http://wapfile.desktx.com/7681280/0925/160925rcxiez3ikcg.jpg"
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511268196&di=a17c805213846a55eb067565cda0ae0f&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170314%2F20170314093020_61f5e1c760157917576b50b62bc59c80_7.jpeg", "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298118&di=263456f22d8b03397cc467c82c9cd195&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20181003%2F0f8307fe3de6468d8b51c53b276e9e1b.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298118&di=b2944fc7eef07d274d629ba9a2eff5be&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fd%2F574bd264dc04f.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298118&di=f6e60ae16352a14b848dba216af784f4&imgtype=0&src=http%3A%2F%2Fp0.qhimg.com%2Ft01dc11f29c01424c6d.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298114&di=156b200f20eb702f2ad3ba8fc5b55ba2&imgtype=0&src=http%3A%2F%2Fpic.feizl.com%2Fupload%2Fallimg%2F170614%2F1410251g5-0.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298114&di=2194e443572fcac6b86e8ca9a3eb9acc&imgtype=0&src=http%3A%2F%2F00.minipic.eastday.com%2F20170303%2F20170303140548_7cb2d40a62600c2ee10f9c826dedfb8b_9.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298112&di=69a2ac37a9b763829f3c26195a7fcbf0&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn18%2F410%2Fw1470h2140%2F20180525%2F59be-haysviy8786664.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298111&di=40e9330ad50aafb884d6699801f1d2d2&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2F2%2F48%2F542c1208181.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298110&di=039ff5882950f28189cea1ad6f1a25e4&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fb%2F5680fcc0d31b2.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298110&di=ed3cf8b466ca36997ce94201f392d8c7&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2Fa%2F64%2F79121317058.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298109&di=c95f19699712aa1c51b3bff4f0f6a0cc&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170421%2F20170421142504_aa430cd7552a22e19a91054d15ae0905_14.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298109&di=8ce9291fd03a7e225cfe0f4cf4524769&imgtype=0&src=http%3A%2F%2Fimage.hnol.net%2Fc%2F2013-03%2F20%2F19%2F20130320191211951-2089977.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298256&di=51e80d7ccbda7e72856a9db4d0961afa&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201707%2F17%2F20170717230736_RWUmT.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298255&di=8ec2d086beaa20b3414eb357c4bd2286&imgtype=0&src=http%3A%2F%2Fimg.pconline.com.cn%2Fimages%2Fupload%2Fupc%2Ftx%2Fphotoblog%2F1405%2F28%2Fc3%2F34712742_34712742_1401260899709.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298256&di=d2a6ce2938738d40ae62119e68573b18&imgtype=0&src=http%3A%2F%2Fimg4.cache.netease.com%2Fphoto%2F0026%2F2013-07-08%2F938RKTEP43AJ0026.JPG",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298255&di=fa5fbffe31186ea20df334ab4063725c&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170306%2F20170306111324_d2b7a6d928ad827f4db19f355b9550d4_5.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298255&di=da54af6be9cce91a57426f9cb684d49f&imgtype=0&src=http%3A%2F%2Fi3.17173.itc.cn%2F2008%2Fjr%2F2008%2F11%2F20%2F8.JPG",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298255&di=850c6e1979c1cac2faebe91ec910913a&imgtype=0&src=http%3A%2F%2Fimage.hnol.net%2Fc%2F2016-01%2F30%2F18%2F201601301826324531-3356886.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298254&di=5bc035ef1f5ac4ffb90fbf6fe62027ae&imgtype=0&src=http%3A%2F%2Fp0.ifengimg.com%2Fa%2F2016_33%2Fb9050beb18718b0_size524_w3885_h2745.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298254&di=8cb3d6fac8e62a0291aabde8aad08dab&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20190126%2F6727836cd8c84e3f9f02ecb97f4cc5cc.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298254&di=43f222be11c12cbf8cc77ca55ca08c11&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170506%2F20170506134244_50112ebd2eb624744aa8b957008a8d71_4.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511954989&di=8a4a9739fab70902712c00ff9828428f&imgtype=0&src=http%3A%2F%2Fimg4.imgtn.bdimg.com%2Fit%2Fu%3D3556124484%2C830383795%26fm%3D214%26gp%3D0.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298253&di=82c1aff5dfde5886b2f10338d7733dc0&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F2018-09-10%2F5b961ed1809f1.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298253&di=65206968f3d93a8e8ad4783356d7fd87&imgtype=0&src=http%3A%2F%2F00.minipic.eastday.com%2F20170122%2F20170122133549_02dc7a8d994ea57c5a7c11421a56eb2f_2.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298253&di=8aa1beeca9e2274fc8bc7055fd815d0f&imgtype=0&src=http%3A%2F%2F00.minipic.eastday.com%2F20170417%2F20170417154748_f05b8931f7bed94d8a76e9f96d784a8b_9.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298253&di=f5fa7bfe3aed8d636fa8716738415d90&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2F7%2F07%2F26501170849.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298253&di=05e0dd05b7ea3e283bcc4a9f189970b5&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn10111%2F710%2Fw1600h2310%2F20181207%2F8102-hpinryc5855494.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298252&di=03c16c31e38886781a1ed04fe3a1f986&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2F7%2Fe8%2Fa8781211260.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298252&di=efc9e9755ae73cfcbeeefc8088165ac1&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170421%2F20170421142504_aa430cd7552a22e19a91054d15ae0905_9.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298252&di=d68706f875990e682a152292beb7bbb3&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170519%2F20170519154440_0791cfd6f5d25410bcde032e77afb40d_2.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298251&di=0064201bef322ecfdc7359f7bbdabb7e&imgtype=0&src=http%3A%2F%2Fwww.deskcar.com%2Fdesktop%2Fstar%2Fchina%2F20151124212913%2F7.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298251&di=41c055afa9f969fa4096fd44e41dc094&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2F5%2F39%2F58581218506.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298251&di=5ebc26be806759d833492f14887fe6bb&imgtype=0&src=http%3A%2F%2Fwww.flybridal.com%2Fhuangse%2FaHR0cDovL3BpYzEud2luNDAwMC5jb20vcGljL2YvMzMvM2I5YjMwMTQyNi5qcGc%3D.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298250&di=237cae63df3dad5ef3a8a61acf6e36b9&imgtype=0&src=http%3A%2F%2Fimg.pconline.com.cn%2Fimages%2Fupload%2Fupc%2Ftx%2Fphotoblog%2F1111%2F24%2Fc2%2F9721899_9721899_1322103707644.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298249&di=79bc09a920abfc3601420db91e3c759d&imgtype=0&src=http%3A%2F%2F00.minipic.eastday.com%2F20170407%2F20170407091825_3cbfafdd9a6fe547be7cab4ae702077e_2.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511298248&di=105a164fdb6c8192b2a8576bcc1250cb&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20181125%2F5369ec03f8274b4c889537fea5b635e9.jpeg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511994779&di=99bddb40e08488550d893ebf8f0ff892&imgtype=0&src=http%3A%2F%2Fimg.improve-yourmemory.com%2Fpic%2F913f45ee741278fc4213e5d861fe2acb-4.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511994779&di=170a327f5f388d45aeafd88a5775c727&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fpic%2F0%2F29%2F163a1215183.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511994778&di=1a37f80710cd3dd09aed0e0ee3fdf772&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F1%2F50655aa104436.jpg",
+ "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595511994777&di=d1feb652465b5af592a82f2b6c36a1bc&imgtype=0&src=http%3A%2F%2F01.minipic.eastday.com%2F20170308%2F20170308093953_6e555cf710ad2a15a03ef91239032c85_4.jpeg"
};
private Toolbar mToolbar;
@@ -80,25 +100,30 @@ public void onClick(View v) {
});
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
private void previewImages() {
ArrayList imageList = new ArrayList<>();
Collections.addAll(imageList, IMAGE_PATH_LIST);
Album.gallery(this)
- .checkedList(imageList)
- .checkable(mCheckBox.isChecked())
- .widget(
- Widget.newDarkBuilder(this)
- .title(mToolbar.getTitle().toString())
- .build()
- )
- .onResult(new Action>() {
- @Override
- public void onAction(@NonNull ArrayList result) {
- // TODO If it is optional, here you can accept the results of user selection.
- }
- })
- .start();
+ .checkedList(imageList)
+ .checkable(mCheckBox.isChecked())
+ .widget(
+ Widget.newDarkBuilder(this)
+ .title(mToolbar.getTitle().toString())
+ .build()
+ )
+ .onResult(new Action>() {
+ @Override
+ public void onAction(@NonNull ArrayList result) {
+ // TODO If it is optional, here you can accept the results of user selection.
+ }
+ })
+ .start();
}
@Override
@@ -113,8 +138,4 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- }
}
From 83a7b3aa31c2e00b58e236521e568514fdfece51 Mon Sep 17 00:00:00 2001
From: LiuJun
Date: Fri, 7 Aug 2020 16:35:47 +0800
Subject: [PATCH 4/6] release 3.0.1
---
README.md | 8 ++-
.../com/yanzhenjie/album/AlbumLoader.java | 55 +++++++++++++------
build.gradle | 4 --
config.gradle | 48 ++++++++--------
gradlew | 0
.../yanzhenjie/album/sample/FrescoLoader.java | 8 +--
.../yanzhenjie/album/sample/MediaLoader.java | 8 +--
7 files changed, 78 insertions(+), 53 deletions(-)
mode change 100644 => 100755 gradlew
diff --git a/README.md b/README.md
index 4ad209d..8939cab 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,13 @@ Effect on landscape screen:
## Download
```groovy
-implementation 'com.yanzhenjie:album:2.1.3'
+repositories {
+ maven { url "https://jitpack.io" }
+}
+
+dependencies {
+ compile 'com.github.imliujun:album:3.0.1'
+}
```
## Usage
diff --git a/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java b/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
index 7003b47..eb90acf 100644
--- a/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
+++ b/album/src/main/java/com/yanzhenjie/album/AlbumLoader.java
@@ -17,11 +17,12 @@
import android.content.Context;
import android.net.Uri;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
/**
* Used to load the preview, it should be customized.
* Created by Yan Zhenjie on 2017/3/31.
@@ -30,25 +31,31 @@ public interface AlbumLoader {
AlbumLoader DEFAULT = new AlbumLoader() {
@Override
- public void load(ImageView imageView, AlbumFile albumFile) {
+ public void load(@NonNull ImageView imageView, @NonNull AlbumFile albumFile) {
}
@Override
- public void load(ImageView imageView, Uri url) {
+ public void load(@NonNull ImageView imageView, @NonNull Uri url) {
}
-
+
@NonNull
@Override
- public View getPreviewView(Context context, AlbumFile albumFile, View.OnClickListener onClickListener, View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context,
+ @NonNull AlbumFile albumFile,
+ View.OnClickListener onClickListener,
+ View.OnClickListener longClickListener) {
return new ImageView(context);
}
-
+
@NonNull
@Override
- public View getPreviewView(Context context, Uri uri, View.OnClickListener onClickListener, View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context,
+ @NonNull Uri uri,
+ View.OnClickListener onClickListener,
+ View.OnClickListener longClickListener) {
return new ImageView(context);
}
-
+
};
/**
@@ -57,7 +64,7 @@ public View getPreviewView(Context context, Uri uri, View.OnClickListener onClic
* @param imageView {@link ImageView}.
* @param albumFile the media object may be a picture or video.
*/
- void load(ImageView imageView, AlbumFile albumFile);
+ void load(@NonNull ImageView imageView, @NonNull AlbumFile albumFile);
/**
* Load thumbnails of pictures or videos, either local file or remote file.
@@ -65,12 +72,28 @@ public View getPreviewView(Context context, Uri uri, View.OnClickListener onClic
* @param imageView {@link ImageView}.
* @param uri The uri of the file, local path or remote path.
*/
- void load(ImageView imageView, Uri uri);
-
+ void load(@NonNull ImageView imageView, @NonNull Uri uri);
+
+ /**
+ * 获取大图预览的 View,开发者可以自由使用自己加载大图的组件
+ *
+ * @return 加载大图的组件
+ */
@NonNull
- View getPreviewView(Context context, AlbumFile albumFile, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener);
-
+ View getPreviewView(@NonNull Context context,
+ @NonNull AlbumFile albumFile,
+ @Nullable View.OnClickListener onClickListener,
+ @Nullable View.OnClickListener longClickListener);
+
+ /**
+ * 获取大图预览的 View,开发者可以自由使用自己加载大图的组件
+ *
+ * @return 加载大图的组件
+ */
@NonNull
- View getPreviewView(Context context, Uri uri, @Nullable View.OnClickListener onClickListener, @Nullable View.OnClickListener longClickListener);
-
+ View getPreviewView(@NonNull Context context,
+ @NonNull Uri uri,
+ @Nullable View.OnClickListener onClickListener,
+ @Nullable View.OnClickListener longClickListener);
+
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index ab2f6cd..9299632 100644
--- a/build.gradle
+++ b/build.gradle
@@ -21,7 +21,3 @@ allprojects {
}
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
\ No newline at end of file
diff --git a/config.gradle b/config.gradle
index 53ac197..4c1ad59 100644
--- a/config.gradle
+++ b/config.gradle
@@ -18,30 +18,30 @@ ext {
versionName : "2.1.3",
]
- bintray = [
- version : "2.1.3",
-
- siteUrl : 'https://github.com/yanzhenjie/Album',
- gitUrl : 'git@github.com:yanzhenjie/Album.git',
-
- group : "com.yanzhenjie",
-
- packaging : 'aar',
- name : 'Album',
- description : 'Album for android',
-
- licenseName : 'The Apache Software License, Version 2.0',
- licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.txt',
-
- developerId : 'yanzhenjie',
- developerName : 'yanzhenjie',
- developerEmail: 'smallajax@foxmail.com',
-
- binrayLibrary : "Album",
- bintrayRepo : "maven",
- bintrayUser : 'yolanda',
- bintrayLicense: "Apache-2.0"
- ]
+ // bintray = [
+ // version : "2.1.3",
+ //
+ // siteUrl : 'https://github.com/yanzhenjie/Album',
+ // gitUrl : 'git@github.com:yanzhenjie/Album.git',
+ //
+ // group : "com.yanzhenjie",
+ //
+ // packaging : 'aar',
+ // name : 'Album',
+ // description : 'Album for android',
+ //
+ // licenseName : 'The Apache Software License, Version 2.0',
+ // licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.txt',
+ //
+ // developerId : 'yanzhenjie',
+ // developerName : 'yanzhenjie',
+ // developerEmail: 'smallajax@foxmail.com',
+ //
+ // binrayLibrary : "Album",
+ // bintrayRepo : "maven",
+ // bintrayUser : 'yolanda',
+ // bintrayLicense: "Apache-2.0"
+ // ]
dependencies = [
mediaScanner: 'com.yanzhenjie:mediascanner:1.0.3',
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
index 0675797..9aee03d 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/FrescoLoader.java
@@ -47,12 +47,12 @@
public class FrescoLoader implements AlbumLoader {
@Override
- public void load(ImageView imageView, AlbumFile albumFile) {
+ public void load(@NonNull ImageView imageView, @NonNull AlbumFile albumFile) {
load(imageView, albumFile.getUri());
}
@Override
- public void load(ImageView imageView, Uri uri) {
+ public void load(@NonNull ImageView imageView, @NonNull Uri uri) {
if (imageView instanceof SimpleDraweeView) {
imageView.setImageURI(uri);
}
@@ -60,7 +60,7 @@ public void load(ImageView imageView, Uri uri) {
@NonNull
@Override
- public View getPreviewView(Context context, AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context, @NonNull AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
final AttacherImageView view = new AttacherImageView(context);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
@@ -103,7 +103,7 @@ public boolean onLongClick(View v) {
@NonNull
@Override
- public View getPreviewView(Context context, Uri uri, @Nullable View.OnClickListener onClickListener, final @Nullable View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context, @NonNull Uri uri, @Nullable View.OnClickListener onClickListener, final @Nullable View.OnClickListener longClickListener) {
final BigImageView view = new BigImageView(context);
view.setImageViewFactory(new FrescoImageViewFactory());
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
index 10938ce..dcf2df3 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
@@ -35,12 +35,12 @@
public class MediaLoader implements AlbumLoader {
@Override
- public void load(ImageView imageView, AlbumFile albumFile) {
+ public void load(@NonNull ImageView imageView, @NonNull AlbumFile albumFile) {
load(imageView, albumFile.getUri());
}
@Override
- public void load(ImageView imageView, Uri uri) {
+ public void load(@NonNull ImageView imageView, @NonNull Uri uri) {
Glide.with(imageView.getContext())
.load(uri)
.error(R.drawable.placeholder)
@@ -51,13 +51,13 @@ public void load(ImageView imageView, Uri uri) {
@NonNull
@Override
- public View getPreviewView(Context context, AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context, @NonNull AlbumFile albumFile, final View.OnClickListener onClickListener, final View.OnClickListener longClickListener) {
return getPreviewView(context, albumFile.getUri(), onClickListener, longClickListener);
}
@NonNull
@Override
- public View getPreviewView(Context context, Uri uri, @Nullable final View.OnClickListener onClickListener, @Nullable final View.OnClickListener longClickListener) {
+ public View getPreviewView(@NonNull Context context, @NonNull Uri uri, @Nullable final View.OnClickListener onClickListener, @Nullable final View.OnClickListener longClickListener) {
final AttacherImageView view = new AttacherImageView(context);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
load(view, uri);
From 98ce52e8144fa5f40dfbf0a1e7d11cfddc43b341 Mon Sep 17 00:00:00 2001
From: LiuJun
Date: Fri, 7 Aug 2020 17:14:43 +0800
Subject: [PATCH 5/6] release 3.0.2
---
album/build.gradle | 1 +
build.gradle | 4 ++++
config.gradle | 48 +++++++++++++++++++++++-----------------------
3 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/album/build.gradle b/album/build.gradle
index a248f6b..3aa559f 100644
--- a/album/build.gradle
+++ b/album/build.gradle
@@ -1,4 +1,5 @@
apply plugin: rootProject.ext.plugins.library
+apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.imliujun'
diff --git a/build.gradle b/build.gradle
index 9299632..ab2f6cd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -21,3 +21,7 @@ allprojects {
}
}
}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
\ No newline at end of file
diff --git a/config.gradle b/config.gradle
index 4c1ad59..53ac197 100644
--- a/config.gradle
+++ b/config.gradle
@@ -18,30 +18,30 @@ ext {
versionName : "2.1.3",
]
- // bintray = [
- // version : "2.1.3",
- //
- // siteUrl : 'https://github.com/yanzhenjie/Album',
- // gitUrl : 'git@github.com:yanzhenjie/Album.git',
- //
- // group : "com.yanzhenjie",
- //
- // packaging : 'aar',
- // name : 'Album',
- // description : 'Album for android',
- //
- // licenseName : 'The Apache Software License, Version 2.0',
- // licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.txt',
- //
- // developerId : 'yanzhenjie',
- // developerName : 'yanzhenjie',
- // developerEmail: 'smallajax@foxmail.com',
- //
- // binrayLibrary : "Album",
- // bintrayRepo : "maven",
- // bintrayUser : 'yolanda',
- // bintrayLicense: "Apache-2.0"
- // ]
+ bintray = [
+ version : "2.1.3",
+
+ siteUrl : 'https://github.com/yanzhenjie/Album',
+ gitUrl : 'git@github.com:yanzhenjie/Album.git',
+
+ group : "com.yanzhenjie",
+
+ packaging : 'aar',
+ name : 'Album',
+ description : 'Album for android',
+
+ licenseName : 'The Apache Software License, Version 2.0',
+ licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.txt',
+
+ developerId : 'yanzhenjie',
+ developerName : 'yanzhenjie',
+ developerEmail: 'smallajax@foxmail.com',
+
+ binrayLibrary : "Album",
+ bintrayRepo : "maven",
+ bintrayUser : 'yolanda',
+ bintrayLicense: "Apache-2.0"
+ ]
dependencies = [
mediaScanner: 'com.yanzhenjie:mediascanner:1.0.3',
From ebbb65225872d88c0dbe455315e20ba190a54633 Mon Sep 17 00:00:00 2001
From: LiuJun
Date: Fri, 7 Aug 2020 17:53:36 +0800
Subject: [PATCH 6/6] update sample
---
README.md | 2 +-
build.gradle | 1 +
config.gradle | 10 +++++-----
sample/build.gradle | 12 ++++++------
.../com/yanzhenjie/album/sample/MediaLoader.java | 1 -
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 8939cab..6a38ea7 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ repositories {
}
dependencies {
- compile 'com.github.imliujun:album:3.0.1'
+ compile 'com.github.imliujun:album:3.0.2'
}
```
diff --git a/build.gradle b/build.gradle
index ab2f6cd..83eeb11 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,7 @@ allprojects {
repositories {
google()
jcenter()
+ maven { url 'https://jitpack.io' }
maven {
url "http://dl.bintray.com/piasy/maven"
}
diff --git a/config.gradle b/config.gradle
index 53ac197..966e701 100644
--- a/config.gradle
+++ b/config.gradle
@@ -11,7 +11,7 @@ ext {
compileSdkVersion: 29,
buildToolsVersion: "29.0.3",
- minSdkVersion : 14,
+ minSdkVersion : 17,
targetSdkVersion : 29,
versionCode : 27,
@@ -47,11 +47,11 @@ ext {
mediaScanner: 'com.yanzhenjie:mediascanner:1.0.3',
design : 'com.google.android.material:material:1.0.0',
- appCompat : 'androidx.appcompat:appcompat:1.0.0',
- recyclerView: 'androidx.recyclerview:recyclerview:1.0.0',
+ appCompat : 'androidx.appcompat:appcompat:1.1.0',
+ recyclerView: 'androidx.recyclerview:recyclerview:1.1.0',
cardView : 'androidx.cardview:cardview:1.0.0',
- album : 'com.yanzhenjie:album:2.1.3',
- glide : 'com.github.bumptech.glide:glide:3.8.0'
+ album : 'com.github.imliujun:album:3.0.2',
+ glide : 'com.github.bumptech.glide:glide:4.11.0'
]
}
\ No newline at end of file
diff --git a/sample/build.gradle b/sample/build.gradle
index 8307a4f..143f23c 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -19,12 +19,12 @@ android {
}
dependencies {
- implementation project(":album")
- // implementation rootProject.ext.dependencies.album
- implementation 'com.facebook.fresco:fresco:2.1.0'
- implementation "com.github.piasy:BigImageViewer:1.6.5"
- implementation "com.github.piasy:FrescoImageLoader:1.6.5"
- implementation 'com.github.piasy:FrescoImageViewFactory:1.6.5'
+ // implementation project(":album")
+ implementation rootProject.ext.dependencies.album
+ implementation 'com.facebook.fresco:fresco:2.3.0'
+ implementation "com.github.piasy:BigImageViewer:1.6.6"
+ // implementation "com.github.piasy:FrescoImageLoader:1.6.6"
+ // implementation 'com.github.piasy:FrescoImageViewFactory:1.6.6'
implementation rootProject.ext.dependencies.appCompat
implementation rootProject.ext.dependencies.design
diff --git a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
index dcf2df3..09663fa 100644
--- a/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
+++ b/sample/src/main/java/com/yanzhenjie/album/sample/MediaLoader.java
@@ -45,7 +45,6 @@ public void load(@NonNull ImageView imageView, @NonNull Uri uri) {
.load(uri)
.error(R.drawable.placeholder)
.placeholder(R.drawable.placeholder)
- .crossFade()
.into(imageView);
}