Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.maycon1038:example-range-datepicker-android:1.5'
}
dependencies {
implementation("com.github.maycon1038:example-range-datepicker-android:1.5")
}
<dependency>
<groupId>com.github.maycon1038</groupId>
<artifactId>example-range-datepicker-android</artifactId>
<version>1.5</version>
</dependency>
libraryDependencies += "com.github.maycon1038" % "example-range-datepicker-android" % "1.5"
:dependencies [[com.github.maycon1038/example-range-datepicker-android "1.5"]]
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.maycon1038:example-Range-DatePicker-Android:1.2'
}
implement DateRangePickerFragment.OnDateRangeSelectedListener in your MainActivity
in your onCreate instance DateRangePickerFragment
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DateRangePickerFragment rangePickerFragment = new DateRangePickerFragment();
rangePickerFragment.initialize(MainActivity.this,true);
//optional,set names for tabHost
rangePickerFragment.setNameTabHost("Data Início", "Data Fim");
//optional,to display the selected dates in the RangeDatePicker
rangePickerFragment.showPerido(true);
//optional, max dates
rangePickerFragment.setMaxDate(cd.getTime(), new Date());
rangePickerFragment.show(getSupportFragmentManager(), "MainActivity");
}
@Override
public void onDateRangeSelected(int startDay, int startMonth, int startYear, int endDay, int endMonth, int endYear) {
//work your method here
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault());
Calendar c = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c.set(startYear,startMonth,startDay);
c2.set(endYear, endMonth,endDay);
txt_inform.setText(df.format(c.getTime()) + "\n");
txt_inform.append( df.format(c2.getTime());
}