diff --git a/app/app.iml b/app/app.iml
index 15c790c..7faa30b 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -12,10 +12,12 @@
-
-
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
@@ -97,8 +99,8 @@
-
+
diff --git a/imagepicker/imagepicker.iml b/imagepicker/imagepicker.iml
index 94c53ae..1e1b5ad 100644
--- a/imagepicker/imagepicker.iml
+++ b/imagepicker/imagepicker.iml
@@ -12,10 +12,12 @@
-
-
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
@@ -63,6 +65,7 @@
+
@@ -82,7 +85,9 @@
+
+
@@ -93,9 +98,9 @@
+
-
diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/model/ImageEntry.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/model/ImageEntry.java
index 583f0e7..a2aca8e 100644
--- a/imagepicker/src/main/java/net/yazeed44/imagepicker/model/ImageEntry.java
+++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/model/ImageEntry.java
@@ -12,6 +12,7 @@
public class ImageEntry implements Serializable {
public final int imageId;
public final String path;
+ public boolean isPicked = false;
public ImageEntry(final Builder builder) {
this.path = builder.mPath;
diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/AlbumsFragment.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/AlbumsFragment.java
index 8f1cb5a..2a2b538 100644
--- a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/AlbumsFragment.java
+++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/AlbumsFragment.java
@@ -67,19 +67,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
return mAlbumsRecycler;
}
- protected void setupRecycler() {
-
- mAlbumsRecycler.setHasFixedSize(true);
-
-
- final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.num_columns_albums));
- gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
-
- mAlbumsRecycler.setLayoutManager(gridLayoutManager);
-
-
- }
-
@Override
public void onStart() {
if (mAlbumList == null) {
@@ -96,21 +83,6 @@ public void onStop() {
super.onStop();
}
-
- public void setupAdapter() {
- if (mAlbumList == null) {
- final LoadingAlbumsRequest loadingRequest = new LoadingAlbumsRequest(getActivity());
-
- mSpiceManager.execute(loadingRequest, this);
- } else {
-
- mAlbumsRecycler.setAdapter(new AlbumsAdapter(mAlbumList, mAlbumsRecycler, mPickOptions));
- }
-
-
- }
-
-
@Override
public void onRequestFailure(SpiceException spiceException) {
Log.e(TAG, spiceException.getMessage());
@@ -134,14 +106,34 @@ public void onRequestSuccess(ArrayList albumEntries) {
}
- private boolean hasLoadedSuccessfully(final ArrayList albumList) {
- return albumList != null && albumList.size() > 0;
+ protected void setupRecycler() {
+
+ mAlbumsRecycler.setHasFixedSize(true);
+
+
+ final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.num_columns_albums));
+ gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
+
+ mAlbumsRecycler.setLayoutManager(gridLayoutManager);
+
+
}
+ public void setupAdapter() {
+ if (mAlbumList == null) {
+ final LoadingAlbumsRequest loadingRequest = new LoadingAlbumsRequest(getActivity());
- /* public void onEvent(final Events.OnAttachFabEvent fabEvent){
- fabEvent.fab.attachToRecyclerView(mAlbumsRecycler);
- }*/
+ mSpiceManager.execute(loadingRequest, this);
+ } else {
+
+ mAlbumsRecycler.setAdapter(new AlbumsAdapter(mAlbumList, mAlbumsRecycler, mPickOptions));
+ }
+ }
+
+ private boolean hasLoadedSuccessfully(final ArrayList albumList) {
+ return albumList != null && albumList.size() > 0;
+ }
+
}
diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/ImagesThumbnailAdapter.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/ImagesThumbnailAdapter.java
index 7d3bc89..4c1f264 100644
--- a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/ImagesThumbnailAdapter.java
+++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/ImagesThumbnailAdapter.java
@@ -105,7 +105,7 @@ public void drawGrid(final ImageViewHolder holder, final ImageEntry imageEntry)
holder.check.setImageDrawable(mCheckIcon);
- if (isPicked(imageEntry)) {
+ if (imageEntry.isPicked) {
holder.itemView.setBackgroundColor(mPickOptions.imageBackgroundColorWhenChecked);
holder.check.setBackgroundColor(mPickOptions.imageBackgroundColorWhenChecked);
@@ -129,9 +129,8 @@ public void drawGrid(final ImageViewHolder holder, final ImageEntry imageEntry)
public void pickImage(final ImageViewHolder holder, final ImageEntry imageEntry) {
- final boolean isPicked = isPicked(imageEntry);
- if (isPicked) {
+ if (imageEntry.isPicked) {
//Unpick
EventBus.getDefault().post(new Events.OnUnpickImageEvent(imageEntry));
@@ -148,22 +147,6 @@ public void pickImage(final ImageViewHolder holder, final ImageEntry imageEntry)
}
-
- public boolean isPicked(final ImageEntry pImageEntry) {
-
-
- for (final ImageEntry imageEntry : PickerActivity.sCheckedImages) {
-
- if (imageEntry.equals(pImageEntry)) {
- return true;
- }
-
- }
-
- return false;
- }
-
-
public static class ImageViewHolder extends RecyclerView.ViewHolder {
private final ImageView thumbnail;
private final ImageView check;
diff --git a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java
index f5ee730..ca664ff 100644
--- a/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java
+++ b/imagepicker/src/main/java/net/yazeed44/imagepicker/ui/PickerActivity.java
@@ -180,6 +180,7 @@ public void onClickDone(View view) {
if (mPickOptions.pickMode == Picker.PickMode.SINGLE_IMAGE) {
sCheckedImages.add(mCurrentlyDisplayedImage);
+ mCurrentlyDisplayedImage.isPicked = true;
} else {
//No need to modify sCheckedImages for Multiple images mode
@@ -328,9 +329,10 @@ private void selectAllImages() {
}
- if (!sCheckedImages.contains(imageEntry)) {
+ if (!imageEntry.isPicked) {
//To avoid repeated images
sCheckedImages.add(imageEntry);
+ imageEntry.isPicked = true;
}
@@ -402,6 +404,7 @@ private void handleMultipleModeAddition(final ImageEntry imageEntry) {
}
if (sCheckedImages.size() < mPickOptions.limit || mPickOptions.limit == NO_LIMIT) {
+ imageEntry.isPicked = true;
sCheckedImages.add(imageEntry);
} else {
Toast.makeText(this, R.string.you_cant_check_more_images, Toast.LENGTH_SHORT).show();
@@ -481,6 +484,7 @@ public void onEvent(final Events.OnPickImageEvent pickImageEvent) {
public void onEvent(final Events.OnUnpickImageEvent unpickImageEvent) {
sCheckedImages.remove(unpickImageEvent.imageEntry);
+ unpickImageEvent.imageEntry.isPicked = false;
updateFab();
hideDeselectAll();