B4A Library cgCalendar_Monthly_View, cgColorPicker and cgUpDown

Hi Guys,

After a long absence in the sharing sub-part of this wonderful community, I decided to finally finish an old project, and release it to you.
It's a Custom View with Designer Support.
A Calendar view that can be as simple as you want it to be, or as extravagant and colourful as your wildest dreams.
Its just about 98% customizable!!

I intend to create 2 additional views : a Weekly View as well as a Daily View

I hope you like this, and please do post comments, bugs or suggestions

[OBS] I'd like to Thank @RandomCoder for is collaboration in this project.

Change-Log

v1.0
Initial compilation, fully functional
Locale implemented
Most Properties are write only


v1.1
Fixed a MAJOR bug with the sizing of the Calendar
Most Properties are now Read/Write
*NOTE : the Width/Height Write values may slightly differ from the Read values due to inner calculations


v1.2
Added the ability to use a bitmap as the calendar background
Properly notated the several methods for ease of usage

First Public Release


v1.21
Added a new Overlay method that enables the setting of a Bitmap as the Today Marker
(MarkerStyle = 3)
Fixed the event Not Firing BUG



The provided DEMO exhibits and exposes almost all the visual properties of the calendar, however, 2 things were deliberately "Fixed" :
- The FONT property cannot be changed in the DEMO ( I am not happy with this, but to provide the changing functionality I would have to create another custom panel or custom view)
- The Marker Style is set to be 3, Overlay, and will show the value when selecting an image

When satisfied with the looks of your Calendar, click a day, any day in the calendar.
A toast message will appear and the theme will be logged with all the current values.
You then jus need to copy this log to your own calendar project and change whatever still needs to change.
If you prefer MarkerStyles 0 to 2, you MUST first set the related properties like color, border color, border width, etc, before setting the MarkerStyle

I am also providing 2 other Libs along with the calendar.
cgColorPicker, this is a small evolution of my previous version of it, and the original thread will be updated;
cgUpDown, this is a new CustomView providing numerical increment and decrement MATERIAL STYLED.
A new Thread will be created for this one.

Please post any questions/comments/suggestions/BUGs related to the Calendar or the DEMO here.
Anything related with the other two libs should be posted in their correspondant threads.
 

Attachments

  • CalendarDemo.zip
    222.5 KB · Views: 572
  • Triplets.zip
    34.3 KB · Views: 490
Last edited:

Cableguy

Expert
Licensed User
Longtime User
V1.21

Added a new Overlay method that enables the setting of a Bitmap as the Today Marker
(MarkerStyle = 3)

CustomView1.MarkerStyle = 3
CustomView1.MarkerOverlay(LoadBitmap(File.DirAssets,"redcircle2.png"))

Files updated in First post.
Over the weekend I will produce a full blow DEMO with an extra feature, stay tuned!
 

Anser

Well-Known Member
Licensed User
Longtime User
Good work.
A Sample app along with the Library would have been nice.

Regards
Anser
 

iz0ndg

Active Member
Licensed User
Longtime User
Error touching Month label :
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
cgcalendar_monthly_view_sliderpnl_touch (java line: 1602)
java.text.ParseException: Unparseable date: "01 " (at offset 3)
   at java.text.DateFormat.parse(DateFormat.java:555)
   at anywheresoftware.b4a.keywords.DateTime.DateParse(DateTime.java:148)
   at b4a.example.cgcalendar_monthly_view._sliderpnl_touch(cgcalendar_monthly_view.java:1602)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.BA$1.run(BA.java:293)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:146)
   at android.app.ActivityThread.main(ActivityThread.java:5635)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
   at dalvik.system.NativeStart.main(Native Method)
 

Cableguy

Expert
Licensed User
Longtime User
Good work.
A Sample app along with the Library would have been nice.

Regards
Anser
In the post just before yours...

"Over the weekend I will produce a full blow DEMO with an extra feature..."
 

Cableguy

Expert
Licensed User
Longtime User
Error touching Month label :
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
cgcalendar_monthly_view_sliderpnl_touch (java line: 1602)
java.text.ParseException: Unparseable date: "01 " (at offset 3)
   at java.text.DateFormat.parse(DateFormat.java:555)
   at anywheresoftware.b4a.keywords.DateTime.DateParse(DateTime.java:148)
   at b4a.example.cgcalendar_monthly_view._sliderpnl_touch(cgcalendar_monthly_view.java:1602)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.BA$1.run(BA.java:293)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:146)
   at android.app.ActivityThread.main(ActivityThread.java:5635)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
   at dalvik.system.NativeStart.main(Native Method)
That's strange, I took an extra effort to not touch the system DateFormat when doing the parsings...
I will be producing a demo, but in the meantime, can you post me a sample of what you are doing?
 

iz0ndg

Active Member
Licensed User
Longtime User
Sorry,
I think it was my mistake, I added by a designer and then I CustomView1 initialized by code:

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Private CustomView1 As cgCalendar_Monthly_View
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("Layout1")
   Activity.LoadLayout("main")
   CustomView1.Initialize(Me,"CustomView1") ' <-- Error
End Sub

the event should be called...

B4X:
Sub CustomView1_?????

End Sub
 

Cableguy

Expert
Licensed User
Longtime User
if you use the tab when adding the sub, you will see listed in the cgCalendar type, the event "Click"
 

Cableguy

Expert
Licensed User
Longtime User
My bad, will correct it when I get home.
Anyway, the event should be " _click"
 

Cableguy

Expert
Licensed User
Longtime User
The Files have been updated.
The event can now be added from the list of events (tab)
 

Jomagom

Member
Licensed User
Longtime User
Hello,thank you very muchforthe library, I foundseveral flaws:
1.To view the bitmap for the current day, you have tomove forward and backwardon the calendar (CustomView1.MarkerOverlay(LoadBitmap(File.DirAssets,"round.png"))
2.It takestoo long to loadthe background imageand meanwhilethere is a very annoying white screen.
3.If I put MarkerStyle=1 or 2, the application is closed.
We have to improvesomethingthe library,butis fine.
Sorry formyEnglish,it is the translator.
I am Spanish
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Font Sizes are NOT editable, as they are auto adjusted to the View Size.
The correct event name is "Click" and the file has been corrected to show it in the subs events list
The Bitmap background setting uses a routine that can be a bit slow in some devices, but in all the 7 devices I have to test it with, none presented a significant delay in showing the completed Calendar.
I am unable to reproduce your first issue, and until I release my full Demo, hopefully by tomorrow night, I will not be able to fully address it.
 

Jomagom

Member
Licensed User
Longtime User
The click event does not generate any result.

B4X:
Sub CustomView1_Click
Activity.Title="Hello"  
End Sub
 
Last edited:

Jomagom

Member
Licensed User
Longtime User
96gk1h.png

This is the first image you see before show calendar
 

Cableguy

Expert
Licensed User
Longtime User
the Click event has arguments, wich I forgot to add in the declaration;

please use this:

customview1_Click(CurrentDate as string, CurrentDateTicks as Long)
 

Cableguy

Expert
Licensed User
Longtime User
Are you using the Emulator????
It's VERY VERY VERY VERY.... did I say VERY already? SLOW!!!!
Please use a real device!
 

Jomagom

Member
Licensed User
Longtime User
The image is a real device.
Customview1_Click(CurrentDate as string, CurrentDateTicks as Long)
does not work
 

Cableguy

Expert
Licensed User
Longtime User
Can you please hold until tomorrow, I will post a fully working demo!
Sorry for the trouble but I need the time to complete the demo.
Please do post any other issues that you may encounter so that I can address them
 

Cableguy

Expert
Licensed User
Longtime User
I m sorry to announce that the DEMO is not yet ready due to family obligations and will be released during the week.
This Demo is more of a tool/showcase that will allow the developers using the Calendar view to create on the fly the visuals of the CustomView and easily integrate it in their own code.
It is not a simple Demo, so please be patient.
 
Top