Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
import java.util.Calendar;


public class CalendarUtils
{
public static int getDaysInMonth(int month, int year) {
public class CalendarUtils {
public static int getDaysInMonth(int month, int year) {
switch (month) {
case Calendar.JANUARY:
case Calendar.MARCH:
Expand All @@ -48,5 +47,5 @@ public static int getDaysInMonth(int month, int year) {
default:
throw new IllegalArgumentException("Invalid Month");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,56 +29,48 @@
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;

public class DayPickerView extends RecyclerView
{
public class DayPickerView extends RecyclerView {
protected Context mContext;
protected SimpleMonthAdapter mAdapter;
private DatePickerController mController;
protected SimpleMonthAdapter mAdapter;
private DatePickerController mController;
protected int mCurrentScrollState = 0;
protected long mPreviousScrollPosition;
protected int mPreviousScrollState = 0;
protected long mPreviousScrollPosition;
protected int mPreviousScrollState = 0;
private TypedArray typedArray;
private OnScrollListener onScrollListener;

public DayPickerView(Context context)
{
public DayPickerView(Context context) {
this(context, null);
}

public DayPickerView(Context context, AttributeSet attrs)
{
public DayPickerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public DayPickerView(Context context, AttributeSet attrs, int defStyle)
{
public DayPickerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (!isInEditMode())
{
if (!isInEditMode()) {
typedArray = context.obtainStyledAttributes(attrs, R.styleable.DayPickerView);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
init(context);
}
}

public void setController(DatePickerController mController)
{
public void setController(DatePickerController mController) {
this.mController = mController;
setUpAdapter();
setAdapter(mAdapter);
}


public void init(Context paramContext) {
public void init(Context paramContext) {
setLayoutManager(new LinearLayoutManager(paramContext));
mContext = paramContext;
setUpListView();
mContext = paramContext;
setUpListView();

onScrollListener = new OnScrollListener()
{
onScrollListener = new OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
final SimpleMonthView child = (SimpleMonthView) recyclerView.getChildAt(0);
if (child == null) {
Expand All @@ -89,34 +81,37 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy)
mPreviousScrollState = mCurrentScrollState;
}
};
}
}


protected void setUpAdapter() {
if (mAdapter == null) {
mAdapter = new SimpleMonthAdapter(getContext(), mController, typedArray);
}
mAdapter.notifyDataSetChanged();
}

protected void setUpAdapter() {
if (mAdapter == null) {
mAdapter = new SimpleMonthAdapter(getContext(), mController, typedArray);
public void setSelectedDay(SimpleMonthAdapter.CalendarDay calendarDay) {
if (mAdapter != null) {
mAdapter.setSelectedDay(calendarDay);
}
mAdapter.notifyDataSetChanged();
}
}

protected void setUpListView() {
setVerticalScrollBarEnabled(false);
setOnScrollListener(onScrollListener);
setFadingEdgeLength(0);
}
protected void setUpListView() {
setVerticalScrollBarEnabled(false);
setOnScrollListener(onScrollListener);
setFadingEdgeLength(0);
}

public SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> getSelectedDays()
{
public SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> getSelectedDays() {
return mAdapter.getSelectedDays();
}

protected DatePickerController getController()
{
protected DatePickerController getController() {
return mController;
}

protected TypedArray getTypedArray()
{
protected TypedArray getTypedArray() {
return typedArray;
}
}
Loading