B4A Library Tasty Toast

A wrap for this Github project.

1.png


default.gif


error.gif


info.gif


success.gif


warning.gif


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: TastyToast - Wrapped by Johan Schoeman
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource
#AdditionalRes: ..\resource_tastytoast

'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
'#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
   
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim tt As TastyToast
   
   
    Private btnSuccess As Button
    Private btnWarning As Button
    Private btnError As Button
    Private btnInfo As Button
    Private btnDefault As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.LoadLayout("main")

    tt.Initialize

   
End Sub

Sub Activity_Resume
   
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnSuccess_Click
   
    tt.showSuccessToast("Download Successful !")
   
End Sub

Sub btnWarning_Click
   
    tt.showWarningToast("Are you sure ?")
   
End Sub

Sub btnError_Click
   
    tt.showErrorToast("Downloading failed ! Try again later ")
   
End Sub

Sub btnInfo_Click
   
    tt.showInfoToast("Searching for username : 'Johan' ")
   
End Sub

Sub btnDefault_Click
   
    tt.showDefaultToast("This is Default Toast")
   
End Sub
 

Attachments

  • b4aTastyToast.zip
    445.2 KB · Views: 421
  • TastyToastLibFiles.zip
    55.9 KB · Views: 423
  • TheJavaCode.zip
    46 KB · Views: 281

Mashiane

Expert
Licensed User
Longtime User
A wrap for this Github project.

View attachment 46627

View attachment 46622

View attachment 46623

View attachment 46624

View attachment 46625

View attachment 46626

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: TastyToast - Wrapped by Johan Schoeman
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource
#AdditionalRes: ..\resource_tastytoast

'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
'#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
  
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim tt As TastyToast
  
  
    Private btnSuccess As Button
    Private btnWarning As Button
    Private btnError As Button
    Private btnInfo As Button
    Private btnDefault As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
  
    Activity.LoadLayout("main")

    tt.Initialize

  
End Sub

Sub Activity_Resume
  
  
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnSuccess_Click
  
    tt.showSuccessToast("Download Successful !")
  
End Sub

Sub btnWarning_Click
  
    tt.showWarningToast("Are you sure ?")
  
End Sub

Sub btnError_Click
  
    tt.showErrorToast("Downloading failed ! Try again later ")
  
End Sub

Sub btnInfo_Click
  
    tt.showInfoToast("Searching for username : 'Johan' ")
  
End Sub

Sub btnDefault_Click
  
    tt.showDefaultToast("This is Default Toast")
  
End Sub
So brilliant... Now I'm convinced you are an alien from an intelligent light source somewhere... ;)
 

Reids

Member
Licensed User
Longtime User
This is awesome!, but I need duration more longer in milisecond somehow :(
 

Johan Schoeman

Expert
Licensed User
Longtime User
This is awesome!, but I need duration more longer in milisecond somehow :(
The library makes use of the default toast class where the duration is either short(2000ms) or long (3500ms). The simplest solution with the lib as it is will be to call the toast twice eg
B4X:
    tt.showSuccessToast("Download Successful !")
tt.showSuccessToast("Download Successful !")

It might cause a slight blink but it is a solution....
 
Top