summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2013-09-17 14:39:07 -0700
committerAlan Viverette <alanv@google.com>2013-09-17 14:39:07 -0700
commit22c1c2cd103ef8beadaf0e78c12b22b60ce9cfc3 (patch)
tree1db9645b11e831bb0452e06af1d8e8868d72341b /core/java/android/widget
parent7354b834fc53a9d1885553aea58f632df16a5655 (diff)
downloadframeworks_base-22c1c2cd103ef8beadaf0e78c12b22b60ce9cfc3.zip
frameworks_base-22c1c2cd103ef8beadaf0e78c12b22b60ce9cfc3.tar.gz
frameworks_base-22c1c2cd103ef8beadaf0e78c12b22b60ce9cfc3.tar.bz2
Ensure WeeksAdapter calls notifyDataSetChanged when needed
Also cleans up references to Context. BUG: 10241917 Change-Id: Ic0b3d650cd85d656002cbb11b2bc73180ffe1bec
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/CalendarView.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java
index de2be75..0957ab4 100644
--- a/core/java/android/widget/CalendarView.java
+++ b/core/java/android/widget/CalendarView.java
@@ -391,7 +391,7 @@ public class CalendarView extends FrameLayout {
mWeekSeperatorLineWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
UNSCALED_WEEK_SEPARATOR_LINE_WIDTH, displayMetrics);
- LayoutInflater layoutInflater = (LayoutInflater) mContext
+ LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
View content = layoutInflater.inflate(R.layout.calendar_view, null, false);
addView(content);
@@ -874,7 +874,6 @@ public class CalendarView extends FrameLayout {
}
mFirstDayOfWeek = firstDayOfWeek;
mAdapter.init();
- mAdapter.notifyDataSetChanged();
setUpHeader();
}
@@ -937,7 +936,7 @@ public class CalendarView extends FrameLayout {
}
private void updateDateTextSize() {
- TypedArray dateTextAppearance = getContext().obtainStyledAttributes(
+ TypedArray dateTextAppearance = mContext.obtainStyledAttributes(
mDateTextAppearanceResId, R.styleable.TextAppearance);
mDateTextSize = dateTextAppearance.getDimensionPixelSize(
R.styleable.TextAppearance_textSize, DEFAULT_DATE_TEXT_SIZE);
@@ -1004,7 +1003,7 @@ public class CalendarView extends FrameLayout {
*/
private void setUpAdapter() {
if (mAdapter == null) {
- mAdapter = new WeeksAdapter(getContext());
+ mAdapter = new WeeksAdapter();
mAdapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
@@ -1333,19 +1332,16 @@ public class CalendarView extends FrameLayout {
* </p>
*/
private class WeeksAdapter extends BaseAdapter implements OnTouchListener {
+ private final Calendar mSelectedDate = Calendar.getInstance();
+ private final GestureDetector mGestureDetector;
private int mSelectedWeek;
- private GestureDetector mGestureDetector;
-
private int mFocusedMonth;
- private final Calendar mSelectedDate = Calendar.getInstance();
-
private int mTotalWeekCount;
- public WeeksAdapter(Context context) {
- mContext = context;
+ public WeeksAdapter() {
mGestureDetector = new GestureDetector(mContext, new CalendarGestureListener());
init();
}
@@ -1360,6 +1356,7 @@ public class CalendarView extends FrameLayout {
|| mMaxDate.get(Calendar.DAY_OF_WEEK) != mFirstDayOfWeek) {
mTotalWeekCount++;
}
+ notifyDataSetChanged();
}
/**