Android Question MsgBox2 issue (not waiting)

Harris

Expert
Licensed User
Longtime User
The msgbox2 (or BetterDialogs version) is not waiting for a user touch screen response to the dialog that is presented.

This section below (from the Logs file) shows that it "seems" to have got a response and processed it, yet no screen press was given.

B4X:
 getting a trailer... wait here...-999
GOT a trailer22... selected: 78111
See if we have a pretrip on file -CheckCurrInspect4Pre 1234 Unit: 2
See if we have a pretrip on file -CheckCurrInspect4Pre 1321 Unit: 2
Build existing post trip -BuildPostTrip - using pretrip? -false
built existing post-trip inspection for trailer

When the selection was called - the response should have been... (stop at the modal dialog and WAIT for a response)

B4a (5.02 (1)

B4X:
getting a trailer... wait here...-999


This is the sub that calls it all (below)...
I have tried the IF, Else, End If as well as the CASE method.
Both produce the same result.

Note: After some compiles (I have noticed), it WILL stop as one would expect, allowing me to select the correct item to build the correct data from (button selection in dialog). But now, it never halts on the (modal) msgbox2 and selects the CANCEL option..???

It is probably me, but every time I FIX some other issue (and there were many), I introduce some other strange behavior that did not appear/exist before. WTH?

This seems pretty straight forward, yet it confounds.

B4X:
Sub GetATrailer As Int

Dim gettrl1 As Int = -999

If DefCM.DefTrlNum = "" Then
   Log(" No trailer num - returned...")
  Return 0
End If
Log(" getting a trailer... wait here..."&gettrl1)

If DefCM.DefTrlNum2 <> "" Then

   If  DefCM.DefTrlNum3 <> "" Then
       Select  BDmod.MB("Select Trailer"," Select The Trailer To Inspect",DefCM.DefTrlNum, DefCM.DefTrlNum2,DefCM.DefTrlNum3)
     '  i = Msgbox2(" Select The Trailer To Inspect","Select Trailer",DefCM.DefTrlNum, DefCM.DefTrlNum2,DefCM.DefTrlNum3,Null)
       Case  DialogResponse.POSITIVE
          DefCM.InspTrl = DefCM.DefTrlNum
          Log(" GOT a traile1r... selected: "&DefCM.InspTrl)
          Return 1
       Case  DialogResponse.CANCEL
          DefCM.InspTrl = DefCM.DefTrlNum2
          Log(" GOT a trailer2... selected: "&DefCM.InspTrl)
          Return 2
      Case  DialogResponse.NEGATIVE
          DefCM.InspTrl = DefCM.DefTrlNum3
            Log(" GOT a trailer3... selected: "&DefCM.InspTrl)
          Return 3
      End Select     
    Else
       Select BDmod.MB("Select Trailer"," Select The Trailer To Inspect",DefCM.DefTrlNum,DefCM.DefTrlNum2,"")
    '   i = Msgbox2(  " Select The Trailer To Inspect","Select Trailer",DefCM.DefTrlNum, DefCM.DefTrlNum2, "",Null)

       Case DialogResponse.POSITIVE
          DefCM.InspTrl = DefCM.DefTrlNum
            Log(" GOT a trailer11... selected: "&DefCM.InspTrl)
          Return 1
       Case  DialogResponse.CANCEL
          DefCM.InspTrl = DefCM.DefTrlNum2
            Log(" GOT a trailer22... selected: "&DefCM.InspTrl)
          Return 2
       End Select     
    End If
End If

DefCM.InspTrl = DefCM.DefTrlNum
Log(" getting a trailer - the only... selected as final result: "&DefCM.InspTrl)

Return 1

End Sub
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
You are not showing any msgbox.
No wonder it does not wait
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
You are not showing any msgbox.
No wonder it does not wait
"Select BDmod.MB("Select Trailer"," Select The Trailer To Inspect",DefCM.DefTrlNum, DefCM.DefTrlNum2,DefCM.DefTrlNum3)"

The above is the same as msgbox2, in a BetterDialogs method.
My MsgBox2 does show, yet travels on with a response before I select...

I have tried both, as you see from the code where I commented out the msgbox2, to see what the affect would be.

Anything else I might have missed?

I always thought there was a problem in Better Dialogs lib. I proved myself wrong. There is no problem with BD.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I know nothing about betterDialogs lib, but placing the msgbox2 inside the 'select' and not 'case', results into ignoring the command.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
B4X:
Sub GetATrailer As Int

Dim gettrl1 As Int = -999

If DefCM.DefTrlNum = "" Then
   Log(" No trailer num - returned...")
  Return 0
End If
Log(" getting a trailer... wait here..."&gettrl1)

If DefCM.DefTrlNum2 <> "" Then
   DoEvents
   If  DefCM.DefTrlNum3 <> "" Then
     '  gettrl1 = BDmod.MB("Select Trailer"," Select The Trailer To Inspect",DefCM.DefTrlNum, DefCM.DefTrlNum2,DefCM.DefTrlNum3)
       gettrl1 = Msgbox2(" Select The Trailer To Inspect","Select Trailer",DefCM.DefTrlNum, DefCM.DefTrlNum2,DefCM.DefTrlNum3,Null)
       If gettrl1 = DialogResponse.POSITIVE Then
          DefCM.InspTrl = DefCM.DefTrlNum
          Log(" GOT a traile1r... selected: "&DefCM.InspTrl)
          Return 1
       Else if gettrl1 = DialogResponse.CANCEL Then
          DefCM.InspTrl = DefCM.DefTrlNum2
          Log(" GOT a trailer2... selected: "&DefCM.InspTrl)
          Return 2
       Else if gettrl1 = DialogResponse.NEGATIVE Then
          DefCM.InspTrl = DefCM.DefTrlNum3
            Log(" GOT a trailer3... selected: "&DefCM.InspTrl)
          Return 3
       End If    
    Else
     '  gettrl1 = BDmod.MB("Select Trailer"," Select The Trailer To Inspect",DefCM.DefTrlNum,DefCM.DefTrlNum2,"")
       gettrl1 = Msgbox2(  " Select The Trailer To Inspect","Select Trailer",DefCM.DefTrlNum, DefCM.DefTrlNum2, "",Null)
       If gettrl1 = DialogResponse.POSITIVE Then
          DefCM.InspTrl = DefCM.DefTrlNum
            Log(" GOT a trailer11... selected: "&DefCM.InspTrl)
          Return 1
       Else if gettrl1 = DialogResponse.CANCEL Then
          DefCM.InspTrl = DefCM.DefTrlNum2
            Log(" GOT a trailer22... selected: "&DefCM.InspTrl)

          Return 2
       End If    
    End If
End If

Here is the standard IF method. Same thing as first post, but now it is in-consistent. Sometimes it waits, other times it skips right through - yet still shows the dialog as pictured below.

This is where it gets called, and where the CallSubDelayed( LogServmod, "BuildTrailerInpection") is being triggered.
B4X:
    Select ActionItemID
            Case 1 ' new trailer inspection
                Inspection.Trlinsp = GetATrailer
                If Inspection.Trlinsp = 0 Then
                   Msgbox(" No Trailer Defined"," Error")
                   Return
                End If
         
                   CallSubDelayed( LogServmod, "BuildTrailerInpection")

            Case 2
                ReviewInsp.InspT_T = 2
                ReviewInsp.INSPType = 1
                StartActivity(ReviewInsp)
             
             Case 3
                StartActivity(unit_odom)
             
        End Select
 

Attachments

  • msgbx1.png
    msgbx1.png
    123.9 KB · Views: 237
  • msgbx2.png
    msgbx2.png
    69.3 KB · Views: 212
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I'm a bit suspicious about the doEvents I see. Is it helping something else outside?
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
I'm a bit suspicious about the doEvents I see. Is it helping something else outside?
Yes, I removed it to see if it was the cause. Same intermittent action...
This images shows the quick action menu behind the msgbox, which is used to select this "Select Trailer" action.
When it is in this state (not dismissed), the msgbox will wait. When it IS dismissed (as in photo in above post), I get the issue...
Looking into what it does this now...


msgbx3.png
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Have you tried to use callsubplus method when the dialog should be called.
user click on the picture and the quickaction (in background) shows up.
user click on the item to start the selection.
app uses callsubplus to raise a sub with a delay of 200ms or 500
in this sub the dialog should work now i guess
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Case 1 ' new trailer inspection
Inspection.Trlinsp = GetATrailer
this is the place i would use the callsubplus delayed sub where the dialog is shown then.

Just a guess what i would try. eventdriven is mostly better to give the system to handle events, redraws, and so on.
I dont like such situations. Therefore i look out for a async way most time.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
this is the place i would use the callsubplus delayed sub where the dialog is shown then.

Just a guess what i would try. eventdriven is mostly better to give the system to handle events, redraws, and so on.
I dont like such situations. Therefore i look out for a async way most time.

I have tried the callsubplus... same issue???
Anyways, I am now at a hotel for a flight to Alaska at 6 am.
I can't reach my local RDC, so data isn't being transferred - as it was when I was at home earlier.
Now, the BetterDialogs screen are not (going black) or performing the same issue I was seeing earlier.

I might scrap the BetterDialogs and use a panel with labels and buttons - less overhead, and see what happens.
This is all so strange (and a frustrating waste of time) when it used to work pretty darn well...

Thanks
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Well hells bells...

I plugged in my wifi router, at this hotel, and reverted all code back to the way it started - before the issue reported.
All new data is sent to my server, inserted into tables, as it was before.

Now, everything works as expected (and coded).
No skipping thru the msgbox2 or betterdialogs (whichever I try).

I have no freakin idea what the heck was happening, how it could possibly happen and hope it doesn't rear it's ugly head again, but I don't count on it. These things occasionally plague me.

Looks like I have to sell my house and move since I can't code effectively at home any more... It is possessed.

WTF doesn't begin to describe the hell of the last three wasted days. The code gods are punishing me for my (past) evils.
I have changed my evil ways long ago... I release all my trout caught on barb-less flies - to swim and live again.

Thanks for bearing with me. I shall keep you updated if the devil returns.
 
Upvote 0
Top