Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events, Badges, Scroll Direction #194

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ android {
minifyEnabled false
}
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}

apply from: 'gradle-mvn-push.gradle'
apply from: 'gradle-mvn-push.gradle'
5 changes: 5 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@

<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

<application />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.wdullaer.materialdatetimepicker.date;

import android.os.Parcel;
import android.os.Parcelable;

public class Badge implements Parcelable {
public static final int TOP_RIGHT = 1;
public static final int TOP_LEFT = 2;
public static final int BOTTOM_RIGHT = 3;
public static final int BOTTOM_LEFT = 4;

private int location = TOP_LEFT;
private int color = -1;
private int displayInt = 0;

public Badge(int displayInt){
this.displayInt = displayInt;
}

public int getLocation() {
return location;
}

public void setLocation(int location) {
this.location = location;
}

public int getColor() {
return color;
}

public void setColor(int color) {
this.color = color;
}

public int getDisplayInt() {
return displayInt;
}

public void setDisplayInt(int displayInt) {
this.displayInt = displayInt;
}

//parcelling part
public Badge(Parcel in){
location = in.readInt();
color = in.readInt();
displayInt = in.readInt();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(location);
dest.writeInt(color);
dest.writeInt(displayInt);
}

@Override
public int describeContents() {
return 0;
}

public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public Badge createFromParcel(Parcel in) {
return new Badge(in);
}

public Badge[] newArray(int size) {
return new Badge[size];
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.wdullaer.materialdatetimepicker.date;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.Calendar;

public class CalendarwBadge extends MonthAdapter.CalendarDay implements Parcelable{
private ArrayList<Badge> badgeArrayList;

public CalendarwBadge() {super();}

public CalendarwBadge(long timeInMillis) {super(timeInMillis);}

public CalendarwBadge(Calendar calendar) {super(calendar);}

public CalendarwBadge(int year, int month, int day) {
super(year, month, day);
}

public ArrayList<Badge> getBadgeArrayList() {
return badgeArrayList;
}

/**
* Set list of badges to be displayed.
*
* @param badgeArrayList List of badges. Maximum number of badges are 4.
*/
public void setBadgeArrayList(ArrayList<Badge> badgeArrayList) {
this.badgeArrayList = badgeArrayList;
}

//parcelling part
public CalendarwBadge(Parcel in){
year = in.readInt();
month = in.readInt();
day = in.readInt();
in.readTypedList(badgeArrayList, Badge.CREATOR);
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(year);
dest.writeInt(month);
dest.writeInt(day);
dest.writeTypedList(badgeArrayList);
}

@Override
public int describeContents() {
return 0;
}

public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public CalendarwBadge createFromParcel(Parcel in) {
return new CalendarwBadge(in);
}

public CalendarwBadge[] newArray(int size) {
return new CalendarwBadge[size];
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.wdullaer.materialdatetimepicker.date;

import android.app.FragmentManager;
import android.os.Build;

import java.util.Calendar;

public class DatePicker {

/**
* Determine appropriate picker dialog to be shown
* Option for horizontal scroll only available for Android API >=7
*
* @param manager Fragment manager of activity where picker dialog will be shown.
* @param events Contain details of events to be / not displayed on picker dialog.
* Pass null if there is no events to be displayed.
* @param tag Picker dialog's tag.
* @param scrollDirection Determine picker dialog scroll direction,
* use LinearLayoutManager.VERTICAL or LinearLayoutManager.HORIZONTAL,
* by default, it is LinearLayoutManager.VERTICAL.
*/
public static void displayDialog(FragmentManager manager, String tag, DatePickerDialog.OnDateSetListener listener,
Events events, int scrollDirection){

Calendar cal = Calendar.getInstance();
DatePickerDialog datePickerFragment;

if(Build.VERSION.SDK_INT >= 7){
datePickerFragment = DatePickerDialog.newInstance(listener, cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), events, scrollDirection);
}else{
if (events!=null) datePickerFragment = DatePickerDialog.newInstance (listener,cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),events);
else datePickerFragment = DatePickerDialog.newInstance (listener,cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
}
datePickerFragment.show(manager, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ public interface DatePickerController {
boolean isOutOfRange(int year, int month, int day);

void tryVibrate();

//EVENTS
//---------------------------------------------------------------------
boolean isEvent(int year, int month, int day);
int getEventColor();
boolean isEventClickable();
CalendarwBadge getCalendarwBadge();
//---------------------------------------------------------------------
}
Loading