Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-FileManager: Commit

packages/apps/FileManager


Commit MetaInfo

Revisionb39db62e9307518debf67f78d07c34e1e9fc14e8 (tree)
Time2011-07-03 00:56:20
AuthorJoe Berria <nexesdevelopment@gmai...>
CommiterJoe Berria

Log Message

improved load speed of cached thumbnail icons

Change Summary

Incremental Difference

--- a/src/com/nexes/manager/tablet/ThumbnailCreator.java
+++ b/src/com/nexes/manager/tablet/ThumbnailCreator.java
@@ -75,47 +75,59 @@ public class ThumbnailCreator extends Thread {
7575
7676 final File file = new File(mDir + "/" + mFiles.get(i));
7777
78- if (isImageFile(file.getName())) {
79- long len_kb = file.length() / 1024;
80-
81- BitmapFactory.Options options = new BitmapFactory.Options();
82- options.outWidth = mWidth;
83- options.outHeight = mHeight;
84-
85- if (len_kb > 500 && len_kb < 2000) {
86- options.inSampleSize = 16;
87- options.inPurgeable = true;
88- options.inPreferQualityOverSpeed = false;
89- mThumb = new SoftReference<Bitmap>(BitmapFactory.decodeFile(file.getPath(), options));
90-
91- } else if (len_kb >= 2000) {
92- options.inSampleSize = 32;
93- options.inPurgeable = true;
94- options.inPreferQualityOverSpeed = false;
95- mThumb = new SoftReference<Bitmap>(BitmapFactory.decodeFile(file.getPath(), options));
96-
97- } else if (len_kb <= 500) {
98- options.inPurgeable = true;
99- mThumb = new SoftReference<Bitmap>(Bitmap.createScaledBitmap(
100- BitmapFactory.decodeFile(file.getPath()),
101- mWidth,
102- mHeight,
103- false));
104- }
105-
106- final BitmapDrawable d = new BitmapDrawable(mThumb.get());
107-
108- d.setGravity(Gravity.CENTER);
109- mCacheMap.put(file.getPath(), d);
110-
78+ //we already loaded this thumbnail, just return it.
79+ if (mCacheMap.containsKey(file.getPath())) {
11180 mHandler.post(new Runnable() {
11281 @Override
11382 public void run() {
11483 Message msg = mHandler.obtainMessage();
115- msg.obj = (BitmapDrawable)d;
84+ msg.obj = mCacheMap.get(file.getPath());
11685 msg.sendToTarget();
11786 }
11887 });
88+
89+ //we havn't loaded it yet, lets make it.
90+ } else {
91+ if (isImageFile(file.getName())) {
92+ long len_kb = file.length() / 1024;
93+
94+ BitmapFactory.Options options = new BitmapFactory.Options();
95+ options.outWidth = mWidth;
96+ options.outHeight = mHeight;
97+
98+ if (len_kb > 500 && len_kb < 2000) {
99+ options.inSampleSize = 16;
100+ options.inPurgeable = true;
101+ mThumb = new SoftReference<Bitmap>(BitmapFactory.decodeFile(file.getPath(), options));
102+
103+ } else if (len_kb >= 2000) {
104+ options.inSampleSize = 32;
105+ options.inPurgeable = true;
106+ mThumb = new SoftReference<Bitmap>(BitmapFactory.decodeFile(file.getPath(), options));
107+
108+ } else if (len_kb <= 500) {
109+ options.inPurgeable = true;
110+ mThumb = new SoftReference<Bitmap>(Bitmap.createScaledBitmap(
111+ BitmapFactory.decodeFile(file.getPath()),
112+ mWidth,
113+ mHeight,
114+ false));
115+ }
116+
117+ final BitmapDrawable d = new BitmapDrawable(mThumb.get());
118+
119+ d.setGravity(Gravity.CENTER);
120+ mCacheMap.put(file.getPath(), d);
121+
122+ mHandler.post(new Runnable() {
123+ @Override
124+ public void run() {
125+ Message msg = mHandler.obtainMessage();
126+ msg.obj = (BitmapDrawable)d;
127+ msg.sendToTarget();
128+ }
129+ });
130+ }
119131 }
120132 }
121133 }
Show on old repository browser