Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Update support lib
Browse files Browse the repository at this point in the history
Update README with doc + gif
  • Loading branch information
badoualy committed Jul 10, 2017
1 parent c6dcd05 commit bc62b59
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 15 deletions.
Binary file added ART/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

> ### Designed by the awesome https://dribbble.com/LeslyPyram :)
<img src="https://github.com/badoualy/datepicker-timeline/blob/master/ART/demo.gif" width="300">

Setup
----------------

Expand All @@ -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
<com.github.badoualy.datepicker.DatePickerTimeline
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
```

### 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
----------------
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName '1.0'
}
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId "com.github.badoualy.datepicker.sample"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName '1.0.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bc62b59

Please sign in to comment.