summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben <rglez@google.com>2014-07-09 17:05:22 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-09 17:05:22 +0000
commit1ec1790979f5faf81da3d6bdb608613a4ea07248 (patch)
treea3f7cd6557d73386e791a058fbfde0fc5fdc8356
parent049e42303371575d5d3cb011a5eae81879c0e0f4 (diff)
parent7136720cda1d03a805a2add26e9ee5b4bdeec2e4 (diff)
downloadandroid_frameworks_opt_datetimepicker-1ec1790979f5faf81da3d6bdb608613a4ea07248.tar.gz
android_frameworks_opt_datetimepicker-1ec1790979f5faf81da3d6bdb608613a4ea07248.tar.bz2
android_frameworks_opt_datetimepicker-1ec1790979f5faf81da3d6bdb608613a4ea07248.zip
am 7136720c: am 59d94e4e: Prepare MonthView to support new features in child classes
* commit '7136720cda1d03a805a2add26e9ee5b4bdeec2e4': Prepare MonthView to support new features in child classes
-rw-r--r--src/com/android/datetimepicker/date/MonthView.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/com/android/datetimepicker/date/MonthView.java b/src/com/android/datetimepicker/date/MonthView.java
index f209e74..0976265 100644
--- a/src/com/android/datetimepicker/date/MonthView.java
+++ b/src/com/android/datetimepicker/date/MonthView.java
@@ -176,7 +176,8 @@ public abstract class MonthView extends View {
protected int mNumRows = DEFAULT_NUM_ROWS;
// Optional listener for handling day click actions
- private OnDayClickListener mOnDayClickListener;
+ protected OnDayClickListener mOnDayClickListener;
+
// Whether to prevent setting the accessibility delegate
private boolean mLockAccessibilityDelegate;
@@ -530,6 +531,21 @@ public abstract class MonthView extends View {
* @return The day number, or -1 if the position wasn't in a day
*/
public int getDayFromLocation(float x, float y) {
+ final int day = getInternalDayFromLocation(x, y);
+ if (day < 1 || day > mNumCells) {
+ return -1;
+ }
+ return day;
+ }
+
+ /**
+ * Calculates the day that the given x position is in, accounting for week
+ * number.
+ *
+ * @param x The x position of the touch event
+ * @return The day number
+ */
+ protected int getInternalDayFromLocation(float x, float y) {
int dayStart = mEdgePadding;
if (x < dayStart || x > mWidth - mEdgePadding) {
return -1;
@@ -540,9 +556,6 @@ public abstract class MonthView extends View {
int day = column - findDayOffset() + 1;
day += row * mNumDays;
- if (day < 1 || day > mNumCells) {
- return -1;
- }
return day;
}