Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
((FrameLayout) convertView).setForeground(isSelected ? getResources().getDrawable(R.drawable.gallery_photo_selected) : null);

if (holder.mImage == null || !holder.mImage.equals(image)) {
mActivity.mImageFetcher.loadImage(image.mUri, holder.mThumbnail);
mActivity.mImageFetcher.loadImage(image.mUri, holder.mThumbnail, image.mOrientation);
holder.mImage = image;
}
return convertView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class ImagePickerActivity extends Activity implements ActionBar.TabListen
*/
public static final String EXTRA_SELECTION_LIMIT = "nl.changer.changer.nl.polypicker.extra.selection_limit";

public static final String EXTRA_IMAGE_ORIENTATIONS = "nl.changer.changer.nl.polypicker.extra.selected_image_orientations";

private Set<Image> mSelectedImages;
private LinearLayout mSelectedImagesContainer;
private TextView mSelectedImageEmptyMessage;
Expand Down Expand Up @@ -135,7 +137,8 @@ public boolean addImage(Image image) {
View rootView = LayoutInflater.from(ImagePickerActivity.this).inflate(R.layout.list_item_selected_thumbnail, null);
ImageView thumbnail = (ImageView) rootView.findViewById(R.id.selected_photo);
rootView.setTag(image.mUri);
mImageFetcher.loadImage(image.mUri, thumbnail);
// mImageFetcher.loadImage(image.mUri, thumbnail);
mImageFetcher.loadImage(image.mUri, thumbnail, image.mOrientation);
mSelectedImagesContainer.addView(rootView, 0);

int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics());
Expand Down Expand Up @@ -182,13 +185,18 @@ public void onClick(View view) {
if (view.getId() == R.id.action_btn_done) {

Uri[] uris = new Uri[mSelectedImages.size()];
int[] orientations = new int[mSelectedImages.size()];

int i = 0;
for (Image img : mSelectedImages) {
uris[i++] = img.mUri;
//uris[i++] = img.mUri;
uris[i] = img.mUri;
orientations[i++] = img.mOrientation;
}

Intent intent = new Intent();
intent.putExtra(EXTRA_IMAGE_URIS, uris);
intent.putExtra(EXTRA_IMAGE_ORIENTATIONS, orientations);
setResult(Activity.RESULT_OK, intent);
} else if (view.getId() == R.id.action_btn_cancel) {
setResult(Activity.RESULT_CANCELED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ protected ImageWorker(Context context) {
* @param data The URL of the image to download.
* @param imageView The ImageView to bind the downloaded image to.
*/
public void loadImage(Object data, ImageView imageView) {
// public void loadImage(Object data, ImageView imageView) {
public void loadImage(Object data, ImageView imageView, int orientation) {
if (data == null) {
return;
}
Expand All @@ -85,12 +86,14 @@ public void loadImage(Object data, ImageView imageView) {
if (value != null) {
// Bitmap found in memory cache
imageView.setImageDrawable(value);
imageView.setRotation(orientation);
} else if (cancelPotentialWork(data, imageView)) {
//BEGIN_INCLUDE(execute_background_task)
final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
final AsyncDrawable asyncDrawable =
new AsyncDrawable(mResources, mLoadingBitmap, task);
imageView.setImageDrawable(asyncDrawable);
imageView.setRotation(orientation);

// NOTE: This uses a custom version of AsyncTask that has been pulled from the
// framework and slightly modified. Refer to the docs at the top of the class
Expand Down