diff --git a/ART/demo.gif b/ART/demo.gif new file mode 100644 index 0000000..776cc9a Binary files /dev/null and b/ART/demo.gif differ diff --git a/README.md b/README.md index 9212107..a996bc2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ > ### Designed by the awesome https://dribbble.com/LeslyPyram :) + + Setup ---------------- @@ -25,6 +27,49 @@ Now go do some awesome stuff! Usage ---------------- +**Warning**: Note that the month value is always between 0 and 11 due to the use of the Calendar API. + +### Add the view to your xml +```xml + +``` + +### Setup the first visible date via the code +```java +timeline.setFirstVisibleDate(2016, Calendar.JULY, 19); +``` + +### You can also set the limit date +```java +timeline.setLastVisibleDate(2020, Calendar.JULY, 19); +``` + +### Supply a label adapter to add a label below each date if needed +```java +timeline.setDateLabelAdapter(new MonthView.DateLabelAdapter() { + @Override + public CharSequence getLabel(Calendar calendar, int index) { + return Integer.toString(calendar.get(Calendar.MONTH) + 1) + "/" + (calendar.get(Calendar.YEAR) % 2000); + } +}); +``` + +### Set a listener to be notified when the user select a date +```java +timeline.setOnDateSelectedListener(new DatePickerTimeline.OnDateSelectedListener() { + @Override + public void onDateSelected(int year, int month, int day, int index) { + + } +}); +``` + +### You can the the date manually +```java +timeline.setSelectedDate(2017, Calendar.JULY, 19); +``` Licence ---------------- diff --git a/build.gradle b/build.gradle index 4bd033a..4e4666f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ buildscript { repositories { jcenter() - mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' @@ -12,18 +11,19 @@ buildscript { allprojects { repositories { jcenter() - mavenCentral() - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://jitpack.io" } + maven { + url "https://maven.google.com" + } } } // To avoid manually setting the same values in all Android modules, set the value on the root // project and then reference this from the modules ext { - compileSdkVersion = 25 - buildToolsVersion = "25.0.3" - supportLibVersion = "25.3.1" + compileSdkVersion = 26 + buildToolsVersion = "26.0.0" + supportLibVersion = "26.0.0-beta2" } task wrapper(type: Wrapper) { diff --git a/gradle.properties b/gradle.properties index 7e9bd25..9fa2b39 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Maven stuff GROUP=com.github.badoualy -VERSION_CODE=100 -VERSION_NAME=1.0.0 +VERSION_CODE=101 +VERSION_NAME=1.0.1 POM_NAME=DatePicker Timeline POM_ARTIFACT_ID=datepicker diff --git a/library/build.gradle b/library/build.gradle index c8bda0d..9bd801c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName '1.0' } diff --git a/sample/build.gradle b/sample/build.gradle index 269b668..2f82b24 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,7 +9,7 @@ android { defaultConfig { applicationId "com.github.badoualy.datepicker.sample" minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName '1.0.0' } diff --git a/sample/src/main/java/com/github/badoualy/datepicker/sample/MainActivity.java b/sample/src/main/java/com/github/badoualy/datepicker/sample/MainActivity.java index d5aac86..73189e1 100644 --- a/sample/src/main/java/com/github/badoualy/datepicker/sample/MainActivity.java +++ b/sample/src/main/java/com/github/badoualy/datepicker/sample/MainActivity.java @@ -17,15 +17,20 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); - DatePickerTimeline timeline = (DatePickerTimeline) findViewById(R.id.timeline); - final MonthView.DateLabelAdapter adapter = new MonthView.DateLabelAdapter() { - + DatePickerTimeline timeline = findViewById(R.id.timeline); + timeline.setDateLabelAdapter(new MonthView.DateLabelAdapter() { @Override public CharSequence getLabel(Calendar calendar, int index) { return Integer.toString(calendar.get(Calendar.MONTH) + 1) + "/" + (calendar.get(Calendar.YEAR) % 2000); } - }; - timeline.setDateLabelAdapter(adapter); + }); + + timeline.setOnDateSelectedListener(new DatePickerTimeline.OnDateSelectedListener() { + @Override + public void onDateSelected(int year, int month, int day, int index) { + + } + }); timeline.setLastVisibleDate(2020, Calendar.JULY, 19); //timeline.setFirstVisibleDate(2016, Calendar.JULY, 19);