Permalink
Browse files

fixed force close when leaving directory before thumbnails are finish…

…ed loading
  • Loading branch information...
1 parent 2693af2 commit edf793a782861ae316483c9702432b825bf078f2 Joe Berria committed Jun 30, 2011
View
@@ -19,8 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nexes.manager"
- android:versionCode="214"
- android:versionName="2.1.4"
+ android:versionCode="218"
+ android:versionName="2.1.8"
android:installLocation="auto">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -31,7 +31,6 @@
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
-import android.util.Log;
public class DirectoryInfo extends Activity {
private static final int KB = 1024;
@@ -79,6 +79,7 @@
private final FileManager mFileMang;
private ThumbnailCreator mThumbnail;
private TableRow mDelegate;
+
private boolean multi_select_flag = false;
private boolean delete_after_copy = false;
private boolean thumbnail_flag = true;
@@ -275,9 +276,16 @@ public void zipFile(String zipPath) {
new BackgroundWork(ZIP_TYPE).execute(zipPath);
}
+ /**
+ * this will stop our background thread that creates thumbnail icons
+ * if the thread is running. this should be stopped when ever
+ * we leave the folder the image files are in.
+ */
public void stopThumbnailThread() {
- if (mThumbnail != null)
+ if (mThumbnail != null) {
+ mThumbnail.setCancelThumbnails(true);
mThumbnail = null;
+ }
}
/**
@@ -296,6 +304,8 @@ public void onClick(View v) {
Toast.makeText(mContext, "Multi-select is now off",
Toast.LENGTH_SHORT).show();
}
+
+ stopThumbnailThread();
updateDirectory(mFileMang.getPreviousDir());
if(mPathLabel != null)
mPathLabel.setText(mFileMang.getCurrentDir());
@@ -308,6 +318,8 @@ public void onClick(View v) {
Toast.makeText(mContext, "Multi-select is now off",
Toast.LENGTH_SHORT).show();
}
+
+ stopThumbnailThread();
updateDirectory(mFileMang.setHomeDir("/sdcard"));
if(mPathLabel != null)
mPathLabel.setText(mFileMang.getCurrentDir());
@@ -526,7 +538,6 @@ public void onClick(DialogInterface dialog, int index) {
private final int MG = KB * KB;
private final int GB = MG * KB;
private String display_size;
- private String dir_name = "/sdcard";
private ArrayList<Integer> positions;
private LinearLayout hidden_layout;
@@ -844,6 +844,8 @@ public boolean onKeyDown(int keycode, KeyEvent event) {
Toast.makeText(Main.this, "Multi-select is now off", Toast.LENGTH_SHORT).show();
} else {
+ //stop updating thumbnail icons if its running
+ mHandler.stopThumbnailThread();
mHandler.updateDirectory(mFileMag.getPreviousDir());
mPathLabel.setText(mFileMag.getCurrentDir());
}
@@ -36,6 +36,7 @@
private ArrayList<String> mFiles;
private String mDir;
private Handler mHandler;
+ private boolean mStop = false;
public ThumbnailCreator(int width, int height) {
mHeight = height;
@@ -49,11 +50,26 @@ public Bitmap isBitmapCached(String name) {
return mCacheMap.get(name);
}
+ public void setCancelThumbnails(boolean stop) {
+ mStop = stop;
+ }
+
+ public void createNewThumbnail(ArrayList<String> files, String dir, Handler handler) {
+ this.mFiles = files;
+ this.mDir = dir;
+ this.mHandler = handler;
+ }
+
@Override
public void run() {
int len = mFiles.size();
- for (int i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
+ if (mStop) {
+ mStop = false;
+ mFiles = null;
+ return;
+ }
final File file = new File(mDir + "/" + mFiles.get(i));
if (isImageFile(file.getName())) {
@@ -96,12 +112,6 @@ public void run() {
}
}
- public void createNewThumbnail(ArrayList<String> files, String dir, Handler handler) {
- this.mFiles = files;
- this.mDir = dir;
- this.mHandler = handler;
- }
-
private boolean isImageFile(String file) {
String ext = file.substring(file.lastIndexOf(".") + 1);

0 comments on commit edf793a

Please sign in to comment.