Skip to content

Commit

Permalink
Merge branch 'feature'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiran.gyawali committed Jul 17, 2019
2 parents b75946a + d9f14cd commit e4e105d
Show file tree
Hide file tree
Showing 18 changed files with 687 additions and 307 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.idea/
.DS_Store
/build
/captures
/.idea/caches/build_file_checksums.ser
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
### Contributor
`Jeffrey Jongko`

<p align="center">
<img width="300" height="550" src="https://raw.githubusercontent.com/keyrunHORNET/date_picker_converter/master/Screenshot_2018-06-04.png">
</p>
Date Picker | Calendar
---- | ----
![Date Picker](https://raw.githubusercontent.com/keyrunHORNET/date_picker_converter/master/Screenshot_2018-06-04.png) | ![Calendar](https://raw.githubusercontent.com/keyrunHORNET/date_picker_converter/master/calendar.png)

### demo (old version)
https://play.google.com/store/apps/details?id=com.hornet.nepalidateconverter
Expand Down Expand Up @@ -44,6 +44,25 @@ https://play.google.com/store/apps/details?id=com.hornet.nepalidateconverter
```
You may also add the library as an Android Library to your project. All the library files live in ```library```.

## Using Calendar
include the calendar in your desired layout
```xml
<com.hornet.dateconverter.CalendarView.Calendar
android:id="@+id/calendar"
android:layout_width="wrap_content"
android:layout_height="300dp" />
```
In order to receive the date set in the picker, you will need to implement the `CalendarView.Calendar.OnDateSetListener` interface. This will be a the `Activity` or `Fragment` that creates the calendar in their respective layout. Then hook up the interface with calendar in your layout.

```java
calendar.setOnDateSetListener(this);

@Override
public void onDateClick(View calendar, int year, int month, int day) {
Toast.makeText(this, "year :: " + year + " month :: " + (month + 1) + " day :: " + day, Toast.LENGTH_SHORT).show();
}

```
## Using Date Picker / Time Picker

### Implement an `OnDateSetListener` / `OnTimeSetListener`
Expand Down
Binary file modified Screenshot_2018-06-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ android {
versionCode 2
versionName "2.0"
}
lintOptions{
lintOptions {
checkReleaseBuilds false
}

dataBinding {
enabled true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation project(':library')
implementation 'com.android.support:appcompat-v7:28.0.0'
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".CalendarActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -17,4 +18,4 @@
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.hornet.nepalidateconverter;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.hornet.dateconverter.CalendarView.Calendar;
import com.hornet.dateconverter.DateConverter;
import com.hornet.dateconverter.Model;

import java.util.ArrayList;
import java.util.List;

public class CalendarActivity extends AppCompatActivity implements com.hornet.dateconverter.CalendarView.Calendar.OnDateSetListener {
Calendar mCalendar;
DateConverter dateConverter;
TextView textOutput;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calendar);
dateConverter = new DateConverter();
mCalendar = findViewById(R.id.calendar);
textOutput = findViewById(R.id.textOutput);
mCalendar.setOnDateSetListener(this);
mCalendar.setHighlightedDays(DateConverter.getAllSaturdays());
setTitle("Nepali Calendar");
}

@SuppressLint("SetTextI18n")
@Override
public void onDateClick(View calendar, int year, int month, int day) {
textOutput.setText("year :: " + year + " month :: " + (month + 1) + " day :: " + day);
}

/**
* get List of sample model of date
*
* @return ArrayList<Model>
*/
public List<Model> getSampleModelList() {
List<Model> myList = new ArrayList<>();
for (int i = 2; i < 15; i++) {
myList.add(new Model(dateConverter.getTodayNepaliDate().getYear(), dateConverter.getTodayNepaliDate().getMonth(), (i + 2)));
}
return myList;
}

}
Loading

0 comments on commit e4e105d

Please sign in to comment.