B4A Library AwesomeSpeedometer

A wrap for this Github project. Posting
1. B4A sample project
2. B4A library files
3. Java code (I have been lazy - change it to your liking)
4. LibRes.zip - extract it and copy the folder into the B4A project so that it is on the same folder level as that of the /Files and /Objects folders of the B4A project.

1.gif


Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: AwesomeSpeedometer
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#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.
   
    Dim t As Timer

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.

    Private as1 As AwesomeSpeedometer
    Dim maxSpeed As Int = 200
   
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")
    t.Initialize("t", 1000)
   
    as1.MaxSpeed = 200
    as1.IndicatorColor = Colors.red
    as1.TrianglesColor = Colors.Magenta
    as1.MarkColor = Colors.Red
    as1.TextColor = Colors.White
    as1.SpeedometerColor = Colors.Cyan
    as1.Unit = "mph"
    as1.SpeedTextColor = Colors.Green

End Sub

Sub Activity_Resume
   
    t.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
    t.Enabled = False

End Sub

Sub t_tick
   
    as1.speedTo_2(Rnd(0,maxSpeed+1),500)
   
End Sub

Library:
AwesomeSpeedometer
Author:
Github: Anas Altair, Wrapped by: Johan Schoeman
Version: 1
  • AwesomeSpeedometer
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • speedPercentTo (percent As Int)
      change speed to percent value.
      percent percent value to change, should be between [0,100].
    • speedTo_1 (speed As Int)
      if speed is less than 0 then speed will be 0.
      speed correct speed to move.
    • speedTo_2 (speed As Int, moveDuration As Long)
      speed correct speed to move.
      moveDuration The length of the animation, in milliseconds. This value cannot be negative.
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • IndicatorColor As Int [write only]
    • Left As Int
    • MarkColor As Int [write only]
    • MaxSpeed As Int [write only]
    • Parent As Object [read only]
    • SpeedTextColor As Int [write only]
    • SpeedTextSize As Float [write only]
    • SpeedometerColor As Int [write only]
    • SpeedometerWidth As Float [write only]
    • Tag As Object
    • TextColor As Int [write only]
    • Top As Int
    • TrianglesColor As Int [write only]
    • Unit As String [write only]
    • Visible As Boolean
    • Width As Int
 

Attachments

  • ba4AwesomeSpeedometer.zip
    8 KB · Views: 462
  • LibRes.zip
    882 bytes · Views: 449
  • AwesomeSpeedometerLibFiles.zip
    27.2 KB · Views: 496
  • The JavaCode.zip
    14.2 KB · Views: 409

Mashiane

Expert
Licensed User
Longtime User
Wow..
A wrap for this Github project. Posting
1. B4A sample project
2. B4A library files
3. Java code (I have been lazy - change it to your liking)
4. LibRes.zip - extract it and copy the folder into the B4A project so that it is on the same folder level as that of the /Files and /Objects folders of the B4A project.

View attachment 47692

Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: AwesomeSpeedometer
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#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.
  
    Dim t As Timer

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.

    Private as1 As AwesomeSpeedometer
    Dim maxSpeed As Int = 200
  
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")
    t.Initialize("t", 1000)
  
    as1.MaxSpeed = 200
    as1.IndicatorColor = Colors.red
    as1.TrianglesColor = Colors.Magenta
    as1.MarkColor = Colors.Red
    as1.TextColor = Colors.White
    as1.SpeedometerColor = Colors.Cyan
    as1.Unit = "mph"
    as1.SpeedTextColor = Colors.Green

End Sub

Sub Activity_Resume
  
    t.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)
  
    t.Enabled = False

End Sub

Sub t_tick
  
    as1.speedTo_2(Rnd(0,maxSpeed+1),500)
  
End Sub

Library:
AwesomeSpeedometer
Author:
Github: Anas Altair, Wrapped by: Johan Schoeman
Version: 1
  • AwesomeSpeedometer
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • speedPercentTo (percent As Int)
      change speed to percent value.
      percent percent value to change, should be between [0,100].
    • speedTo_1 (speed As Int)
      if speed is less than 0 then speed will be 0.
      speed correct speed to move.
    • speedTo_2 (speed As Int, moveDuration As Long)
      speed correct speed to move.
      moveDuration The length of the animation, in milliseconds. This value cannot be negative.
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • IndicatorColor As Int [write only]
    • Left As Int
    • MarkColor As Int [write only]
    • MaxSpeed As Int [write only]
    • Parent As Object [read only]
    • SpeedTextColor As Int [write only]
    • SpeedTextSize As Float [write only]
    • SpeedometerColor As Int [write only]
    • SpeedometerWidth As Float [write only]
    • Tag As Object
    • TextColor As Int [write only]
    • Top As Int
    • TrianglesColor As Int [write only]
    • Unit As String [write only]
    • Visible As Boolean
    • Width As Int
 

Johan Schoeman

Expert
Licensed User
Longtime User
I know this is an old thread, but I like the design of the gauge and downloaded the sample but still shows issue from this Post....am I missing something?
Open the designer, click on the Activity part of the layout to see the Activity properties and then rename the activity to whatever you want.

JS
 
Last edited:

chris_sung

Member
Licensed User
Hello
How to compile "The Java Code" ?
I want to modify some of the content inside.
Rebuild to generate JAR
 

chris_sung

Member
Licensed User
With SimpleLibraryCompiler

Hi DonManfred

thanks for your reminder.
The jar has been generated with the SLC tool.
But I replaced the original "AwesomeSpeedometer jar" and there was a problem compiling.
Can you please guide me again Thank you.

upload_2018-11-27_0-22-36.png

upload_2018-11-27_0-23-33.png
 

chris_sung

Member
Licensed User
You should always start a new thread for your questions.

OK

But I seem to solve this problem, it seems that there is a problem with the generated XML, compile OK after modifying the XML.
I will study it again. Thank you.
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
OK

But I seem to solve this problem, it seems that there is a problem with the generated XML, compile OK after modifying the XML.
I will study it again. Thank you.
What are you using to compile the library with? Eclipse or SimpleLibraryCompiler?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Missed that one.....:)

Probably something to do with info entered into SLC. What is in -b4aignore? Can't remember if it was "main" or "com" or something else. Look at what the library package name starts with....
 
Top