B4A Library LikeButtonView

The attached project warps the bare essentials of this Github project. There are files in the /Objects/res/xxx folders that are write protected and that the project depends on. Thus, if you want to use this project you need to use it as your base to start working from.

It raises a toggle event in the B4A project whenever the "like" view is clicked.

Posting the following:
1. The B4A project demonstrating this wrapper
2. The library files (2 x jar and 1 x xml) - copy them to your additional library folder.
3. The Java code - change it to your liking.

Below some pics of the animation that I caught in action:

1.png


2.png


3.png


4.png


The library as it stands at present:

LikeButtonView
Author:
Github: Miroslaw Stanek, Wrapped by: Johan Schoeman
Version: 1
  • LikeAnimation
    Events:
    • like_toggled
    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)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

Sample Code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aLikeButtonView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #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 lbv1 As LikeAnimation
    Private lbv2 As LikeAnimation
    Private lbv3 As LikeAnimation
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")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub lbv1_like_toggled
  
    Log("lbv1 toggled")
  
End Sub

Sub lbv2_like_toggled
  
    Log("lbv2 toggled")
  
End Sub

Sub lbv3_like_toggled
  
    Log("lbv3 toggled")
  
End Sub
 

Attachments

  • LikeButtonViewLibFiles.zip
    28.1 KB · Views: 303
  • b4aLikeButtonView.zip
    25.3 KB · Views: 295
  • TheJavaCode.zip
    62.9 KB · Views: 276
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
You are very fast i just finished it lol...
Post it....I have just done the bare essentials and therefore posted the Java code in case someone wants to take it further...
 

Daniel-White

Active Member
Licensed User
Longtime User
Hi Johan, nice job, It is very comfortable to use in "Visual Designer" the Script-General you did it there.

Question for everybody.
I know I am asking too much, but with this library, (this is the visual art), Can we integrate it with the score system in Google Play store,? I mean, the end user select an example 4 stars in our APP and give it to play store without need to go manually to the web of Play Store , how we can do it?.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan, nice job, It is very comfortable to use in "Visual Designer" the Script-General you did it there.

Question for everybody.
I know I am asking too much, but with this library, (this is the visual art), Can we integrate it with the score system in Google Play store,? I mean, the end user select an example 4 stars in our APP and give it to play store without need to go manually to the web of Play Store , how we can do it?.
You will have to do that in the B4A code of your project. I merely brought back the toggle of the stars in the library via the wrapper into B4A. You will also need to keep track of the state of the stars in your B4A project (i.e wether a star is "enabled" or not). But that is easy /simple to do.
 

jahswant

Well-Known Member
Licensed User
Longtime User
You will have to do that in the B4A code of your project. I merely brought back the toggle of the stars in the library via the wrapper into B4A. You will also need to keep track of the state of the stars in your B4A project (i.e wether a star is "enabled" or not). But that is easy /simple to do.
It's Single IE Not joined.You will need to treat every star differently.
 

Reids

Member
Licensed User
Longtime User
This is great library, but I have small problem here
1.there is no lbv1.isstared method on this lib to know if there is star clicked or not, toggle seem only set it, but if we read star data from database we should need this method
2.I'm using kitkat 4.4.4 Cyanogenmod there is no animation like screenshot above, only zoom in / out animation when clicked

Thank You :D
 

Johan Schoeman

Expert
Licensed User
Longtime User
This is great library, but I have small problem here
1.there is no lbv1.isstared method on this lib to know if there is star clicked or not, toggle seem only set it, but if we read star data from database we should need this method
2.I'm using kitkat 4.4.4 Cyanogenmod there is no animation like screenshot above, only zoom in / out animation when clicked

Thank You :D
As I have said in post #1, I have wrapped the bare essentials and therefore also posted the Java code for whoever wants to do something with it. I spent basically about 90% of the time on doing this wrapper to get rid of the dependency on ButterKnife. Have tested it ony on 2 x KitKat devices and it worked fine....as per the pics.
 

yousif

New Member
Licensed User
Longtime User
it is good library
But don't work with B4A 6 with Firebase ... you should remove android-support-annotations.jar with library because .I get Error :

B4A version: 6.00
Parsing code. (0.02s)
Compiling code. (0.17s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. (0.87s)
Compiling debugger engine code. (2.61s)
Compiling generated Java code. (4.11s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/annotation/DimenRes;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:615)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
at com.android.dx.command.dexer.Main.access$2(Main.java:546)
at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:537)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
at com.android.dx.command.dexer.Main.run(Main.java:206)
at com.android.dx.command.dexer.Main.main(Main.java:179)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
 

BarryW

Active Member
Licensed User
Longtime User
B4A version: 6.30
Parsing code. (0.01s)
Compiling code. (0.06s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.10s)
Compiling generated Java code. (1.81s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/annotation/ColorRes;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:615)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
at com.android.dx.command.dexer.Main.access$2(Main.java:546)
at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:537)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
at com.android.dx.command.dexer.Main.run(Main.java:206)
at com.android.dx.command.dexer.Main.main(Main.java:179)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting

I also got this error.
 
Top