diff --git a/library/src/main/java/com/alamkanak/weekview/DateTimeInterpreter.java b/library/src/main/java/com/alamkanak/weekview/DateTimeInterpreter.java index 383c5570d..f72341501 100644 --- a/library/src/main/java/com/alamkanak/weekview/DateTimeInterpreter.java +++ b/library/src/main/java/com/alamkanak/weekview/DateTimeInterpreter.java @@ -1,11 +1,13 @@ package com.alamkanak.weekview; -import java.util.Calendar; - /** * Created by Raquib on 1/6/2015. */ -public interface DateTimeInterpreter { - String interpretDate(Calendar date); - String interpretTime(int hour); +/** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.DateTimeInterpreter} instead. + */ +@Deprecated +public interface DateTimeInterpreter extends com.alamkanak.weekview.interfaces.DateTimeInterpreter{ } diff --git a/library/src/main/java/com/alamkanak/weekview/MonthLoader.java b/library/src/main/java/com/alamkanak/weekview/MonthLoader.java index 424d67c1b..49ab285b2 100644 --- a/library/src/main/java/com/alamkanak/weekview/MonthLoader.java +++ b/library/src/main/java/com/alamkanak/weekview/MonthLoader.java @@ -1,13 +1,15 @@ package com.alamkanak.weekview; +import com.alamkanak.weekview.interfaces.WeekViewLoader; + import java.util.Calendar; import java.util.List; public class MonthLoader implements WeekViewLoader { - private MonthChangeListener mOnMonthChangeListener; + private com.alamkanak.weekview.interfaces.MonthChangeListener mOnMonthChangeListener; - public MonthLoader(MonthChangeListener listener){ + public MonthLoader(com.alamkanak.weekview.interfaces.MonthChangeListener listener){ this.mOnMonthChangeListener = listener; } @@ -21,23 +23,21 @@ public List onLoad(int periodIndex){ return mOnMonthChangeListener.onMonthChange(periodIndex / 12, periodIndex % 12 + 1); } - public MonthChangeListener getOnMonthChangeListener() { + public com.alamkanak.weekview.interfaces.MonthChangeListener getOnMonthChangeListener() { return mOnMonthChangeListener; } - public void setOnMonthChangeListener(MonthChangeListener onMonthChangeListener) { + public void setOnMonthChangeListener(com.alamkanak.weekview.interfaces.MonthChangeListener onMonthChangeListener) { this.mOnMonthChangeListener = onMonthChangeListener; } - public interface MonthChangeListener { - /** - * Very important interface, it's the base to load events in the calendar. - * This method is called three times: once to load the previous month, once to load the next month and once to load the current month.
- * That's why you can have three times the same event at the same place if you mess up with the configuration - * @param newYear : year of the events required by the view. - * @param newMonth : month of the events required by the view
1 based (not like JAVA API) --> January = 1 and December = 12. - * @return a list of the events happening during the specified month. - */ - List onMonthChange(int newYear, int newMonth); + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.MonthChangeListener} instead. + */ + @Deprecated + public interface MonthChangeListener extends com.alamkanak.weekview.interfaces.MonthChangeListener{ + } } diff --git a/library/src/main/java/com/alamkanak/weekview/WeekView.java b/library/src/main/java/com/alamkanak/weekview/WeekView.java index da3fa71a0..838724e85 100755 --- a/library/src/main/java/com/alamkanak/weekview/WeekView.java +++ b/library/src/main/java/com/alamkanak/weekview/WeekView.java @@ -1,5 +1,13 @@ package com.alamkanak.weekview; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; + import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -33,13 +41,8 @@ import android.view.ViewConfiguration; import android.widget.OverScroller; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; +import com.alamkanak.weekview.interfaces.DateTimeInterpreter; +import com.alamkanak.weekview.interfaces.WeekViewLoader; import static com.alamkanak.weekview.WeekViewUtil.*; @@ -146,13 +149,13 @@ private enum Direction { private int mScrollDuration = 250; // Listeners. - private EventClickListener mEventClickListener; - private EventLongPressListener mEventLongPressListener; - private WeekViewLoader mWeekViewLoader; - private EmptyViewClickListener mEmptyViewClickListener; - private EmptyViewLongPressListener mEmptyViewLongPressListener; - private DateTimeInterpreter mDateTimeInterpreter; - private ScrollListener mScrollListener; + private com.alamkanak.weekview.interfaces.EventClickListener mEventClickListener; + private com.alamkanak.weekview.interfaces.EventLongPressListener mEventLongPressListener; + private com.alamkanak.weekview.interfaces.WeekViewLoader mWeekViewLoader; + private com.alamkanak.weekview.interfaces.EmptyViewClickListener mEmptyViewClickListener; + private com.alamkanak.weekview.interfaces.EmptyViewLongPressListener mEmptyViewLongPressListener; + private com.alamkanak.weekview.interfaces.DateTimeInterpreter mDateTimeInterpreter; + private com.alamkanak.weekview.interfaces.ScrollListener mScrollListener; private final GestureDetector.SimpleOnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener() { @@ -1222,21 +1225,21 @@ public void invalidate() { // ///////////////////////////////////////////////////////////////// - public void setOnEventClickListener (EventClickListener listener) { + public void setOnEventClickListener (com.alamkanak.weekview.interfaces.EventClickListener listener) { this.mEventClickListener = listener; } - public EventClickListener getEventClickListener() { + public com.alamkanak.weekview.interfaces.EventClickListener getEventClickListener() { return mEventClickListener; } - public @Nullable MonthLoader.MonthChangeListener getMonthChangeListener() { + public @Nullable com.alamkanak.weekview.interfaces.MonthChangeListener getMonthChangeListener() { if (mWeekViewLoader instanceof MonthLoader) return ((MonthLoader) mWeekViewLoader).getOnMonthChangeListener(); return null; } - public void setMonthChangeListener(MonthLoader.MonthChangeListener monthChangeListener) { + public void setMonthChangeListener(com.alamkanak.weekview.interfaces.MonthChangeListener monthChangeListener) { this.mWeekViewLoader = new MonthLoader(monthChangeListener); } @@ -1260,35 +1263,35 @@ public void setWeekViewLoader(WeekViewLoader loader){ this.mWeekViewLoader = loader; } - public EventLongPressListener getEventLongPressListener() { + public com.alamkanak.weekview.interfaces.EventLongPressListener getEventLongPressListener() { return mEventLongPressListener; } - public void setEventLongPressListener(EventLongPressListener eventLongPressListener) { + public void setEventLongPressListener(com.alamkanak.weekview.interfaces.EventLongPressListener eventLongPressListener) { this.mEventLongPressListener = eventLongPressListener; } - public void setEmptyViewClickListener(EmptyViewClickListener emptyViewClickListener){ + public void setEmptyViewClickListener(com.alamkanak.weekview.interfaces.EmptyViewClickListener emptyViewClickListener){ this.mEmptyViewClickListener = emptyViewClickListener; } - public EmptyViewClickListener getEmptyViewClickListener(){ + public com.alamkanak.weekview.interfaces.EmptyViewClickListener getEmptyViewClickListener(){ return mEmptyViewClickListener; } - public void setEmptyViewLongPressListener(EmptyViewLongPressListener emptyViewLongPressListener){ + public void setEmptyViewLongPressListener(com.alamkanak.weekview.interfaces.EmptyViewLongPressListener emptyViewLongPressListener){ this.mEmptyViewLongPressListener = emptyViewLongPressListener; } - public EmptyViewLongPressListener getEmptyViewLongPressListener(){ + public com.alamkanak.weekview.interfaces.EmptyViewLongPressListener getEmptyViewLongPressListener(){ return mEmptyViewLongPressListener; } - public void setScrollListener(ScrollListener scrolledListener){ + public void setScrollListener(com.alamkanak.weekview.interfaces.ScrollListener scrolledListener){ this.mScrollListener = scrolledListener; } - public ScrollListener getScrollListener(){ + public com.alamkanak.weekview.interfaces.ScrollListener getScrollListener(){ return mScrollListener; } @@ -1989,54 +1992,51 @@ public double getFirstVisibleHour(){ + ///////////////////////////////////////////////////////////////// // // Interfaces. // ///////////////////////////////////////////////////////////////// - - public interface EventClickListener { - /** - * Triggered when clicked on one existing event - * @param event: event clicked. - * @param eventRect: view containing the clicked event. - */ - void onEventClick(WeekViewEvent event, RectF eventRect); + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.EventClickListener} instead. + */ + @Deprecated + public interface EventClickListener extends com.alamkanak.weekview.interfaces.EventClickListener{ } - - public interface EventLongPressListener { - /** - * Similar to {@link com.alamkanak.weekview.WeekView.EventClickListener} but with a long press. - * @param event: event clicked. - * @param eventRect: view containing the clicked event. - */ - void onEventLongPress(WeekViewEvent event, RectF eventRect); + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.EventLongPressListener} instead. + */ + @Deprecated + public interface EventLongPressListener extends com.alamkanak.weekview.interfaces.EventLongPressListener{ } - - public interface EmptyViewClickListener { - /** - * Triggered when the users clicks on a empty space of the calendar. - * @param time: {@link Calendar} object set with the date and time of the clicked position on the view. - */ - void onEmptyViewClicked(Calendar time); + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.EmptyViewClickListener} instead. + */ + @Deprecated + public interface EmptyViewClickListener extends com.alamkanak.weekview.interfaces.EmptyViewClickListener{ } - - public interface EmptyViewLongPressListener { - /** - * Similar to {@link com.alamkanak.weekview.WeekView.EmptyViewClickListener} but with long press. - * @param time: {@link Calendar} object set with the date and time of the long pressed position on the view. - */ - void onEmptyViewLongPress(Calendar time); + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.EmptyViewLongPressListener} instead. + */ + @Deprecated + public interface EmptyViewLongPressListener extends com.alamkanak.weekview.interfaces.EmptyViewLongPressListener{ } + /** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.ScrollListener} instead. + */ + @Deprecated + public interface ScrollListener extends com.alamkanak.weekview.interfaces.ScrollListener{ - public interface ScrollListener { - /** - * Called when the first visible day has changed. - * - * (this will also be called during the first draw of the weekview) - * @param newFirstVisibleDay The new first visible day - * @param oldFirstVisibleDay The old first visible day (is null on the first call). - */ - void onFirstVisibleDayChanged(Calendar newFirstVisibleDay, Calendar oldFirstVisibleDay); } } diff --git a/library/src/main/java/com/alamkanak/weekview/WeekViewLoader.java b/library/src/main/java/com/alamkanak/weekview/WeekViewLoader.java index dcedfe988..81d001746 100644 --- a/library/src/main/java/com/alamkanak/weekview/WeekViewLoader.java +++ b/library/src/main/java/com/alamkanak/weekview/WeekViewLoader.java @@ -1,24 +1,9 @@ package com.alamkanak.weekview; - -import java.util.Calendar; -import java.util.List; - -public interface WeekViewLoader { - /** - * Convert a date into a double that will be used to reference when you're loading data. - * - * All periods that have the same integer part, define one period. Dates that are later in time - * should have a greater return value. - * - * @param instance the date - * @return The period index in which the date falls (floating point number). - */ - double toWeekViewPeriodIndex(Calendar instance); - - /** - * Load the events within the period - * @param periodIndex the period to load - * @return A list with the events of this period - */ - List onLoad(int periodIndex); +/** + * @deprecated code refractoring + * {will be removed in next version}
+ * use {@link com.alamkanak.weekview.interfaces.WeekViewLoader} instead. + */ +@Deprecated +public interface WeekViewLoader extends com.alamkanak.weekview.interfaces.WeekViewLoader{ } diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/DateTimeInterpreter.java b/library/src/main/java/com/alamkanak/weekview/interfaces/DateTimeInterpreter.java new file mode 100644 index 000000000..ae0837ffc --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/DateTimeInterpreter.java @@ -0,0 +1,11 @@ +package com.alamkanak.weekview.interfaces; + +import java.util.Calendar; + +/** + * Created by Raquib on 1/6/2015. + */ +public interface DateTimeInterpreter{ + String interpretDate(Calendar date); + String interpretTime(int hour); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewClickListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewClickListener.java new file mode 100644 index 000000000..85d4cfd5d --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewClickListener.java @@ -0,0 +1,14 @@ +package com.alamkanak.weekview.interfaces; + +import java.util.Calendar; + +/** + * Created by Thomas on 01/02/2016. + */ +public interface EmptyViewClickListener { + /** + * Triggered when the users clicks on a empty space of the calendar. + * @param time: {@link Calendar} object set with the date and time of the clicked position on the view. + */ + void onEmptyViewClicked(Calendar time); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewLongPressListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewLongPressListener.java new file mode 100644 index 000000000..c02076a40 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/EmptyViewLongPressListener.java @@ -0,0 +1,14 @@ +package com.alamkanak.weekview.interfaces; + +import java.util.Calendar; + +/** + * Created by Thomas on 01/02/2016. + */ +public interface EmptyViewLongPressListener { + /** + * Similar to {@link com.alamkanak.weekview.WeekView.EmptyViewClickListener} but with long press. + * @param time: {@link Calendar} object set with the date and time of the long pressed position on the view. + */ + void onEmptyViewLongPress(Calendar time); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/EventClickListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/EventClickListener.java new file mode 100644 index 000000000..314bcc787 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/EventClickListener.java @@ -0,0 +1,17 @@ +package com.alamkanak.weekview.interfaces; + +import android.graphics.RectF; + +import com.alamkanak.weekview.WeekViewEvent; + +/** + * Created by Thomas on 01/02/2016. + */ +public interface EventClickListener{ + /** + * Triggered when clicked on one existing event + * @param event: event clicked. + * @param eventRect: view containing the clicked event. + */ + void onEventClick(WeekViewEvent event, RectF eventRect); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/EventLongPressListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/EventLongPressListener.java new file mode 100644 index 000000000..d1d35caf9 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/EventLongPressListener.java @@ -0,0 +1,17 @@ +package com.alamkanak.weekview.interfaces; + +import android.graphics.RectF; + +import com.alamkanak.weekview.WeekViewEvent; + +/** + * Created by Thomas on 01/02/2016. + */ +public interface EventLongPressListener{ + /** + * Similar to {@link com.alamkanak.weekview.WeekView.EventClickListener} but with a long press. + * @param event: event clicked. + * @param eventRect: view containing the clicked event. + */ + void onEventLongPress(WeekViewEvent event, RectF eventRect); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/MonthChangeListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/MonthChangeListener.java new file mode 100644 index 000000000..69d771010 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/MonthChangeListener.java @@ -0,0 +1,21 @@ +package com.alamkanak.weekview.interfaces; + +import com.alamkanak.weekview.WeekViewEvent; + +import java.util.List; + +/** + * Created by Thomas on 22/02/2016. + */ + +public interface MonthChangeListener{ + /** + * Very important interface, it's the base to load events in the calendar. + * This method is called three times: once to load the previous month, once to load the next month and once to load the current month.
+ * That's why you can have three times the same event at the same place if you mess up with the configuration + * @param newYear : year of the events required by the view. + * @param newMonth : month of the events required by the view
1 based (not like JAVA API) --> January = 1 and December = 12. + * @return a list of the events happening during the specified month. + */ + List onMonthChange(int newYear, int newMonth); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/ScrollListener.java b/library/src/main/java/com/alamkanak/weekview/interfaces/ScrollListener.java new file mode 100644 index 000000000..7697a18c5 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/ScrollListener.java @@ -0,0 +1,17 @@ +package com.alamkanak.weekview.interfaces; + +import java.util.Calendar; + +/** + * Created by Thomas on 01/02/2016. + */ +public interface ScrollListener { + /** + * Called when the first visible day has changed. + * + * (this will also be called during the first draw of the weekview) + * @param newFirstVisibleDay The new first visible day + * @param oldFirstVisibleDay The old first visible day (is null on the first call). + */ + void onFirstVisibleDayChanged(Calendar newFirstVisibleDay, Calendar oldFirstVisibleDay); +} diff --git a/library/src/main/java/com/alamkanak/weekview/interfaces/WeekViewLoader.java b/library/src/main/java/com/alamkanak/weekview/interfaces/WeekViewLoader.java new file mode 100644 index 000000000..9644dde31 --- /dev/null +++ b/library/src/main/java/com/alamkanak/weekview/interfaces/WeekViewLoader.java @@ -0,0 +1,26 @@ +package com.alamkanak.weekview.interfaces; + +import com.alamkanak.weekview.WeekViewEvent; + +import java.util.Calendar; +import java.util.List; + +public interface WeekViewLoader{ + /** + * Convert a date into a double that will be used to reference when you're loading data. + * + * All periods that have the same integer part, define one period. Dates that are later in time + * should have a greater return value. + * + * @param instance the date + * @return The period index in which the date falls (floating point number). + */ + double toWeekViewPeriodIndex(Calendar instance); + + /** + * Load the events within the period + * @param periodIndex the period to load + * @return A list with the events of this period + */ + List onLoad(int periodIndex); +} diff --git a/sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java b/sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java index e311d1943..04432754c 100644 --- a/sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java +++ b/sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java @@ -8,10 +8,13 @@ import android.view.MenuItem; import android.widget.Toast; -import com.alamkanak.weekview.DateTimeInterpreter; import com.alamkanak.weekview.MonthLoader; import com.alamkanak.weekview.WeekView; import com.alamkanak.weekview.WeekViewEvent; +import com.alamkanak.weekview.interfaces.DateTimeInterpreter; +import com.alamkanak.weekview.interfaces.EmptyViewLongPressListener; +import com.alamkanak.weekview.interfaces.EventClickListener; +import com.alamkanak.weekview.interfaces.EventLongPressListener; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -23,7 +26,7 @@ * Created by Raquib-ul-Alam Kanak on 1/3/2014. * Website: http://alamkanak.github.io */ -public abstract class BaseActivity extends AppCompatActivity implements WeekView.EventClickListener, MonthLoader.MonthChangeListener, WeekView.EventLongPressListener, WeekView.EmptyViewLongPressListener { +public abstract class BaseActivity extends AppCompatActivity implements EventClickListener, MonthLoader.MonthChangeListener, EventLongPressListener, EmptyViewLongPressListener { private static final int TYPE_DAY_VIEW = 1; private static final int TYPE_THREE_DAY_VIEW = 2; private static final int TYPE_WEEK_VIEW = 3;