Skip to content
Open
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
54 changes: 13 additions & 41 deletions src/info/guardianproject/iocipher/camera/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import info.guardianproject.iocipher.File;
import info.guardianproject.iocipher.FileInputStream;
import info.guardianproject.iocipher.FileOutputStream;
import info.guardianproject.iocipher.VirtualFileSystem;
import info.guardianproject.iocipher.camera.io.IOCipherContentProvider;
import info.guardianproject.iocipher.camera.viewer.ImageViewerActivity;
import info.guardianproject.iocipher.camera.viewer.MjpegViewerActivity;
Expand All @@ -27,6 +28,7 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
Expand Down Expand Up @@ -58,7 +60,7 @@ public class GalleryActivity extends Activity implements ICacheWordSubscriber {

private GridView gridview;
private HashMap<String,Bitmap> mBitCache = new HashMap<String,Bitmap>();
private HashMap<String,BitmapWorkerThread> mBitLoaders = new HashMap<String,BitmapWorkerThread>();
private HashMap<String,BitmapWorkerTask> mBitLoaders = new HashMap<String,BitmapWorkerTask>();

private CacheWordHandler mCacheWord;

Expand Down Expand Up @@ -590,52 +592,17 @@ private Bitmap getPreview(File fileImage) throws FileNotFoundException {

if (b == null && mBitLoaders.get(fileImage.getAbsolutePath())==null)
{
BitmapWorkerThread bwt = new BitmapWorkerThread(fileImage);
BitmapWorkerTask bwt = new BitmapWorkerTask();
mBitLoaders.put(fileImage.getAbsolutePath(),bwt);
bwt.start();
bwt.execute(fileImage);

}
}

return b;
}

class BitmapWorkerThread extends Thread
{
private File fileImage;

public BitmapWorkerThread (File fileImage)
{
this.fileImage = fileImage;
}

public void run ()
{
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inSampleSize = 8;
Bitmap b;
try {
FileInputStream fis = new FileInputStream(fileImage);
b = BitmapFactory.decodeStream(fis, null, bounds);
fis.close();
mBitCache.put(fileImage.getAbsolutePath(), b);
mBitLoaders.remove(fileImage.getAbsolutePath());

h.post(new Runnable()
{
public void run ()
{
((IconicList)gridview.getAdapter()).notifyDataSetChanged();
}
});

} catch (Exception e) {
Log.e(TAG,"error decoding bitmap preview",e);
}
}
}

/*
class BitmapWorkerTask extends AsyncTask<File, Void, Bitmap> {

// Decode image in background.
Expand All @@ -651,22 +618,27 @@ protected Bitmap doInBackground(File... fileImage) {
fis.close();
mBitCache.put(fileImage[0].getAbsolutePath(), b);

VirtualFileSystem.get().detachThread();

return b;
} catch (Exception e) {
Log.e(TAG,"error decoding bitmap preview",e);
}


return null;

}

// Once complete, see if ImageView is still around and set bitmap.
@Override
protected void onPostExecute(Bitmap bitmap) {
((IconicList)gridview.getAdapter()).notifyDataSetChanged();
protected void onPostExecute(Bitmap bitmap) {

if (bitmap != null)
((IconicList)gridview.getAdapter()).notifyDataSetChanged();

}
}*/
}



Expand Down