MaterialDateTimePicker

DonManfred

Expert
Licensed User
Longtime User
And for you then too:
I dont know what the problem is. It is working fine here.
 

TheJinJ

Active Member
Licensed User
Longtime User
Seems the month is not correct in v1.7 -

B4X:
Sub dateP_onDateSet(year As Int, monthOfYear As Int, dayOfMonth As Int)
   
    Log($"onDateSet(${year},${monthOfYear},${dayOfMonth})"$)
    Dim d As Long
    DateTime.DateFormat = "dd.mm.yyyy"
    d = DateTime.DateParse(dayOfMonth&"."&monthOfYear&"."&year)

logs...

B4X:
onDateSet(2017,0,12)

Can just add 1 to the result if needed and I imagine an easy fix?
 

corwin42

Expert
Licensed User
Longtime User
Great library.

I just tested it as a Date- and TimePicker for the upcoming Preferences library. Works great:
Screenshot_20170120-081019.png

What use has the "tag" parameter in the show() method? Can I access it anywhere?

BTW: It needs the DesignSupport library to be added to your project. Otherwise you will get resource errors.
 
Last edited:

corwin42

Expert
Licensed User
Longtime User
I can send you the source if you are interested (want to include it in your new lib)

No, it is not needed to include it in the preference lib. You will be able to use any available picker in the new preferences library. This is the whole code needed for the TimePicker:

B4X:
Sub PrefView_Ready (PrefsView As PreferenceView)

    [...]
    TimePreference = PrefsView.AddSimplePreference("Time", "time1", "Custom TimePicker", DateTime.Time(PrefManager.GetLong2("time1", DateTime.Now)), DateTime.Now)
    [....]
End Sub

Sub Time_PreferenceClicked (Preference As Preference) As Boolean
    Dim TimePicker As TimePickerDialog
    Dim currentTime As Long
   
    currentTime = PrefManager.GetLong2("time1", DateTime.Now)
    TimePicker.Initialize("TimePicker", DateTime.GetHour(currentTime), DateTime.GetMinute(currentTime), True)
    TimePicker.show("1")
   
    Return True
End Sub

Sub TimePicker_onTimeSet(hour As Int, minute As Int, second As Int)
    Dim selectedTime As Long
   
    selectedTime = DateUtils.SetDateAndTime(DateTime.GetYear(DateTime.Now), DateTime.GetMonth(DateTime.Now)+1, DateTime.GetDayOfMonth(DateTime.Now), hour, minute, second)
    PrefManager.SetLong("time1", selectedTime)
    TimePreference.Summary = DateTime.Time(selectedTime)
End Sub

The preference activity is just a normal activity. You are totally free what to do there. But this should be discussed in another thread.
 

AscySoft

Active Member
Licensed User
Longtime User
Big thanks for this library Don.
I have a question. I don't need a timepicker in my app, so is there a way to "remove it" and just to keep only date picker? (I am trying to create a small apk...is a larger project)
 

SandroB4A

Member
Licensed User
Longtime User
Hi all,
is there a way to visualize only minutes and seconds in the TimePicker?
(I tried to simulate it with hours varying from 0 to 59 without success.)
tks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
so is there a way to "remove it" and just to keep only date picker?
Only with creating a new library. I´ll not split it up.
You can try to remove unneeded classes in the library jar.

I suggest to learn java and do your own wrap which you then can change like you wish.
 

DonManfred

Expert
Licensed User
Longtime User
It seems that "MinDate" property in your example is not working well!

It is working fine for me.
I setup the min date to be 1st of Jan 2017.

I´m not able to scroll to Dec 2016.... Even the starting-date will not work. Min date is january.

B4X:
    date.Initialize("Date",2016,12,3)
    Dim cal As Calendar
    cal.Initialize("dd.MM.yyyy",cal.GERMAN,"01.01.2017")
    date.MinDate = cal
 

AscySoft

Active Member
Licensed User
Longtime User
I´ll not split it up.
Nor was it my intention to ask of you to do this. I was asking for advice.
You can try to remove unneeded classes in the library jar.
Do you mean i could unzip and delete time folder then repack? (ie aar file>>\MaterialDateTimePicker\classes\com\wdullaer\materialdatetimepicker\time\)
It is working fine for me.
Sorry, I was too tired, it is working as expected; forgot to delete.
 

AscySoft

Active Member
Licensed User
Longtime User
I did manage to create a new aar file, without Time class, I removed some time related resource files, a stripped/clean xml and jar files. My package is 25% smaller in size, and is working as expected. I will not post it here because this is after all a @DonManfred's work and could create confusion as its name is still DateTimePicker. Thanks Don for this resource.
 
Last edited:

AscySoft

Active Member
Licensed User
Longtime User
You can post the updated lib here in the thread for any one who want to have the same.
OK, but fore anyone else, this is a scaled down version that does not contain the object TIME and is only good if you do not need to set a TIME value... so try not to overwrite something good :))
 

Attachments

  • MaterialDatePicker1.7.zip
    224.4 KB · Views: 457

Jack Cole

Well-Known Member
Licensed User
Longtime User
Regarding the problem with missing resources, this was resolved for me by changing the IDE paths to use the android.jar under API level 23 instead of 21.

Additionally, this line was needed as suggested above by TheJinJ

B4X:
#AdditionalJar: com.android.support:design
 
Top