TeamAmaze / AmazeFileManager

Material design file manager for Android
https://teamamaze.xyz
GNU General Public License v3.0
5.36k stars 1.58k forks source link

Crash on dialog when trying to delete 16000 files #2698

Open EmmanuelMess opened 3 years ago

EmmanuelMess commented 3 years ago

Press "delete" witg 16000 files selected, the list is unscrollable, and the activity crashes:

-------------------------------------
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@2b08861 is not valid; is your activity running?
 at android.view.ViewRootImpl.setView(ViewRootImpl.java:748)
 at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:343)
 at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
 at android.widget.Toast$TN.handleShow(Toast.java:504)
 at android.widget.Toast$TN$2.handleMessage(Toast.java:384)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6351)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)
-------------------------------------
VishalNehra commented 3 years ago

Dupe to #1063 ?

EmmanuelMess commented 3 years ago

No, that happens on the delete, this happens on the dialog.

VishalNehra commented 3 years ago

Ok, maybe update the description / title to avoid confusion?

VishalNehra commented 3 years ago

Initial suggestion would be to disable file listing in dialog if it crosses certain threshold, say 50 files. Total size calculation may remain, subject to testing.

EmmanuelMess commented 3 years ago

Initial suggestion would be to disable file listing in dialog if it crosses certain threshold, say 50 files. Total size calculation may remain, subject to testing.

Maybe something like ..."and X more files", and directory listing should cancel when the user presses "accept".

VishalNehra commented 3 years ago

And x more files makes sense, but listing should cancel? I mean, will it buffer? Not a good idea, I think it'll be unnecessary complication. It isn't practical to list hundreds of files in a dialog, let alone thousands.

EmmanuelMess commented 3 years ago

And x more files makes sense, but listing should cancel? I mean, will it buffer? Not a good idea, I think it'll be unnecessary complication.

The listing should cancel, otherwise it will have to finish before the delete actually takes place, and the listing can take very long on some directories.

VishalNehra commented 3 years ago

I'm saying we will not list all the files. Will ve something like

Directories
1. A
2. B
3. C
.
.
25. Xyz
And 25 more...
Total - xx GB

Here the listing has finished. So listing 25/ whatever number wouldn't take that long.

EmmanuelMess commented 3 years ago

I'm saying we will not list all the files. Will ve something like

Directories
1. A
2. B
3. C
.
.
25. Xyz
And 25 more...
Total - xx GB

Here the listing has finished. So listing 25/ whatever number wouldn't take that long.

So listing 25/ whatever number wouldn't take that long.

No, but the "total" would need the entire list, and would take long, as it does now.

VishalNehra commented 3 years ago

No, but the "total" would need the entire list, and would take long, as it does now.

Yes. I missed it probably. We can keep something like

Total: xx GB and processing and keep it updating. LiveData should help in this case.

EmmanuelMess commented 3 years ago

No, but the "total" would need the entire list, and would take long, as it does now.

Yes. I missed it probably. We can keep something like

Total: xx GB and processing and keep it updating. LiveData should help in this case.

But when the user clicks "delete" the listing has to be cancelled, otherwise, as it is implemented, I think the deletion doesn't start.