B4A Library MyDynamicCalendar

A partial shortcut wrap for this Github sample and this Github project.

This is Donation Ware and will expire on 29 April 2017 (donation = add additional features such as other colors, etc))

As "old school" as what I am you will need the following jars in your additional library folder (and I guess just about everyone has them there)
android-support-v4.jar
android-support-v7-appcompat.jar
android-support-v7-recyclerview.jar

It is quite a nice Calendar - you need to populate the events from within your B4A code.

I am using B4A version 6.50
I am using AppCompat V3.51 by @corwin42 (Thanks M)

Posting the following:
B4A sample project
B4A library files

You can find the remainder of the libs used (AppCompat V3.51) on the forum.

Extract folders DemoRes and LibRes and copy them to be on the same folder level as that of the B4A project's /Files and /Objects folders.

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

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#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.
   
    Dim dc As DynamicCalendar

    Private Button1 As Button
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")
   
    dc.Initialize("")
   
    Dim dates() As String = Array As String("10-04-2017","15-04-2017", "16-04-2017", "19-04-2017", "18-04-2017", "24-04-2017")
    Dim starttime() As String = Array As String("08:00", "08:00", "09:00", "10:00", "14:00", "15:00")
    Dim endtime() As String = Array As String("08:30", "08:15", "09:25", "10:45", "14:55", "15:15")
    Dim events() As String = Array As String("Safety Meeting", "Quality Meeting", "Supplier Meeting", "Customer Meeting", "IR Meeting", "Finance Meeting")
   
    dc.addEvents(dates, starttime, endtime, events)
   
    Dim holidays() As String = Array As String("14-04-2017", "17-04-2017", "25-12-2017", "26-12-2017", "01-01-2018")
    dc.addHolidays(holidays)
   
    dc.CalendarBackgroundColor = Colors.Green              'the color below the calendar when the Calendar Activity starts
    dc.HeaderBackgroundColor = Colors.Cyan                 'the background color of the 'banner' where the circles and arrows left/right appear
    dc.HeaderTextColor = Colors.Black                      'the color of the text in the 'banner' set in the above line of code
    dc.WeekDayLayoutBackgroundColor = Colors.Yellow        'the background color of the banner where the day names appear
    dc.NextPreviousIndicatorColor = Colors.Red             'the color of the circles and the arrows within them
    dc.ExtraDatesOfMonthBackgroundColor = Colors.ARGB(50, 175, 0, 100)
    dc.ExtraDatesOfMonthTextColor = Colors.Yellow
   
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
   
    dc.startCalendar
   
End Sub
 

Attachments

  • b4aDynamicCalendar.zip
    8.3 KB · Views: 641
  • DynamicCalendarLibFiles.zip
    53.8 KB · Views: 623
  • DemoRes.zip
    31.8 KB · Views: 635
  • LibRes.zip
    37.4 KB · Views: 610

Johan Schoeman

Expert
Licensed User
Longtime User
is it possible receive a apk demo for a dinamic evalutaion?
Have taken out the date limitation...

You will need android-support-v4.jar, android-support-v7-appcompat.jar, android-support-v7-recyclerview.jar, and AppCompat.aar to be in your additional library folder - sure you will figure out where to find them should you not have them in your additional libs folder already

Posting:
1. LibRes.zip - extract it and copy the LibRes folder and its contents to be on the same folder level as that of the B4A projects /Files and /Objects folders
2. Sample B4A project
3. B4A library files

Libs enabled:
1.png


B4A sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDynamicCalendar
    #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 mdc As myDynamicCalendar
    Dim maxindex As Int = 0
   
    Private Button1 As Button
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")
   
    Activity.AddMenuItem("Month", "Month")
    Activity.AddMenuItem("Month with Events", "MonthWithEvents")
    Activity.AddMenuItem("Week", "Week")
    Activity.AddMenuItem("Day", "Day")
    Activity.AddMenuItem("Agenda", "Agenda")
    Activity.AddMenuItem("Today", "Today")
   
   
    Dim dates() As String = Array As String("10-06-2017","15-06-2017", "16-06-2017", "19-07-2017", "18-07-2017", "18-07-2017", "30-06-2017")
    Dim starttime() As String = Array As String("08:00", "08:00", "09:00", "10:00", "14:00", "17:00", "15:00")
    Dim endtime() As String = Array As String("08:30", "08:15", "09:25", "10:45", "14:55", "17:25", "15:15")
    Dim events() As String = Array As String("Safety Meeting", "Quality Meeting", "Supplier Meeting", "Customer Meeting", "IR Meeting", "My Time", "Finance Meeting")
   
    Dim weekdaynames() As String = Array As String("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
    'Dim weekdaynames() As String = Array As String("星期一", "星期二", "星期四", "星期三", "星期五", "星期六", "星期日")

   
    Dim holidays() As String = Array As String("14-06-2017", "17-06-2017", "25-12-2017", "26-12-2017", "01-01-2018")

    mdc.showMonthView
    For i = 0 To 6
        mdc.addEvent(dates(i), starttime(i), endtime(i), events(i))
    Next
   
    For i = 0 To 4
        mdc.addHolidays(holidays(i))
    Next


    mdc.HolidayCellBackgroundColor = Colors.LightGray
    mdc.HolidayCellTextColor = Colors.Red
    mdc.CalendarBackgroundColor = Colors.White
    mdc.HeaderBackgroundColor = Colors.White
    mdc.HeaderTextColor = Colors.Magenta
    mdc.NextPreviousIndicatorColor = Colors.Blue
    mdc.WeekDayLayoutBackgroundColor = Colors.Blue
    mdc.WeekDayLayoutTextColor = Colors.White
    mdc.isSaturdayOff(True, Colors.LightGray, Colors.Red)
    mdc.isSundayOff(True, Colors.LightGray, Colors.Red)
    mdc.ExtraDatesOfMonthBackgroundColor = Colors.Black
    mdc.ExtraDatesOfMonthTextColor = Colors.White
    mdc.DatesOfMonthBackgroundColor = Colors.Cyan
    mdc.DatesOfMonthTextColor = Colors.ARGB(200, 255, 0, 100)
   
    mdc.WeekDayNames = weekdaynames
   
    mdc.CurrentDateBackgroundColor = Colors.Red
    mdc.CurrentDateTextColor = Colors.White
   
    mdc.EventCellBackgroundColor = Colors.White
    mdc.EventCellTextColor = Colors.Blue
    mdc.BelowMonthEventTextColor = Colors.Black
    mdc.BelowMonthEventDividerColor = Colors.Red
    mdc.HolidayCellClickable = True
   
    mdc.ListOfEvents                 'see the event being raised - Sub mdc_get_events(eventname As String, eventstartdate As String, eventstrattime As String, eventendtime As String)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Month_Click
   
    mdc.showMonthView
   
End Sub

Sub MonthWithEvents_Click
   
    mdc.showMonthViewWithBelowEvents
   
End Sub

Sub Week_Click
   
    mdc.showWeekView
   
End Sub

Sub Day_Click
   
    mdc.showDayView
   
End Sub

Sub Agenda_Click
   
    mdc.showAgendaView
   
End Sub

Sub Today_Click
   
    mdc.showToday   
   
End Sub


Sub mdc_get_events(eventname As String, eventstartdate As String, eventstarttime As String, eventendtime As String, index As Int)
    Log("eventname = " & eventname)
    Log("eventstartdate = " & eventstartdate)
    Log("eventstarttime = " & eventstarttime)
    Log("eventendtime = " & eventendtime)
    Log("index = " & index)
    maxindex = index
    Log("maxindex = " & maxindex)
    Log("***************************")
   
End Sub



Sub Button1_Click
   
    mdc.deleteEvent(0)
    mdc.showMonthViewWithBelowEvents
    Log("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
    mdc.ListOfEvents                 'see the event being raised - Sub mdc_get_events(eventname As String, eventstartdate As String, eventstrattime As String, eventendtime As String)
   
End Sub

Sub mdc_previous_selected()
   
    Log("arrow previous clicked")
   
End Sub

Sub mdc_next_selected()
   
    Log("arrow next clicked")
   
End Sub

Sub mdc_month_view_event_selected(eventlist As Object)
   
    Dim mylist As List  = eventlist
    For i = 0 To mylist.Size - 1
        Log("mdc_month_view_event_selected(" & i & ") = " & mylist.Get(i))
    Next
   
   
End Sub

Sub mdc_day_clicked(day As String, time As String)
   
    Log("DAY = " & day)
    Log("TIME = "& time)
    Log("*******************")
   
End Sub
 

Attachments

  • b4aDynamicCalendar.zip
    9.2 KB · Views: 430
  • LibRes.zip
    37.4 KB · Views: 417
  • myDynamicCalendar.zip
    58.1 KB · Views: 414

MAGAREY

Member
Licensed User
Longtime User
Is it possible to hide the top bar, to prevent the user from navigating between months / weeks?
 

larprogramer

Member
Licensed User
A partial shortcut wrap for this Github sample and this Github project.

This is Donation Ware and will expire on 29 April 2017 (donation = add additional features such as other colors, etc))

As "old school" as what I am you will need the following jars in your additional library folder (and I guess just about everyone has them there)
android-support-v4.jar
android-support-v7-appcompat.jar
android-support-v7-recyclerview.jar

It is quite a nice Calendar - you need to populate the events from within your B4A code.

I am using B4A version 6.50
I am using AppCompat V3.51 by @corwin42 (Thanks M)

Posting the following:
B4A sample project
B4A library files

You can find the remainder of the libs used (AppCompat V3.51) on the forum.

Extract folders DemoRes and LibRes and copy them to be on the same folder level as that of the B4A project's /Files and /Objects folders.

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

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#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.
 
    Dim dc As DynamicCalendar

    Private Button1 As Button
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")
 
    dc.Initialize("")
 
    Dim dates() As String = Array As String("10-04-2017","15-04-2017", "16-04-2017", "19-04-2017", "18-04-2017", "24-04-2017")
    Dim starttime() As String = Array As String("08:00", "08:00", "09:00", "10:00", "14:00", "15:00")
    Dim endtime() As String = Array As String("08:30", "08:15", "09:25", "10:45", "14:55", "15:15")
    Dim events() As String = Array As String("Safety Meeting", "Quality Meeting", "Supplier Meeting", "Customer Meeting", "IR Meeting", "Finance Meeting")
 
    dc.addEvents(dates, starttime, endtime, events)
 
    Dim holidays() As String = Array As String("14-04-2017", "17-04-2017", "25-12-2017", "26-12-2017", "01-01-2018")
    dc.addHolidays(holidays)
 
    dc.CalendarBackgroundColor = Colors.Green              'the color below the calendar when the Calendar Activity starts
    dc.HeaderBackgroundColor = Colors.Cyan                 'the background color of the 'banner' where the circles and arrows left/right appear
    dc.HeaderTextColor = Colors.Black                      'the color of the text in the 'banner' set in the above line of code
    dc.WeekDayLayoutBackgroundColor = Colors.Yellow        'the background color of the banner where the day names appear
    dc.NextPreviousIndicatorColor = Colors.Red             'the color of the circles and the arrows within them
    dc.ExtraDatesOfMonthBackgroundColor = Colors.ARGB(50, 175, 0, 100)
    dc.ExtraDatesOfMonthTextColor = Colors.Yellow
 
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
 
    dc.startCalendar
 
End Sub


may i ask you how to refresh calendar?
i want refresh color Red when start activity calendar
 

Attachments

  • kkh.PNG
    kkh.PNG
    13 KB · Views: 284
Last edited:

MAGAREY

Member
Licensed User
Longtime User
its posible to capture the click in the events? (MonthViewWithBelowEvents), or exist a event_click event?
 

BluSky76

Member
Licensed User
Longtime User
Hello with B4x not working error on startup:

java.lang.RuntimeException: Unable to start activity ComponentInfo{JHS.DynamicCalendar/JHS.DynamicCalendar.main}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
 

jahswant

Well-Known Member
Licensed User
Longtime User
java.lang.RuntimeException: Unable to start activity ComponentInfo{JHS.DynamicCalendar/JHS.DynamicCalendar.main}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Check AppCompact library in your project. Download an example on the forum look at the manifest and bring the theme part to your project.
 

BluSky76

Member
Licensed User
Longtime User
Check AppCompact library in your project. Download an example on the forum look at the manifest and bring the theme part to your project.

AppCompact is configured correctly. I never had any problems until I upgraded B4X to version 9.80

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/JHS.DynamicCalendar-1.apk"],nativeLibraryDirectories=[/data/app-lib/JHS.DynamicCalendar-1, /vendor/lib, /system/lib]]

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView"

1. Which B4A Version are you using?
2. Are you compiling against AndroidX? Please post the full compilingwindow text.
3. Did you jetified all Additional Libraries?
 

BluSky76

Member
Licensed User
Longtime User
1. Which B4A Version are you using?
2. Are you compiling against AndroidX? Please post the full compilingwindow text.
3. Did you jetified all Additional Libraries?

1. B4X 9.80

B4X:
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 38 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at JHS.DynamicCalendar.main._activity_create(main.java:392)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at JHS.DynamicCalendar.main.afterFirstLayout(main.java:104)
    at JHS.DynamicCalendar.main.access$000(main.java:17)
    at JHS.DynamicCalendar.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5299)
    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:829)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 22 more
Caused by: android.view.InflateException: Binary XML file line #202: Error inflating class android.support.v7.widget.RecyclerView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.desai.vatsal.mydynamiccalendar.MyDynamicCalendar.init(MyDynamicCalendar.java:95)
    at com.desai.vatsal.mydynamiccalendar.MyDynamicCalendar.<init>(MyDynamicCalendar.java:79)
    at dynamiccalendarwrapper.dynamiccalendarWrapper._initialize(dynamiccalendarWrapper.java:94)
    ... 26 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/JHS.DynamicCalendar-2.apk"],nativeLibraryDirectories=[/data/app-lib/JHS.DynamicCalendar-2, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.view.LayoutInflater.createView(LayoutInflater.java:559)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    ... 38 more
** Activity (main) Resume **

3. Yes (myDynamicCalendar.androidx.jar)
 

DonManfred

Expert
Licensed User
Longtime User
2. Are you compiling against AndroidX? Please post the full compilingwindow text.
I wanted to see the COMPILATION WINDOW text. NOT the error you got.

B4A Version: 9.80
Java Version: 8
Parsing code. (0.45s)
Building folders structure. (0.36s)
Compiling code. (0.39s)
Compiling layouts code. (0.09s)
Organizing libraries. (0.02s)
(AndroidX SDK)
Running custom action. (0.18s)
Generating R file. (6.22s)
Compiling generated Java code. (8.52s)
Convert byte code - optimized dex. (20.74s)
Optimized dexer failed. Switching to Standard dexer.
Packaging files. (4.31s)
Copying libraries resources (1.16s)
Found 44 resource files.
Signing package file (private key). (3.68s)
ZipAlign file. (0.24s)
Installing file to device. Error
No device found.

But when you say you are using AndroidX i fear that the Library is not compatible with AndroidX without changing something in the Lib (or the used Resources)...
 

BluSky76

Member
Licensed User
Longtime User
Ops. Sorry

B4X:
B4A Version: 9.80
Java Version: 11
Parsing code.    (0.01s)
Building folders structure.    (0.05s)
Compiling code.    (0.03s)
    
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    (0.00s)
Compiling generated Java code.    (0.11s)
Convert byte code - optimized dex.    (5.25s)
Packaging files.    (3.75s)
Copying libraries resources    (0.00s)
Signing package file (private key).    (4.27s)
ZipAlign file.    (1.95s)
Installing file to device.    (1.75s)
    Installing with B4A-Bridge.
Completed successfully.
 

DonManfred

Expert
Licensed User
Longtime User

BluSky76

Member
Licensed User
Longtime User
Solved,
i replaced the entries in the my_dynamic_calendar.xml file:

android.support.v7.widget.RecyclerView
android.support.v4.view.ViewPager

with

androidx.recyclerview.widget.RecyclerView
androidx.viewpager.widget.ViewPager

and it works

Thanks
 

ermiakhan

Member
Solved,
i replaced the entries in the my_dynamic_calendar.xml file:

android.support.v7.widget.RecyclerView
android.support.v4.view.ViewPager

with

androidx.recyclerview.widget.RecyclerView
androidx.viewpager.widget.ViewPager

and it works

Thanks

sorry for stupid question, where are old and new files? directory? web address?
i found similar file "android-support-v7-recyclerview.jar" in my additional libs dir

and here the same
 

DonManfred

Expert
Licensed User
Longtime User
Follow the installationstructions carefully and it will work

 
Top