|
@@ -30,6 +30,9 @@ import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
|
+import java.util.concurrent.Executor;
|
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
public class PhotoGridActivity extends AppCompatActivity implements RAGridView.GridViewMeasure {
|
|
public class PhotoGridActivity extends AppCompatActivity implements RAGridView.GridViewMeasure {
|
|
|
|
|
|
|
@@ -178,6 +181,9 @@ public class PhotoGridActivity extends AppCompatActivity implements RAGridView.G
|
|
|
this.measuring = m;
|
|
this.measuring = m;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private ExecutorService executorService = Executors.newSingleThreadExecutor();
|
|
|
|
|
+
|
|
|
/**Adapter*/
|
|
/**Adapter*/
|
|
|
private class GridViewAdapter extends BaseAdapter {
|
|
private class GridViewAdapter extends BaseAdapter {
|
|
|
|
|
|
|
@@ -229,7 +235,7 @@ public class PhotoGridActivity extends AppCompatActivity implements RAGridView.G
|
|
|
|
|
|
|
|
|
|
|
|
|
final HashMap<String,String> item = photoDic.get(position);
|
|
final HashMap<String,String> item = photoDic.get(position);
|
|
|
- String path = item.get("path");
|
|
|
|
|
|
|
+ final String path = item.get("path");
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bitmap bitmap = scaleImage(path);
|
|
// Bitmap bitmap = scaleImage(path);
|
|
@@ -243,29 +249,57 @@ public class PhotoGridActivity extends AppCompatActivity implements RAGridView.G
|
|
|
// holder.photoView.setImageBitmap(scale);
|
|
// holder.photoView.setImageBitmap(scale);
|
|
|
|
|
|
|
|
if (thumbPhotoIsExists(path)) {
|
|
if (thumbPhotoIsExists(path)) {
|
|
|
- Bitmap bitmap = BitmapFactory.decodeFile(path);
|
|
|
|
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeFile(thumbFile(path).getAbsolutePath());
|
|
|
holder.photoView.setImageBitmap(bitmap);
|
|
holder.photoView.setImageBitmap(bitmap);
|
|
|
} else {
|
|
} else {
|
|
|
final String filePath = path;
|
|
final String filePath = path;
|
|
|
final PhotoViewHolder photoHolder = holder;
|
|
final PhotoViewHolder photoHolder = holder;
|
|
|
- new Thread(new Runnable() {
|
|
|
|
|
|
|
+// new Thread(new Runnable() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
|
|
|
|
+//
|
|
|
|
|
+// final Bitmap scale = ThumbnailUtils.extractThumbnail(bitmap, 300, 300);
|
|
|
|
|
+//
|
|
|
|
|
+// File thumbFile = thumbFile(filePath);
|
|
|
|
|
+// savePhotoToFile(scale,thumbFile);
|
|
|
|
|
+//
|
|
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+// photoHolder.photoView.setImageBitmap(scale);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
|
|
+// }).start();
|
|
|
|
|
+
|
|
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
- Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
|
|
|
|
-
|
|
|
|
|
- final Bitmap scale = ThumbnailUtils.extractThumbnail(bitmap, 300, 300);
|
|
|
|
|
-
|
|
|
|
|
- File thumbFile = thumbFile(filePath);
|
|
|
|
|
- savePhotoToFile(scale,thumbFile);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Log.d("Run", "begin " + filePath);
|
|
|
|
|
+
|
|
|
|
|
+ Bitmap scale = null;
|
|
|
|
|
+ if (thumbPhotoIsExists(filePath)) {
|
|
|
|
|
+ scale = BitmapFactory.decodeFile(thumbFile(filePath).getAbsolutePath());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
|
|
|
|
+ scale = ThumbnailUtils.extractThumbnail(bitmap, 300, 300);
|
|
|
|
|
+ File thumbFile = thumbFile(filePath);
|
|
|
|
|
+ savePhotoToFile(scale,thumbFile);
|
|
|
|
|
+ bitmap.recycle();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ final Bitmap scale_img = scale;
|
|
|
runOnUiThread(new Runnable() {
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
- photoHolder.photoView.setImageBitmap(scale);
|
|
|
|
|
|
|
+ photoHolder.photoView.setImageBitmap(scale_img);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ Log.d("Run", "finish " + filePath);
|
|
|
}
|
|
}
|
|
|
- }).start();
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|