Skip to content

Commit edf793a

Browse files
author
Joe Berria
committed
fixed force close when leaving directory before thumbnails are finished loading
1 parent 2693af2 commit edf793a

8 files changed

Lines changed: 34 additions & 12 deletions

File tree

AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2121
package="com.nexes.manager"
22-
android:versionCode="214"
23-
android:versionName="2.1.4"
22+
android:versionCode="218"
23+
android:versionName="2.1.8"
2424
android:installLocation="auto">
2525
<application android:icon="@drawable/icon" android:label="@string/app_name"
2626
android:debuggable="true">

bin/Android file manager.apk

57 Bytes
Binary file not shown.

bin/classes.dex

124 Bytes
Binary file not shown.

bin/resources.ap_

0 Bytes
Binary file not shown.

src/com/nexes/manager/DirectoryInfo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import android.view.View;
3232
import android.widget.TextView;
3333
import android.widget.Button;
34-
import android.util.Log;
3534

3635
public class DirectoryInfo extends Activity {
3736
private static final int KB = 1024;

src/com/nexes/manager/EventHandler.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class EventHandler implements OnClickListener {
7979
private final FileManager mFileMang;
8080
private ThumbnailCreator mThumbnail;
8181
private TableRow mDelegate;
82+
8283
private boolean multi_select_flag = false;
8384
private boolean delete_after_copy = false;
8485
private boolean thumbnail_flag = true;
@@ -275,9 +276,16 @@ public void zipFile(String zipPath) {
275276
new BackgroundWork(ZIP_TYPE).execute(zipPath);
276277
}
277278

279+
/**
280+
* this will stop our background thread that creates thumbnail icons
281+
* if the thread is running. this should be stopped when ever
282+
* we leave the folder the image files are in.
283+
*/
278284
public void stopThumbnailThread() {
279-
if (mThumbnail != null)
285+
if (mThumbnail != null) {
286+
mThumbnail.setCancelThumbnails(true);
280287
mThumbnail = null;
288+
}
281289
}
282290

283291
/**
@@ -296,6 +304,8 @@ public void onClick(View v) {
296304
Toast.makeText(mContext, "Multi-select is now off",
297305
Toast.LENGTH_SHORT).show();
298306
}
307+
308+
stopThumbnailThread();
299309
updateDirectory(mFileMang.getPreviousDir());
300310
if(mPathLabel != null)
301311
mPathLabel.setText(mFileMang.getCurrentDir());
@@ -308,6 +318,8 @@ public void onClick(View v) {
308318
Toast.makeText(mContext, "Multi-select is now off",
309319
Toast.LENGTH_SHORT).show();
310320
}
321+
322+
stopThumbnailThread();
311323
updateDirectory(mFileMang.setHomeDir("/sdcard"));
312324
if(mPathLabel != null)
313325
mPathLabel.setText(mFileMang.getCurrentDir());
@@ -526,7 +538,6 @@ public class TableRow extends ArrayAdapter<String> {
526538
private final int MG = KB * KB;
527539
private final int GB = MG * KB;
528540
private String display_size;
529-
private String dir_name = "/sdcard";
530541
private ArrayList<Integer> positions;
531542
private LinearLayout hidden_layout;
532543

src/com/nexes/manager/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@ public boolean onKeyDown(int keycode, KeyEvent event) {
844844
Toast.makeText(Main.this, "Multi-select is now off", Toast.LENGTH_SHORT).show();
845845

846846
} else {
847+
//stop updating thumbnail icons if its running
848+
mHandler.stopThumbnailThread();
847849
mHandler.updateDirectory(mFileMag.getPreviousDir());
848850
mPathLabel.setText(mFileMag.getCurrentDir());
849851
}

src/com/nexes/manager/ThumbnailCreator.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ThumbnailCreator extends Thread {
3636
private ArrayList<String> mFiles;
3737
private String mDir;
3838
private Handler mHandler;
39+
private boolean mStop = false;
3940

4041
public ThumbnailCreator(int width, int height) {
4142
mHeight = height;
@@ -49,11 +50,26 @@ public Bitmap isBitmapCached(String name) {
4950
return mCacheMap.get(name);
5051
}
5152

53+
public void setCancelThumbnails(boolean stop) {
54+
mStop = stop;
55+
}
56+
57+
public void createNewThumbnail(ArrayList<String> files, String dir, Handler handler) {
58+
this.mFiles = files;
59+
this.mDir = dir;
60+
this.mHandler = handler;
61+
}
62+
5263
@Override
5364
public void run() {
5465
int len = mFiles.size();
5566

56-
for (int i = 0; i < len; i++) {
67+
for (int i = 0; i < len; i++) {
68+
if (mStop) {
69+
mStop = false;
70+
mFiles = null;
71+
return;
72+
}
5773
final File file = new File(mDir + "/" + mFiles.get(i));
5874

5975
if (isImageFile(file.getName())) {
@@ -96,12 +112,6 @@ public void run() {
96112
}
97113
}
98114

99-
public void createNewThumbnail(ArrayList<String> files, String dir, Handler handler) {
100-
this.mFiles = files;
101-
this.mDir = dir;
102-
this.mHandler = handler;
103-
}
104-
105115
private boolean isImageFile(String file) {
106116
String ext = file.substring(file.lastIndexOf(".") + 1);
107117

0 commit comments

Comments
 (0)