B4A Library ShineButton

A wrap for this Github project. Posting:
1. B4A sample project
2. B4A library files.

Take note of the B4A project's /Objects/res/... folder and the files they contain.

demo.gif


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

#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 sb1 As ShineButton

    Private sb2 As ShineButton
    Private sb3 As ShineButton
    Private sb4 As ShineButton
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")
   
   
    sb1.ShapeResource = "heart"
    sb1.BtnColor = Colors.Gray
    sb1.BtnFillColor = Colors.Red
    sb1.AllowRandomColor = True
    sb1.EnableFlashing = True
    sb1.BigShineColor = Colors.Yellow
    sb1.ClickAnimDuration = 200
    sb1.AnimDuration = 1000
    sb1.ShineTurnAngle = 180
    sb1.SmallShineColor = Colors.Green
   
    sb2.ShapeResource = "like"
    sb2.BtnColor = Colors.Gray
    sb2.BtnFillColor = Colors.Blue
    sb2.AllowRandomColor = True
    sb2.EnableFlashing = True
    sb2.BigShineColor = Colors.Green
    sb2.ClickAnimDuration = 200
    sb2.AnimDuration = 1000
    sb2.ShineTurnAngle = 180
    sb2.SmallShineColor = Colors.Yellow
   
    sb3.ShapeResource = "smile"
    sb3.BtnColor = Colors.Gray
    sb3.BtnFillColor = Colors.Yellow
    sb3.AllowRandomColor = True
    sb3.EnableFlashing = True
    sb3.BigShineColor = Colors.Red
    sb3.ClickAnimDuration = 200
    sb3.AnimDuration = 1000
    sb3.ShineTurnAngle = 180
    sb3.SmallShineColor = Colors.Green
   
    sb4.ShapeResource = "star"
    sb4.BtnColor = Colors.Gray
    sb4.BtnFillColor = Colors.Green
    sb4.AllowRandomColor = True
    sb4.EnableFlashing = True
    sb4.BigShineColor = Colors.Magenta
    sb4.ClickAnimDuration = 200
    sb4.AnimDuration = 1000
    sb4.ShineTurnAngle = 180
    sb4.SmallShineColor = Colors.Red           

End Sub

Sub Activity_Resume
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub sb1_check_changed (check As Boolean)
   
    Log("Button sb1 status = " & check)
    'If check = True Then sb1.Checked = False
   
End Sub

Sub sb1_button_clicked
   
    Log("sb1 clicked")
   
End Sub

Sub sb2_check_changed (check As Boolean)
   
    Log("Button sb2 status = " & check)
    'If check = True Then sb2.Checked = False
   
End Sub

Sub sb2_button_clicked
   
    Log("sb2 clicked")
   
End Sub

Sub sb3_check_changed (check As Boolean)
   
    Log("Button sb3 status = " & check)
    'If check = True Then sb3.Checked = False
   
End Sub

Sub sb3_button_clicked
   
    Log("sb3 clicked")
   
End Sub

Sub sb4_check_changed (check As Boolean)
   
    Log("Button sb4 status = " & check)
    'If check = True Then sb4.Checked = False
   
End Sub

Sub sb4_button_clicked
   
    Log("sb4 clicked")
   
End Sub

Library:
ShineButton
Author:
Github: Chad Song, Wrapped by: Johan Schoeman
Version: 1
  • ShineButton
    Events:
    • button_clicked, check_changed (check As Boolean)
    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)
    • setCancel
    • showAnim
    Properties:
    • AllowRandomColor As Boolean [write only]
    • AnimDuration As Int [write only]
    • Background As Drawable
    • BigShineColor As Int [write only]
    • BtnColor As Int [write only]
    • BtnFillColor As Int [write only]
    • Checked As Boolean [write only]
    • ClickAnimDuration As Int [write only]
    • Color As Int [write only]
    • EnableFlashing As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • ShapeResource As String [write only]
    • ShineCount As Int [write only]
    • ShineDistanceMultiple As Float [write only]
    • ShineTurnAngle As Float [write only]
    • SmallShineColor As Int [write only]
    • SmallShineOffAngle As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

1.png


2.png


3.png


4.png


5.png
 

Attachments

  • ShineButtonLibFiles.zip
    28.8 KB · Views: 427
  • b4aShineButton.zip
    18 KB · Views: 404

Mashiane

Expert
Licensed User
Longtime User
A wrap for this Github project. Posting:
1. B4A sample project
2. B4A library files.

Take note of the B4A project's /Objects/res/... folder and the files they contain.

View attachment 45902

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

#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 sb1 As ShineButton

    Private sb2 As ShineButton
    Private sb3 As ShineButton
    Private sb4 As ShineButton
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")
  
  
    sb1.ShapeResource = "heart"
    sb1.BtnColor = Colors.Gray
    sb1.BtnFillColor = Colors.Red
    sb1.AllowRandomColor = True
    sb1.EnableFlashing = True
    sb1.BigShineColor = Colors.Yellow
    sb1.ClickAnimDuration = 200
    sb1.AnimDuration = 1000
    sb1.ShineTurnAngle = 180
    sb1.SmallShineColor = Colors.Green
  
    sb2.ShapeResource = "like"
    sb2.BtnColor = Colors.Gray
    sb2.BtnFillColor = Colors.Blue
    sb2.AllowRandomColor = True
    sb2.EnableFlashing = True
    sb2.BigShineColor = Colors.Green
    sb2.ClickAnimDuration = 200
    sb2.AnimDuration = 1000
    sb2.ShineTurnAngle = 180
    sb2.SmallShineColor = Colors.Yellow
  
    sb3.ShapeResource = "smile"
    sb3.BtnColor = Colors.Gray
    sb3.BtnFillColor = Colors.Yellow
    sb3.AllowRandomColor = True
    sb3.EnableFlashing = True
    sb3.BigShineColor = Colors.Red
    sb3.ClickAnimDuration = 200
    sb3.AnimDuration = 1000
    sb3.ShineTurnAngle = 180
    sb3.SmallShineColor = Colors.Green
  
    sb4.ShapeResource = "star"
    sb4.BtnColor = Colors.Gray
    sb4.BtnFillColor = Colors.Green
    sb4.AllowRandomColor = True
    sb4.EnableFlashing = True
    sb4.BigShineColor = Colors.Magenta
    sb4.ClickAnimDuration = 200
    sb4.AnimDuration = 1000
    sb4.ShineTurnAngle = 180
    sb4.SmallShineColor = Colors.Red          

End Sub

Sub Activity_Resume
  

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub sb1_check_changed (check As Boolean)
  
    Log("Button sb1 status = " & check)
    'If check = True Then sb1.Checked = False
  
End Sub

Sub sb1_button_clicked
  
    Log("sb1 clicked")
  
End Sub

Sub sb2_check_changed (check As Boolean)
  
    Log("Button sb2 status = " & check)
    'If check = True Then sb2.Checked = False
  
End Sub

Sub sb2_button_clicked
  
    Log("sb2 clicked")
  
End Sub

Sub sb3_check_changed (check As Boolean)
  
    Log("Button sb3 status = " & check)
    'If check = True Then sb3.Checked = False
  
End Sub

Sub sb3_button_clicked
  
    Log("sb3 clicked")
  
End Sub

Sub sb4_check_changed (check As Boolean)
  
    Log("Button sb4 status = " & check)
    'If check = True Then sb4.Checked = False
  
End Sub

Sub sb4_button_clicked
  
    Log("sb4 clicked")
  
End Sub

Library:
ShineButton
Author:
Github: Chad Song, Wrapped by: Johan Schoeman
Version: 1
  • ShineButton
    Events:
    • button_clicked, check_changed (check As Boolean)
    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)
    • setCancel
    • showAnim
    Properties:
    • AllowRandomColor As Boolean [write only]
    • AnimDuration As Int [write only]
    • Background As Drawable
    • BigShineColor As Int [write only]
    • BtnColor As Int [write only]
    • BtnFillColor As Int [write only]
    • Checked As Boolean [write only]
    • ClickAnimDuration As Int [write only]
    • Color As Int [write only]
    • EnableFlashing As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • ShapeResource As String [write only]
    • ShineCount As Int [write only]
    • ShineDistanceMultiple As Float [write only]
    • ShineTurnAngle As Float [write only]
    • SmallShineColor As Int [write only]
    • SmallShineOffAngle As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

View attachment 45903

View attachment 45904

View attachment 45905

View attachment 45906

View attachment 45907
Wow, this is so mnca yho! Are you sure you are human??? Love your work... ;)
 

alimanam3386

Active Member
Licensed User
Longtime User
Hi

When I use AppCompact lib with yours library I get bellow error :

do.php
 
Last edited:

MhdBoy

Member
Licensed User
Longtime User
Hi
why the library get me error?
my code:


B4X:
For i = 0 To 2
Dim pl As Panel
pl.Initialize("pl")
ScrollView1.Panel.AddView(pl,0,stop,100%x,300dip)
stop = stop + 260dip
pl.LoadLayout("twete")
Dim ShineButton1 AS ShineButton
ShineButton1.ShapeResource= "heart"
ShineButton1.BtnColor = Colors.Gray
ShineButton1.BtnFillColor = Colors.Red
ShineButton1.AllowRandomColor = True
ShineButton1.EnableFlashing = True
ShineButton1.BigShineColor = Colors.Yellow
ShineButton1.ClickAnimDuration = 200
ShineButton1.AnimDuration = 1000
ShineButton1.ShineTurnAngle = 180
ShineButton1.SmallShineColor = Colors.Green
Next


error:
B4X:
Error occurred on line: 135 (home)
java.lang.NullPointerException: Attempt to invoke virtual method 'void main.java.com.sackcentury.shinebuttonlib.ShineButton.setShapeResource(int)' on a null object reference
at shinebuttonwrapper.shinebuttonWrapper.setShapeResource(shinebuttonWrapper.java:475)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:748)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at ir.Baloutgroup.Dezfull.home.afterFirstLayout(home.java:102)
at ir.Baloutgroup.Dezfull.home.access$000(home.java:17)
at ir.Baloutgroup.Dezfull.home$WaitForLayout.run(home.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
* Activity (home) Resume *

Line 135 : ShineButton1.ShapeResource= "heart"

i copy heart.png to my res->raw project folder
how i can fix it?
 

scsjc

Well-Known Member
Licensed User
Longtime User
Hello really good work...

i have a little cuestion, i try this code...and get number via v.tag... but always get a last number from loop ... 10
where are my mistake ?
thanks !!!

B4X:
Dim corazon As ShineButton
For a=1 To 10
    corazon.Initialize("corazon")
    fondo.AddView(corazon,label.width-30dip,label.Top + 10dip,28dip,28dip)
    corazon.ShapeResource = "heart"
    corazon.BtnColor = Colors.Gray
    corazon.BtnFillColor = Colors.Red
    corazon.AllowRandomColor = True
    corazon.EnableFlashing = True
    corazon.BigShineColor = Colors.Yellow
    corazon.ClickAnimDuration = 200
    corazon.AnimDuration = 1000
    corazon.ShineTurnAngle = 180
    corazon.SmallShineColor = Colors.Green
    corazon.Tag= a
Next

Sub corazon_button_clicked
    'Log("corazon clicked")
    Dim v As View
    v = Sender
    Log(v.tag)


End Sub
 

Attachments

  • shinebutton_tags.zip
    18.2 KB · Views: 277
Last edited:
Top