Fields Summary |
---|
private static final int | INITIAL_HEAP_SIZE |
private android.view.animation.Animation | mInAnimationPast |
private android.view.animation.Animation | mInAnimationFuture |
private android.view.animation.Animation | mOutAnimationPast |
private android.view.animation.Animation | mOutAnimationFuture |
private android.widget.ViewSwitcher | mSwitcher |
private android.text.format.Time | mTime |
private android.content.ContentResolver | mContentResolver |
EventLoader | mEventLoader |
private int | mStartDay |
private android.widget.ProgressBar | mProgressBar |
private android.content.BroadcastReceiver | mIntentReceiverListens for intent broadcasts |
private android.database.ContentObserver | mObserver |
Methods Summary |
---|
void | eventsChanged()
MonthView view = (MonthView) mSwitcher.getCurrentView();
view.reloadEvents();
|
public boolean | getAllDay()
return false;
|
public long | getSelectedTime()
MonthView mv = (MonthView) mSwitcher.getCurrentView();
return mv.getSelectedTimeInMillis();
|
int | getStartDay()
return mStartDay;
|
public void | goTo(android.text.format.Time time)
TextView title = (TextView) findViewById(R.id.title);
title.setText(Utils.formatMonthYear(time));
MonthView current = (MonthView) mSwitcher.getCurrentView();
current.dismissPopup();
Time currentTime = current.getTime();
// Compute a month number that is monotonically increasing for any
// two adjacent months.
// This is faster than calling getSelectedTime() because we avoid
// a call to Time#normalize().
int currentMonth = currentTime.month + currentTime.year * 12;
int nextMonth = time.month + time.year * 12;
if (nextMonth < currentMonth) {
mSwitcher.setInAnimation(mInAnimationPast);
mSwitcher.setOutAnimation(mOutAnimationPast);
} else {
mSwitcher.setInAnimation(mInAnimationFuture);
mSwitcher.setOutAnimation(mOutAnimationFuture);
}
MonthView next = (MonthView) mSwitcher.getNextView();
next.setSelectionMode(current.getSelectionMode());
next.setSelectedTime(time);
next.reloadEvents();
next.animationStarted();
mSwitcher.showNext();
next.requestFocus();
mTime = time;
|
public void | goToToday()
Time now = new Time();
now.set(System.currentTimeMillis());
TextView title = (TextView) findViewById(R.id.title);
title.setText(Utils.formatMonthYear(now));
mTime = now;
MonthView view = (MonthView) mSwitcher.getCurrentView();
view.setSelectedTime(now);
view.reloadEvents();
|
public android.view.View | makeView()
MonthView mv = new MonthView(this, this);
mv.setLayoutParams(new ViewSwitcher.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
mv.setSelectedTime(mTime);
return mv;
|
public void | onAnimationEnd(android.view.animation.Animation animation)
MonthView monthView = (MonthView) mSwitcher.getCurrentView();
monthView.animationFinished();
|
public void | onAnimationRepeat(android.view.animation.Animation animation)
|
public void | onAnimationStart(android.view.animation.Animation animation)
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
// Eliminate extra GCs during startup by setting the initial heap size to 4MB.
// TODO: We should restore the old heap size once the activity reaches the idle state
long oldHeapSize = VMRuntime.getRuntime().setMinimumHeapSize(INITIAL_HEAP_SIZE);
setContentView(R.layout.month_activity);
mContentResolver = getContentResolver();
long time;
if (icicle != null) {
time = icicle.getLong(EVENT_BEGIN_TIME);
} else {
time = Utils.timeFromIntentInMillis(getIntent());
}
mTime = new Time();
mTime.set(time);
mTime.normalize(true);
// Get first day of week based on locale and populate the day headers
mStartDay = Calendar.getInstance().getFirstDayOfWeek();
int diff = mStartDay - Calendar.SUNDAY - 1;
String dayString = DateUtils.getDayOfWeekString((Calendar.SUNDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day0)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.MONDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day1)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.TUESDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day2)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.WEDNESDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day3)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.THURSDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day4)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.FRIDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day5)).setText(dayString);
dayString = DateUtils.getDayOfWeekString((Calendar.SATURDAY + diff) % 7 + 1,
DateUtils.LENGTH_MEDIUM);
((TextView) findViewById(R.id.day6)).setText(dayString);
// Set the initial title
TextView title = (TextView) findViewById(R.id.title);
title.setText(Utils.formatMonthYear(mTime));
mEventLoader = new EventLoader(this);
mProgressBar = (ProgressBar) findViewById(R.id.progress_circular);
mSwitcher = (ViewSwitcher) findViewById(R.id.switcher);
mSwitcher.setFactory(this);
mSwitcher.getCurrentView().requestFocus();
mInAnimationPast = AnimationUtils.loadAnimation(this, R.anim.slide_down_in);
mOutAnimationPast = AnimationUtils.loadAnimation(this, R.anim.slide_down_out);
mInAnimationFuture = AnimationUtils.loadAnimation(this, R.anim.slide_up_in);
mOutAnimationFuture = AnimationUtils.loadAnimation(this, R.anim.slide_up_out);
mInAnimationPast.setAnimationListener(this);
mInAnimationFuture.setAnimationListener(this);
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
MenuHelper.onCreateOptionsMenu(menu);
return super.onCreateOptionsMenu(menu);
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
finish();
return true;
}
return super.onKeyDown(keyCode, event);
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
MenuHelper.onOptionsItemSelected(this, item, this);
return super.onOptionsItemSelected(item);
|
protected void | onPause()
super.onPause();
if (isFinishing()) {
mEventLoader.stopBackgroundThread();
}
mContentResolver.unregisterContentObserver(mObserver);
unregisterReceiver(mIntentReceiver);
MonthView view = (MonthView) mSwitcher.getCurrentView();
view.dismissPopup();
view = (MonthView) mSwitcher.getNextView();
view.dismissPopup();
mEventLoader.stopBackgroundThread();
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
MenuHelper.onPrepareOptionsMenu(this, menu);
return super.onPrepareOptionsMenu(menu);
|
protected void | onResume()
super.onResume();
mEventLoader.startBackgroundThread();
eventsChanged();
MonthView view1 = (MonthView) mSwitcher.getCurrentView();
MonthView view2 = (MonthView) mSwitcher.getNextView();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String str = prefs.getString(CalendarPreferenceActivity.KEY_DETAILED_VIEW,
CalendarPreferenceActivity.DEFAULT_DETAILED_VIEW);
view1.setDetailedView(str);
view2.setDetailedView(str);
// Record Month View as the (new) start view
String activityString = CalendarApplication.ACTIVITY_NAMES[CalendarApplication.MONTH_VIEW_ID];
SharedPreferences.Editor editor = prefs.edit();
editor.putString(CalendarPreferenceActivity.KEY_START_VIEW, activityString);
editor.commit();
// Register for Intent broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
registerReceiver(mIntentReceiver, filter);
mContentResolver.registerContentObserver(Events.CONTENT_URI,
true, mObserver);
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
outState.putLong(EVENT_BEGIN_TIME, mTime.toMillis(true));
|
protected void | startProgressSpinner()
// start the progress spinner
mProgressBar.setVisibility(View.VISIBLE);
|
protected void | stopProgressSpinner()
// stop the progress spinner
mProgressBar.setVisibility(View.GONE);
|