Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Commit

Permalink
https://github.com/yazeed44/MultiImagePicker/issues/36
Browse files Browse the repository at this point in the history
-Improve of performance in images thumbnail
  • Loading branch information
yazeed44 committed Jul 23, 2015
1 parent 05d2df7 commit cb091df
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 59 deletions.
8 changes: 5 additions & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down Expand Up @@ -97,8 +99,8 @@
<orderEntry type="library" exported="" name="material-dialogs-0.7.6.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.0" level="project" />
Expand Down
11 changes: 8 additions & 3 deletions imagepicker/imagepicker.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand Down Expand Up @@ -63,6 +65,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand All @@ -82,7 +85,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
Expand All @@ -93,9 +98,9 @@
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="floatingactionbutton-1.3.0" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="robospice-cache-1.4.14" level="project" />
<orderEntry type="library" exported="" name="commons-io-1.3.2" level="project" />
<orderEntry type="library" exported="" name="robospice-1.4.14" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="library-1.2.3" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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));
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -328,9 +329,10 @@ private void selectAllImages() {
}


if (!sCheckedImages.contains(imageEntry)) {
if (!imageEntry.isPicked) {
//To avoid repeated images
sCheckedImages.add(imageEntry);
imageEntry.isPicked = true;
}


Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit cb091df

Please sign in to comment.