B4A Library CoupleCalendar

This is a wrap for this Github project.

CoupleCalendar
<link>...|https://www.b4x.com</link>
Author: yuyakaido (Github)/DonManfred (Wrapper)
Version: 0.1
  • CCEvent
    • Functions:
      • Initialize (EventName As String)
      • IsInitialized As Boolean
      • setDurationType
    • Properties:
      • DurationType As com.yuyakaido.android.couplescalendar.model.DurationType [read only]
      • EndAt As Long
      • EndAtDateTime As Long [read only]
      • EventColor As Int
      • EventDays As java.util.List [read only]
      • EventType As com.yuyakaido.android.couplescalendar.model.EventType
      • LinePosition As com.yuyakaido.android.couplescalendar.model.LinePosition
      • RecurrenceRule As String
      • StartAt As java.util.Date
  • CouplesCalendarView
    • Events:
      • onDateClick (date As Long)
      • onMonthChange (date As Long)
    • Functions:
      • BringToFront
      • DesignerCreateView (base As Panel, lw As Label, props As Map)
      • Initialize (EventName As String)
      • Invalidate
      • Invalidate2 (arg0 As android.graphics.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 android.graphics.Bitmap) As BitmapDrawable
      • 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 android.graphics.drawable.Drawable
      • Color As Int [write only]
      • Enabled As Boolean
      • ETNormal As com.yuyakaido.android.couplescalendar.model.EventType [read only]
      • ETRecurring As com.yuyakaido.android.couplescalendar.model.EventType [read only]
      • ETTransient As com.yuyakaido.android.couplescalendar.model.EventType [read only]
      • Events As List [write only]
      • Height As Int
      • Left As Int
      • LinePositionLower As com.yuyakaido.android.couplescalendar.model.LinePosition [read only]
      • LinePositionUpper As com.yuyakaido.android.couplescalendar.model.LinePosition [read only]
      • Padding As Int()
      • Parent As Object [read only]
      • Tag As Object
      • Theme As com.yuyakaido.android.couplescalendar.model.Theme
      • ThemeBlue As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeGREEN As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeLIGHT_BLUE As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeNAVY_BLUE As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeORANGE As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemePINK As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemePURPLE As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeRED As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeTIFFANY_BLUE As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • ThemeYELLOW As com.yuyakaido.android.couplescalendar.model.Theme [read only]
      • Top As Int
      • Visible As Boolean
      • Width As Int

B4X:
    Dim evList As List
    evList.Initialize

    Dim event As CCEvent
    event.Initialize("")
    Dim startAt As Long = DateTime.DateTimeParse("01/12/2019","08:00:00")
    Dim endAt As Long = DateTime.DateTimeParse("01/14/2019","08:30:00")
    event.setDurationType
    event.StartAt = startAt
    event.EndAt = endAt
    event.EventColor = Colors.Blue
    event.LinePosition = ccv1.LinePositionUpper
    evList.Add(event)

    Dim event As CCEvent
    event.Initialize("")
    Dim startAt As Long = DateTime.DateTimeParse("02/01/2019","00:00:00")
    Dim endAt As Long = DateTime.DateTimeParse("02/01/2019","23:59:59")
    event.setDurationType
    event.StartAt = startAt
    event.EndAt = endAt
    event.EventColor = Colors.Black
    event.LinePosition = ccv1.LinePositionUpper
    evList.Add(event)

    Dim event As CCEvent
    event.Initialize("")
    Dim startAt As Long = DateTime.DateTimeParse("02/02/2019","00:00:00")
    Dim endAt As Long = DateTime.DateTimeParse("02/02/2019","22:00:00")
    event.setDurationType
    event.StartAt = startAt
    event.EndAt = endAt
    event.EventColor = Colors.Magenta
    event.LinePosition = ccv1.LinePositionUpper
    evList.Add(event)

    Dim event As CCEvent
    event.Initialize("")
    Dim startAt As Long = DateTime.DateTimeParse("02/18/2019","00:00:00")
    Dim endAt As Long = DateTime.DateTimeParse("02/22/2019","00:00:00")
    event.setDurationType
    event.StartAt = startAt
    event.EndAt = endAt
    event.EventColor = Colors.Red
    event.LinePosition = ccv1.LinePositionLower
    evList.Add(event)

    ccv1.Events = evList
    ccv1.Theme = ccv1.ThemeGREEN

results in
WhatsApp Image 2019-02-02 at 08.19.15.jpeg

Notes:
- To get it working with Android X you need to add
B4X:
#AdditionalJar: androidx.legacy:legacy-support-v4
and use the res-Folder from the zip res.Couplescalendar-AndroidX.zip
 

Attachments

  • CoupleCalendarEx.zip
    8.3 KB · Views: 573
  • CoupleCalendarV0.1.zip
    82.2 KB · Views: 571
  • res.Couplescalendar.zip
    16.2 KB · Views: 545
  • res.Couplescalendar-AndroidX.zip
    16.2 KB · Views: 417
Last edited:

Harris

Expert
Licensed User
Longtime User
Cool...
I thought from the name - it was a calendar - for couples (like man and wife, girlfriend, etc...).
It would sync their engagements, share each others calendar... Silly me.
What's in a name?
 

Harris

Expert
Licensed User
Longtime User
I guess couples here are more than one event on a day (visible). maybe... Dont know ;-)
and you claim you can't readily understand / interpret english...
Could easily fool me, brother... Can't imagine what my statement would translate into your language.
You guys are amazing - compared to us low lifes on the North American continent.
Peace.
 

DonManfred

Expert
Licensed User
Longtime User
You guys are amazing - compared to us low lifes on the North American continent.
Peace.
Did i bother you in some kind? Or did i misinterpret this now?

If i did bother you in some way; it was not my intention.



I usually do not give much interpretion in a name of a java class. I just take it

public class CouplesCalendarView extends LinearLayout
so i write a CouplesCalendarViewwrapper which is the wrap for the original.
And in this case, the libraryname is just taken from the githubs project main class
package com.yuyakaido.android.couplescalendar
 

Harris

Expert
Licensed User
Longtime User
Did i bother you in some kind? Or did i misinterpret this now?

I said BROTHER- not BOTHER. So similar spelling - yet different meanings entirely (the problem with english).

Brother is what we say for: my close friend - part of my immediate family - someone who is near and dear to me.
It is often used as a slang term we use (here) to imply love and respect among men.
I think it may have originated from the African/American culture here in North America (which many of us have adopted).

Women may use a different term to imply the same thing.

Sorry for hi-jacking your thread here, I couldn't resist.
Oh, the language barrier... With all of the translate technology - it still fails from time to time...

Hey, we learn something new everyday (hopefully).
 

DonManfred

Expert
Licensed User
Longtime User
I said BROTHER
and i did understand it correctly. I just was irritate about the

You guys are amazing - compared to us low lifes on the North American continent.
Peace.
i interpreted it to be something that i said the wrong somehow.
Sorry, i guess this is the result of being english not my native language and sometimes i do not understand correctly or wrong.

Peace :)
 

Harris

Expert
Licensed User
Longtime User
You say I know nothing Mr. Fawlty - but I learn - I learn!!!!!

My tag line... We all learn... hopefully everyday.
 

Pencil3

Member
Licensed User
Tried the example (CoupleCalendarEx.zip) and recieve the below error:

ERROR: resource directory '..\res.couplescalendar' does not exist
 

Adson Figueiredo Lima

New Member
Licensed User
Good night,
This error is occurring with the date 10/20/2019.



java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: Illegal instant due to time zone offset transition: 2019-10-20T03:00:00.000
at org.joda.time.chrono.ZonedChronology.localToUTC(ZonedChronology.java:143)
at org.joda.time.chrono.ZonedChronology.getDateTimeMillis(ZonedChronology.java:119)
at org.joda.time.chrono.AssembledChronology.getDateTimeMillis(AssembledChronology.java:133)
at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:254)
at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:195)
at org.joda.time.DateTime.<init>(DateTime.java:460)
at com.yuyakaido.android.couplescalendar.util.CalendarUtils.getMidnight(CalendarUtils.java:46)
at com.yuyakaido.android.couplescalendar.model.InternalEvent.getEventDays(InternalEvent.java:118)
at com.yuyakaido.android.couplescalendar.util.EventCache.createCacheIn(EventCache.java:84)
at com.yuyakaido.android.couplescalendar.util.EventCache.createDefaultCache(EventCache.java:110)
at com.yuyakaido.android.couplescalendar.util.EventCache.init(EventCache.java:45)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView$2.doInBackground(CouplesCalendarView.java:154)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView$2.doInBackground(CouplesCalendarView.java:151)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more
** Activity (app) Pause, UserClosed = true **
 

Pencil3

Member
Licensed User
I am running into the below error with AndroidX and B4A 9.50 when trying to use the CoupleCalendarEx.zip. The library is jetified and I have the following files in my external libs folder:
CoupleCalendar.androidx
CoupleCalendar
CoupleCalendar.xml

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 36 (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 b4a.example.calendar.main._activity_create(main.java:387)
at java.lang.reflect.Method.invoke(Native Method)
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.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.calendar.main.afterFirstLayout(main.java:104)
at b4a.example.calendar.main.access$000(main.java:17)
at b4a.example.calendar.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 18 more
Caused by: android.view.InflateException: Binary XML file line #18 in b4a.example.calendar:layout/view_couples_calendar: Binary XML file line #18 in b4a.example.calendar:layout/view_couples_calendar: Error inflating class android.support.v4.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #18 in b4a.example.calendar:layout/view_couples_calendar: Error inflating class android.support.v4.view.ViewPager
Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at android.view.LayoutInflater.createView(LayoutInflater.java:815)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at android.view.View.inflate(View.java:25757)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView.initialize(CouplesCalendarView.java:72)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView.<init>(CouplesCalendarView.java:68)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView.<init>(CouplesCalendarView.java:63)
at com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView.<init>(CouplesCalendarView.java:59)
at de.donmanfred.CouplesCalendarViewwrapper._initialize(CouplesCalendarViewwrapper.java:74)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.calendar.main._activity_create(main.java:387)
at java.lang.reflect.Method.invoke(Native Method)
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.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.calendar.main.afterFirstLayout(main
Message longer than Log limit (4000). Message was truncated.
** Activity (main) Resume **
 

Johan Schoeman

Expert
Licensed User
Longtime User
If you change the xml code in view_couples_calendar.xml to.....

B4X:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/cc_while">

    <GridView
        android:id="@+id/view_couples_calendar_day_of_week_grid_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:listSelector="@android:color/transparent"
        android:numColumns="7">
    </GridView>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/view_couples_calendar_view_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </androidx.viewpager.widget.ViewPager>

</LinearLayout>

.....then it should work. Look for view_couples_calendar.xml in the res.Couplescalendar/layout folder of @DonManfred's B4A sample project.

I have tested in with targetSDK = 28 on an Android 9 (Samsung S10) device and it is working just fine after I have made the above changes to the xml file and ran the Jetifier. Using B4A v9.50
 

Attachments

  • view_couples_calendar.xml
    805 bytes · Views: 318
  • joda-time-2.1.jar.zip
    470.6 KB · Views: 371
Last edited:

Pencil3

Member
Licensed User
I can confirm it works for me also. Thank you so much for posting a solution!

If you change the xml code in view_couples_calendar.xml to.....

B4X:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/cc_while">

    <GridView
        android:id="@+id/view_couples_calendar_day_of_week_grid_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:listSelector="@android:color/transparent"
        android:numColumns="7">
    </GridView>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/view_couples_calendar_view_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </androidx.viewpager.widget.ViewPager>

</LinearLayout>

.....then it should work. Look for view_couples_calendar.xml in the res.Couplescalendar/layout folder of @DonManfred's B4A sample project.

I have tested in with targetSDK = 28 on an Android 9 (Samsung S10) device and it is working just fine after I have made the above changes to the xml file and ran the Jetifier. Using B4A v9.50
 

Johan Schoeman

Expert
Licensed User
Longtime User
I think it is more relevant to ask here then to start a new thread: I have installed B4A 9.5, downloaded the files, but I get that same error. I wonder what else to check?

Is your SDK Manager up to date?
Did you run the Jetifier and cleaned your project after you ran the Jetifier?
 

DonManfred

Expert
Licensed User
Longtime User
My error is the same error as posted by Pencil3 on november 10 (post #14) except I don't run AndroidX and I tried the XML that Johan posted. I did not have time yet to carry out his suggestions.
if you are not using AndroidX then you should NOT follow Johans Answer. Instead use the resources from #1

Start a new Thread, post the not working project and the full error.
 

Gktech

Member
Licensed User
I'm trying to run a library with the downloaded example, but I'm getting the following error:

B4X:
Logger connected to:  motorola Moto E (4)
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 36 (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 b4a.example.calendar.main._activity_create(main.java:387)
    at java.lang.reflect.Method.invoke(Native Method)
    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.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.calendar.main.afterFirstLayout(main.java:104)
    at b4a.example.calendar.main.access$000(main.java:17)
    at b4a.example.calendar.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6339)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 18 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/yuyakaido/android/couplescalendar/ui/CouplesCalendarView;
    at de.donmanfred.CouplesCalendarViewwrapper._initialize(CouplesCalendarViewwrapper.java:74)
    ... 21 more
Caused by: java.lang.ClassNotFoundException: com.yuyakaido.android.couplescalendar.ui.CouplesCalendarView
    at java.lang.VMClassLoader.findLoadedClass(Native Method)
    at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 22 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager$OnPageChangeListener;
    ... 22 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager$OnPageChangeListener" on path: DexPathList[[zip file "/data/app/b4a.example.calendar-1/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example.calendar-1/lib/arm, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 22 more
** Activity (main) Resume **

Would you help me?
 
Top