Skip to content

Commit

Permalink
Load photos in background.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickard Lindberg and Kajsa Goffrich authored and rickardlindberg committed Oct 8, 2012
1 parent 3ee7f2c commit dc8d1d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion backlog
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Next release:
- Add pair commit gravatar and email
- Load high res in background
Backlog:
- New photo sources: picasa, flickr, ...
- Select subset of photos to show
Expand Down
6 changes: 3 additions & 3 deletions photobox/src/com/photobox/app/PhotoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public PhotoView(Context context, AttributeSet attrs, int defStyle) {
inputState = new InputState(context, mapping);
int maxSize = getScreenSize().max();
asynchPhotoLoader = new AsynchPhotoLoader(this, maxSize);
ladder = new ResolutionLadder(1, 1, maxSize,
new ResolutionLadder(3, 0.5f, maxSize,
new ResolutionLadder(10, 0.15f, maxSize, null)));
ladder = new ResolutionLadder(1, 1, asynchPhotoLoader,
new ResolutionLadder(3, 0.5f, asynchPhotoLoader,
new ResolutionLadder(10, 0.15f, asynchPhotoLoader, null)));
inputActor = new InputActor(mapping, collection, ladder);
}

Expand Down
10 changes: 5 additions & 5 deletions photobox/src/com/photobox/files/ResolutionLadder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import com.photobox.files.*;
import com.photobox.queues.*;
import com.photobox.world.Photo;

Expand All @@ -10,13 +11,13 @@
public class ResolutionLadder {

private float resolution;
private int maxSize;
private AsynchPhotoLoader asynchPhotoLoader;
private ResolutionLadder nextLevel;
private SizedQueue<Photo> photoQueue;

public ResolutionLadder(int maxPhotosAllowed, float resolution, int maxSize, ResolutionLadder nextLevel) {
public ResolutionLadder(int maxPhotosAllowed, float resolution, AsynchPhotoLoader asynchPhotoLoader, ResolutionLadder nextLevel) {
this.resolution = resolution;
this.maxSize = maxSize;
this.asynchPhotoLoader = asynchPhotoLoader;
this.nextLevel = nextLevel;
photoQueue = new SizedQueue<Photo>(maxPhotosAllowed);
}
Expand Down Expand Up @@ -64,8 +65,7 @@ private void enqueue(Photo photo, boolean fiddleWithBitmaps) {
}

private void loadWithRes(float res, Photo p) {
Bitmap b = p.bitmapLoader.loadWithRes((int)Math.round(maxSize * res));
p.setBitmap(res, b);
asynchPhotoLoader.addLoadingTask(p, res);
}

}

0 comments on commit dc8d1d2

Please sign in to comment.