B4i Library iHUD library - Toast messages and progress dialogs

This library is based on the following open source project: https://github.com/matej/MBProgressHUD
License: https://github.com/matej/MBProgressHUD/blob/master/LICENSE

It includes two features available in B4A: Toast messages and progress dialogs.

Using this library is very simple.
Declare a process global variable:
B4X:
Private hd As HUD

Show a toast message:
B4X:
hd.ToastMessageShow("Some message", True) 'second parameter is LongDuration
Unlike in Android the toast message appears in the middle of the screen.

Show a progress dialog (that disables user interaction):
B4X:
hd.ProgressDialogShow("Downloading...")
Later you should call hd.ProgressDialogHide. Note that there is no DoEvents method in B4i. You should instead use asynchronous method for long tasks (when such are available).

SS-2014-10-26_17.05.14.png


Library installation:
- Download the zip file, unzip it and copy the xml file to the libraries folder.
 

Attachments

  • iHUD.zip
    606 bytes · Views: 734

LWGShane

Well-Known Member
Licensed User
Longtime User
This is awesome! I cannot wait to start messing with B4i.
 

Mikonios

Active Member
Licensed User
Longtime User
Remote Compilation is for small proyect and only trial versión.
Is posible hud.jar file ????
 

cbanks

Active Member
Licensed User
Longtime User
Could a couple enhancements be made to the iHUD library? It cuts off the text if there is a bunch of text. It also doesn't let you use CRLF to break up the text onto multiple lines. Thanks.
 

yonson

Active Member
Licensed User
Longtime User
Hi Erel

thanks for this excellent library. I am however having issues with the async method, as you say with B4A its simply a question of adding in 'DoEvents', but I was wondering if you could clarify how to create a async method?

For example:-

<code>
Dim hd As HUD
hd.ProgressDialogShow("busy")
DoBusyEvent
hd.ProgressDialogHide

Private Sub DoBusyEvent

For i=0 To 10000
Log(i)
Next
End Sub
</code>

how could I make 'DoBusyEvent' an async method, i.e. so that the busy message is shown whilst the method is running, and only closed once it is finished?
Many thanks!
 

ruy

Member
Licensed User
Longtime User
I already copied the iHUD.xml but the compiler replies that the iHUD.jar file is missing. Where can I get it?
 

ruy

Member
Licensed User
Longtime User
I already copied the iHUD.xml but the compiler replies that the iHUD.jar file is missing. Where can I get it?
Never mind. it did complile, the message appeared upon loading the project but it did complie anyway.
 

cooperlegend

Active Member
Licensed User
Longtime User
Hi,

I have a long message to show using Toastmessage. in Android it shows fine, but using this library in iOS the message is truncated. How can I show a long message as a toastmessage ?
 

cooperlegend

Active Member
Licensed User
Longtime User
OK, that's a shame, as I was hoping it would match the Android version, I guess I will switch to a msgbox instead. Thanks
 

Paul Leischow

Member
Licensed User
Longtime User
Any way to have the ability to set the position of the message?
I would prefer to the the message at the bottom of the screen like the Android Toast Message instead of the middle of the screen.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this sub to change the offset of the toast message:
B4X:
Sub SetHUDOffset(offset As Float)
   Dim no1 As NativeObject = App.KeyController
   no1 = no1.GetField("view")
   Dim no2 As NativeObject
   Dim hud As NativeObject = no2.Initialize("MMBProgressHUD").RunMethod("HUDForView:", Array(no1))
   If hud.IsInitialized Then
     hud.SetField("yOffset", offset)
   End If
End Sub

For example:
B4X:
hd.ToastMessageShow("test", True)
SetHUDOffset(Page1.RootPanel.Height / 2 - 100) 'note that RootPanel height will be 0 in Application_Start
 

Rattigan_Roger

Member
Licensed User
Longtime User
wonderful.
I came across this thread just as I was tearing out the remaining few strands of hair on my head trying to get activityView to operate consistently.
Thank You!
 
Top