diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-03-14 23:15:24 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-14 23:15:24 -0700 |
commit | 6d4f318f0c836c0c2eac3a1d99debedc6c03578a (patch) | |
tree | 5c9df11de1038199a037a52abce2bc068f44d76c | |
parent | f057524db620c490e96fa886238f3b31bd973060 (diff) | |
parent | e65711b21f1b351f28d4f04819e1e05a9ac8dfee (diff) | |
download | frameworks_base-6d4f318f0c836c0c2eac3a1d99debedc6c03578a.zip frameworks_base-6d4f318f0c836c0c2eac3a1d99debedc6c03578a.tar.gz frameworks_base-6d4f318f0c836c0c2eac3a1d99debedc6c03578a.tar.bz2 |
am e65711b2: Merge "Tapping on the week number sends the DatePicker to epoch start." into honeycomb-mr1
* commit 'e65711b21f1b351f28d4f04819e1e05a9ac8dfee':
Tapping on the week number sends the DatePicker to epoch start.
-rw-r--r-- | core/java/android/widget/CalendarView.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index 13a407f..f8c76f2 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -1066,7 +1066,10 @@ public class CalendarView extends FrameLayout { public boolean onTouch(View v, MotionEvent event) { if (mListView.isEnabled() && mGestureDetector.onTouchEvent(event)) { WeekView weekView = (WeekView) v; - weekView.getDayFromLocation(event.getX(), mTempDate); + // if we cannot find a day for the given location we are done + if (!weekView.getDayFromLocation(event.getX(), mTempDate)) { + return true; + } // it is possible that the touched day is outside the valid range // we draw whole weeks but range end can fall not on the week end if (mTempDate.before(mMinDate) || mTempDate.after(mMaxDate)) { @@ -1271,21 +1274,23 @@ public class CalendarView extends FrameLayout { /** * Calculates the day that the given x position is in, accounting for - * week number. Returns a Time referencing that day or null if + * week number. * - * @param x The x position of the touch eventy + * @param x The x position of the touch event. + * @return True if a day was found for the given location. */ - public void getDayFromLocation(float x, Calendar outCalendar) { + public boolean getDayFromLocation(float x, Calendar outCalendar) { int dayStart = mShowWeekNumber ? mWidth / mNumCells : 0; if (x < dayStart || x > mWidth) { outCalendar.clear(); - return; + return false; } // Selection is (x - start) / (pixels/day) == (x -s) * day / pixels int dayPosition = (int) ((x - dayStart) * mDaysPerWeek / (mWidth - dayStart)); outCalendar.setTimeInMillis(mFirstDay.getTimeInMillis()); outCalendar.add(Calendar.DAY_OF_MONTH, dayPosition); + return true; } @Override |