Closed lupaulus closed 4 years ago
@lupaulus Thanks for your report. I tried on emulator but can't reproduce it. Could you give us more details so that fixing it.
At line 48 of our master
, it is:
if (_c.get()._neutralBtn.hasFocus() || _c.get()._negativeBtn.hasFocus()
_neutralBtn is null or _negativeBtn? _c.get() is always valid because you'd entered _keyListener.
The code I use to call the file chooser
new ChooserDialog(AddArbreActivity.this)
.withStartFile(Environment.getExternalStoragePublicDirectory(Environment.getExternalStorageState()).getAbsolutePath())
.withChosenListener(new ChooserDialog.Result() {
@Override
public void onChoosePath(String path, File pathFile) {
ouvertureXML(pathFile);
}
}).build()
.show();
I reproduce the bug with
:Sending Touch (ACTION_DOWN): 0:(330.0,787.0)
:Sending Touch (ACTION_UP): 0:(354.7708,791.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(1.0,-3.0)
:Sending Touch (ACTION_DOWN): 0:(4.0,66.0)
I will show you the result of the keyListener
The _c.get().neutralBtn.hasFocus()
is null
and _c.get().negativeBtn.hasFocus()
is null too.
Either the listener is called before the dialog is even built, but I doubt, or we are loosing our reference to ChooserDialog. _c is a WeakReference after all
@lupaulus, do you get this problem in the older versions? (like 1.1.16)
I tried and caught one in debug mode. but I have no idea because the afc is entering a strange state: any members are uninitialized or unspecified. I have a suppose about your monkey test: it's so fast so causing some reentering condition? I could add the defensive lines before line 48:
if (_c.get()._neutralBtn == null) {
return false;
}
But I'm afraid that might not really solve the crash matter.
Anyway, I'll push a patch to devel
including the codes I just said later. Hope works.
It's seems it's "human proof" but not "monkey test proof"
I hope my issue have helped you and I will thank you for your project because it's very complete and practical
Either the listener is called before the dialog is even built, but I doubt, or we are loosing our reference to ChooserDialog. _c is a WeakReference after all
@lupaulus, do you get this problem in the older versions? (like 1.1.16)
I will test tomorrow with an older version, I haven't tried yet.
Hey, hope it can help. On the 1.1.16 at the place of running an exception it shows an toast.
But it seems stable
So it worked right. try the devel-69
branch:
dependencies {
implementation 'com.github.hedzr:android-file-chooser:devel-69-SNAPSHOT'
}
Seems working (monkey test pass)
ok, thanks for the assistance!
This runtime exception append on monkey test of my app that implements the file chooser
The specs
The events :Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sdmo_quiniou/.MainActivity;end // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sdmo_quiniou/.MainActivity } in package com.sdmo_quiniou
:Sending Touch (ACTION_DOWN): 0:(283.0,477.0) :Sending Touch (ACTION_UP): 0:(284.1647,469.472) :Sending Trackball (ACTION_MOVE): 0:(3.0,2.0)
// CRASH: com.sdmo_quiniou (pid 2034) // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException