B4A Library CompassView - Another CompassView

A warp for this Github project. Sure you will know what to do with the attached files.

1.png


Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aNewCompassView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #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.

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 ncv1, ncv2, ncv3 As NewCompassView
    
    Private mbm1, mbm2, mbm3 As Bitmap
    Private bmd1, bmd2, bmd3 As BitmapDrawable
    
    
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")
    
    mbm1.Initialize(File.DirAssets, "ic_needle_2.png")
    bmd1.Initialize(mbm1)
    
    ncv1.DegreesColor = Colors.Yellow
    ncv1.BorderColor = Colors.White
    ncv1.DegreeValueColor = Colors.Red
    ncv1.OrientationLabelsColor = Colors.Magenta
    ncv1.ShowBorder = True
    ncv1.ShowDegreeValue = True
    ncv1.ShowOrientationLabels = True
    ncv1.DegreesStep = 5
    ncv1.Needle = bmd1
    
    'second compass
    mbm2.Initialize(File.DirAssets, "ic_needle_1.png")
    bmd2.Initialize(mbm2)
    
    ncv2.DegreesColor = Colors.Cyan
    ncv2.BorderColor = Colors.Green
    ncv2.DegreeValueColor = Colors.White
    ncv2.OrientationLabelsColor = Colors.Blue
    ncv2.ShowBorder = True
    ncv2.ShowDegreeValue = True
    ncv2.ShowOrientationLabels = True
    ncv2.DegreesStep = 15
    ncv2.Needle = bmd2
    
    'third compass
    mbm3.Initialize(File.DirAssets, "ic_needle.png")
    bmd3.Initialize(mbm3)
    
    ncv3.DegreesColor = Colors.White
    ncv3.BorderColor = Colors.White
    ncv3.DegreeValueColor = Colors.White
    ncv3.OrientationLabelsColor = Colors.White
    ncv3.ShowBorder = True
    ncv3.ShowDegreeValue = True
    ncv3.ShowOrientationLabels = False
    ncv3.DegreesStep = 45
    ncv3.Needle = bmd3

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub ncv1_sensor_changed(value As Double)
    
    Log("Compass 1  = " & value)
    
End Sub

Sub ncv2_sensor_changed(value As Double)
    
    Log("Compass 2  = " & value)
    
End Sub

Sub ncv3_sensor_changed(value As Double)
    
    Log("Compass 3  = " & value)
    
End Sub

Library:
NewComapssView
Author:
Github: Belkilani Ahmed Radhouane, Wrapped by: Johan Schoeman
Version: 1
  • NewCompassView
    Events:
    • sensor_changed (value As Double)
    Fields:
    • ba As anywheresoftware.b4a.BA
    Methods:
    • DesignerCreateView (base As anywheresoftware.b4a.objects.PanelWrapper, lw As anywheresoftware.b4a.objects.LabelWrapper, props As anywheresoftware.b4a.objects.collections.Map) As void
    • IsInitialized As boolean
    • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
    • BringToFront As void
    • SetLayout (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
    • SendToBack As void
    • SetVisibleAnimated (arg0 As int, arg1 As boolean) As void
    • RemoveView As void
    • Invalidate3 (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
    • Invalidate2 (arg0 As android.graphics.Rect) As void
    • SetColorAnimated (arg0 As int, arg1 As int, arg2 As int) As void
    • SetBackgroundImageNew (arg0 As android.graphics.Bitmap) As anywheresoftware.b4a.objects.drawable.BitmapDrawable
    • Invalidate As void
    • SetLayoutAnimated (arg0 As int, arg1 As int, arg2 As int, arg3 As int, arg4 As int) As void
    • RequestFocus As boolean
    Properties:
    • OrientationLabelsColor As int [write only]
    • DegreesStep As int [write only]
    • DegreesColor As int [write only]
    • Left As int
    • Background As android.graphics.drawable.Drawable
    • Parent As java.lang.Object [read only]
    • Color As int [write only]
    • BorderColor As int [write only]
    • ShowDegreeValue As boolean [write only]
    • Enabled As boolean
    • ShowOrientationLabels As boolean [write only]
    • Top As int
    • Needle As android.graphics.drawable.Drawable [write only]
    • Visible As boolean
    • Padding As int[]
    • Height As int
    • DegreeValueColor As int [write only]
    • Tag As java.lang.Object
    • Width As int
    • ShowBorder As boolean [write only]
 

Attachments

  • b4aNewCompassView.zip
    29.8 KB · Views: 588
  • b4aLibFiles.zip
    14.6 KB · Views: 565
  • LibRes.zip
    87.9 KB · Views: 568

nedium

Active Member
Licensed User
Longtime User
Hello @Johan Schoeman

I wanted to use your library but it generates an error even with the published example, I wanted to know if there is a solution. It gives me the same error as in the following publication and I have followed all the steps the same as the example.

 

Johan Schoeman

Expert
Licensed User
Longtime User
Hello @Johan Schoeman

I wanted to use your library but it generates an error even with the published example, I wanted to know if there is a solution. It gives me the same error as in the following publication and I have followed all the steps the same as the example.

What have you done with the folder LibRes in your project?
 

Johan Schoeman

Expert
Licensed User
Longtime User
How to do with the folder LibRes? I confused.
LibRes with its contents must the in the B4A project folder on the same level as the /Files and /Objects folders of the B4A project

MyB4Aproject
Object
Files
LibRes
 
Top