Android Question AS DatePickerTimeline Problem with MinDate option

fbritop

Active Member
Licensed User
Longtime User
I´ve been trying this new mode
Manual with CreateDatePicker.

I´m not sure I tried to dig in the code but I cound not figure out the logic.
ListMode is Paging
CreateMode is Manual
Lib Version: 1.19

Also is it possible to declare BodyColor and CurrentDateColor as part of then ASDatePickerTimeline_BodyProperties structure? I always manage in an internal way the either Dark or Light themes.

My code is:

B4X:
                pnl.LoadLayout("xDateTimeline")
                xDateTimeline.WeekNameShort=xDateTimeline.CreateASDatePickerTimeline_WeekNameShort("Lun", "Mar", "Mie", "Jue", "Vie", "Sáb", "Dom")
                xDateTimeline.MonthNameShort=xDateTimeline.CreateASDatePickerTimeline_MonthNameShort("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic")
                xDateTimeline.BodyProperties.DateTextColor=col.clrBlack
                xDateTimeline.BodyProperties.MonthTextColor=col.clrGray2
                xDateTimeline.BodyProperties.WeekDayTextColor=col.clrGray2
                'xDateTimeline.
                xDateTimeline.BodyProperties.WeekDayTextFont=xc.b4xFontNormal(xc.subTitleSize)
                xDateTimeline.BodyProperties.MonthTextFont=xc.b4xFontNormal(xc.subTitleSize)
                xDateTimeline.BodyProperties.DateTextFont=xc.b4xFontBlack(xc.TitleSize*1.2)
                xDateTimeline.SelectedDayProperties.Color=col.btnCalPickerSelected
               
                If startDate>0 Then
                    xDateTimeline.startDate=startDate
                Else
                    xDateTimeline.StartDate=xc.dtTodayTicks
                End If
                If maxDate>0 Then
                    xDateTimeline.MaxDate=maxDate
                    Log("maxDate:" & DateTime.Date(maxDate))
                End If
                If minDate>0 Then
                    xDateTimeline.MinDate=minDate '<------------- If I comment this there is no exception thrown
                    Log("minDate:" & DateTime.Date(minDate))
                End If
                xDateTimeline.CreateDatePicker

And it throws the following error

B4X:
Panel size is unknown. Layout may not be loaded correctly.
maxDate:22-11-2024
minDate:07-11-2024
xTimePicker_SelectedHourChanged
btnAction
btnAction
btnToday
setNavBarCustom
Error occurred on line: 402 (AS_DatePickerTimeline)
java.lang.IndexOutOfBoundsException: Index -4 out of bounds for length 16
    at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
    at java.util.Objects.checkIndex(Objects.java:359)
    at java.util.ArrayList.get(ArrayList.java:434)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
    at b4a.example3.customlistview._getrawlistitem(customlistview.java:447)
    at cl.abreme.android.as_datepickertimeline$ResumableSub_AddWeeks.resume(as_datepickertimeline.java:1595)
    at cl.abreme.android.as_datepickertimeline._addweeks(as_datepickertimeline.java:1096)
    at cl.abreme.android.as_datepickertimeline._createdatepicker(as_datepickertimeline.java:451)
    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:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:224)
    at android.os.Looper.loop(Looper.java:318)
    at android.app.ActivityThread.main(ActivityThread.java:8765)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
(Exception) java.lang.Exception:  java.lang.IndexOutOfBoundsException: Index -4 out of bounds for length 16

Thanks
FBP
 

Alexander Stolte

Expert
Licensed User
Longtime User
And it throws the following error
I'm sorry, but I can't recreate the error.

Also is it possible to declare BodyColor and CurrentDateColor as part of then ASDatePickerTimeline_BodyProperties structure? I always manage in an internal way the either Dark or Light themes.
I see the problem. In the next update, the view will get the theming feature that most of my views will get this year.
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
I'm sorry, but I can't recreate the error.


I see the problem. In the next update, the view will get the theming feature that most of my views will get this year.
I cannot recreate in a small project. As the view I created uses 3 of your libs all together: ASDraggableBottomCard, AS_DatePickerTimeline and AS_TimerPicker


But I have narrowed the problem and create a small fix arround line #390, I´m not sure when or under what conditions, but StartIndex value gets at -4, so I put out a condition to not enter if there is a negative value

B4X:
        #If B4I
        Sleep(250)
        Log(StartIndex)
        If xclv_Main.Size > 0 And StartIndex>=0 Then
            xclv_Main.JumpToItem(StartIndex)
        End If
            #Else
        If StartIndex>=0 Then xclv_Main.sv.ScrollViewOffsetX = xclv_Main.GetRawListItem(StartIndex).Offset
        
        #End If
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
looks really nice!

But I have narrowed the problem and create a small fix arround line #390, I´m not sure when or under what conditions, but StartIndex value gets at -4, so I put out a condition to not enter if there is a negative value
I have added a safeguard in the next update so that the StartIndex cannot be less than 0. Thanks
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
looks really nice!


I have added a safeguard in the next update so that the StartIndex cannot be less than 0. Thanks
Great
I will post you another bug (I think) in a new thread regarding AS_TimerPicker, I could not understand the code to represent the behaivior
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Update V1.20 is released
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…