badoualy / datepicker-timeline Goto Github PK
View Code? Open in Web Editor NEWAn infinite scrolling timeline to pick a date
License: MIT License
An infinite scrolling timeline to pick a date
License: MIT License
Hello,
When I put the datepicker in an AlertDialog, the forecolor disappears, as follows:
Here's some code:
`
btn.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.CustomAlertDialog);
LayoutInflater inflater1 = getLayoutInflater();
View dlgWeights = inflater1.inflate(R.layout.weights_dialog,null);
builder.setTitle("Set Body Weight");
builder.setView(dlgWeights);
tvWeights = dlgWeights.findViewById(R.id.tvWeights);
tvWeights.setText(spnWeights.getSelectedItemPosition() == 0 ? getString(R.string.lbs) : getString(R.string.kilos));
npWeight = dlgWeights.findViewById(R.id.npWeight);
Log.i("ProfileDialog", "Launching DatePickerTimeline");
final DatePickerTimeline timeline = dlgWeights.findViewById(R.id.datePickerTimeLine);
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
timeline.setOnDateSelectedListener((year, month, day, index) -> {
Calendar date = Calendar.getInstance();
date.set(year, month, day);
refreshWeight(sdf.format(date.getTime()));
});
Calendar current = Calendar.getInstance();
timeline.setSelectedDate(current.get(Calendar.YEAR), current.get(Calendar.MONTH), current.get(Calendar.DATE));
refreshWeight(sdf.format(current.getTime()));
builder.setPositiveButton(getString(R.string.OK), (dialog, which) -> {
Calendar d = Calendar.getInstance();
d.set(timeline.getSelectedYear(), timeline.getSelectedMonth(), timeline.getSelectedDay(), 0, 0, 0);
((ExerciseActivity) getActivity()).exerciseViewModel.ensureWeight(npWeight.getValue(), (int) (d.getTimeInMillis() / 1000L));
refreshBodyWeight();
dialog.dismiss();
});
builder.setNegativeButton(getString(R.string.Cancel), (dialog, which) -> dialog.dismiss());
final AlertDialog dialog = builder.create();
dialog.show();
});`
R.layout.weights_dialog:
`
<com.github.badoualy.datepicker.DatePickerTimeline
android:id="@+id/datePickerTimeLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvWeights"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<com.michaelmuenzer.android.scrollablennumberpicker.ScrollableNumberPicker
android:id="@+id/npWeight"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
app:snp_scrollEnabled="true"
app:snp_updateInterval="5" />
</LinearLayout>
Thanks in advance for any assistance.
Hello,
in the sample app, I can see that the year can be displayed in the MonthView, jkust beneath. Checking the the library embedded in the sample code, I can see the following lines in MonthViewHolder private class:
void bind(int year, int month, boolean selected, boolean beforeSelection) {
this.year = year;
this.month = month;
String text = MONTHS[month].substring(0, 3).toUpperCase(Locale.US);
**if (yearDigitCount > 0) {
text += yearOnNewLine ? "\n" : " ";
text += year % (int) Math.pow(10, yearDigitCount);
}**
lbl.setText(text);
int color = selected ? colorSelected : beforeSelection ? colorBeforeSelection : defaultColor;
lbl.setTextColor(color);
indicator.setColor(color);
indicator.setCircleSizeDp(selected ? 12 : 5);
}
Where this same method lacks the part if(yearDigitCount > 0){} . This seems lost in 1.0.1. Was it removed on purpose? Or this the gradle link not updated?
EDIT. Ah well, I checked the commits, I guess this is not in the gradle release yet. I will try using the library directly in my code. Awesome job man! Keep it up :) Thanks!
@badoualy We can't change the typeface of the widget
hi love the library u created from the inspiration of the design.
There occasion when u don't want the user to pink up the date after a given date, for example not beyond today's date.
To cover max use cases. can v make the adapter to look if the developer has set last visible date. if not we can have the infinite scrollable date picker as it is right now
How to set specific dates instead of a range ?
setOnDateSelectedListener after initiation the timeline lib
im using this code, but the datepicker won't automatic scroll at selected date, how to fix it?
timeline.setSelectedDate(1, 3, 2018);
This lib would be awesome if there is an option to select multiple dates and date range. Is it possible by any means???
i wanna to change labels in different days but the application crash
mCalendarView.setDateLabelAdapter(new MonthView.DateLabelAdapter() {
@OverRide
public CharSequence getLabel(Calendar calendar, int index) {
if (calendar.get(Calendar.DATE) == 5) {
mCalendarView.getTimelineView().setLabelColor(getResources().getColor(R.color.red_50));
return "busy";
}else
return Integer.toString(calendar.get(Calendar.MONTH) + 1) + "/" +
(calendar.get(Calendar.YEAR) % 2000);
}
});
mCalendarView.getTimelineView().getAdapter().notifyDataSetChanged();
The alignment is not perfect, sometimes the offset is a bit off
How can I put a label below the date, but only at the date I want?
I tried to do it with the adapter but you need to check if the date is correct in each index and that is too much work.
When the activity gets killed in the background, and then resumes, the app crashes with the following stack trace:
java.lang.StringIndexOutOfBoundsException: length=2; regionStart=0; regionLength=3
at java.lang.String.substring(String.java:1931)
at com.github.badoualy.datepicker.MonthView$MonthViewHolder.bind(MonthView.java:307)
at com.github.badoualy.datepicker.MonthView$MonthAdapter.onBindViewHolder(MonthView.java:273)
at com.github.badoualy.datepicker.MonthView$MonthAdapter.onBindViewHolder(MonthView.java:256)
/*
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:618)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.support.v4.widget.NestedScrollView.onLayout(NestedScrollView.java:1670)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:132)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:869)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17523)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
*/
I guess this is related to the library. any ideas on how to solve this?
Suppose I want to fetch labels from server upon selection of date. And then reflect the fetched data as label. (Label means the text shown below date, which is supplied by DateLabelAdapter as per your sample).
How do I do it? How do I refresh labels with data fetched from server.
Hi,
I like your library,
I downloaded it to test and it's simple to use & pretty ;)
But you should improve your Readme with some pictures & sample code to have more downloads
val current = Calendar.getInstance()
timeLine.setFirstVisibleDate(2016, Calendar.JULY, 19)
timeLine.setLastVisibleDate(2020, Calendar.JULY, 19)
i am doing this, but when i pick by example the 2017/02/18 all the months after that date disappear
i am adding it from this way
<com.github.badoualy.datepicker.DatePickerTimeline
android:id="@+id/timeLine"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
/>
Hi.
Does anyone have a fix for this ?
https://github.com/badoualy/datepicker-timeline/blob/master/library/src/main/java/com/github/badoualy/datepicker/TimelineView.java#L268
Just switched to summer time (DST), and yeah. It does not work. It shows the day before.
Do I have to check if its summer time (DST) and then add an extra day ? Or is there a better way to do this ?
Hi!,
I have a problem with Class referenced in the layout file, com.github.badoualy.datepicker.DatePickerTimeline, was not found in the project or the libraries in Kotlin.
In build.gradle already is added implementation 'com.github.badoualy:datepicker-timeline:1.0.0' but still not working.
Any idea?
When I call setOnDateSelectedListener I get an error "Expresstion cannot be invoke as a function. The function invoke()
is not found"
My code:
datePicker.onDateSelectedListener(object: DatePickerTimeline.OnDateSelectedListener{
override fun onDateSelected(year: Int, month: Int, day: Int, index: Int) {
calendar.set(year, month, day)
viewModel.getDiaryByPriority(calendar, "objective")
}
})
ring, and bg color not changing
compile 'com.github.badoualy:datepicker-timeline:1.0.1'
or
compile 'com.github.badoualy:datepicker-timeline:c6dcd05737'
or
'a62c066'
Hi, this is a great library
I wanna use this library for Persian calendar , can you help me for support this issue? @badoualy
when adding first date to lib it started on it and not current date that i selected
i cant add to my project, the gradle return failed to resolve
For Release 1.0.0
When selecting date on timelineview or month monthview, selected month doesn't centre on the month view. Same issue when scrolling timelineview, the month view starts to scroll, but the current selected month is not visible.
Understanding is that, if the selected date is visible on the timelineview, and we start to scroll left or right on the timeline the month view will also scroll in the same direction.
this could be the ultimate calendar library for android if supports Full calendar view, with collapse feature.
cheers!
I liked your library as I am using it in my project. I have some queries regarding some functionality.
Recently, my app has reported a significant number of crashes that was caused by StringIndexOutOfBoundsException
from within this library's MonthView
.
The crash logs have led me here:
String text = MONTHS[month].substring(0, 3).toUpperCase(Locale.US);
It's an early guess, but it seems like there is a possibility for MONTHS[month]
to be less than 3 in length. Hence the error.
How to change date pragmatically on buttons click next and previous?
Even if I set on layout a different color, sometimes it will popup back with the defaults. I think I set the correct attrs:
app:mti_bgLblDateSelectedColor="..." app:mti_lblDateColor="..." app:mti_ringLblDateSelectedColor="..." app:mti_tabBeforeSelectionColor="..." app:mti_tabSelectedColor="..."
Next days if I have time I'll look into src code to find the bug, if you spot it before me please answer this issue.
ty
i need show today's date visible while add date range setFirstVisibleDate and setLastVisibleDate
Can't use library via gradle implementation.
Hi! First of all, I want to say thank you for taking the time to develop and maintain this library. Your implementation of the calendar is, without a doubt, unique and pleasant to look at.
I've been developing an app that shall have DayNight theme as one of its features. Using your Datepicker Timeline, this is what I see whenever my app get into the Night (Dark) theme:
Please note that the rest of my app has been properly adapted to use dark backgrounds (as can be seen from the window and CardView
background in the screencap above).
Looking into the sources, I can tell that it's currently not possible to change the background to another color. Could you please provide a way to do so?
Thanks in advance!
Please list that in the readme.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.