Fields Summary |
---|
private static final long | INITIAL_HEAP_SIZE |
private static final long | ANIMATION_DURATION |
protected static final String | BUNDLE_KEY_RESTORE_TIME |
private android.content.ContentResolver | mContentResolver |
private android.accounts.AccountMonitor | mAccountMonitor |
protected android.widget.ProgressBar | mProgressBar |
protected android.widget.ViewSwitcher | mViewSwitcher |
protected android.view.animation.Animation | mInAnimationForward |
protected android.view.animation.Animation | mOutAnimationForward |
protected android.view.animation.Animation | mInAnimationBackward |
protected android.view.animation.Animation | mOutAnimationBackward |
EventLoader | mEventLoader |
android.text.format.Time | mSelectedDay |
android.view.GestureDetector | mGestureDetector |
private android.content.BroadcastReceiver | mIntentReceiverListens for intent broadcasts |
private android.database.ContentObserver | mObserver |
Methods Summary |
---|
void | eventsChanged()
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
view.clearCachedEvents();
view.reloadEvents();
|
public boolean | getAllDay()
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
return view.mSelectionAllDay;
|
Event | getNewEvent()
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
return view.getNewEvent();
|
public CalendarView | getNextView()
return (CalendarView) mViewSwitcher.getNextView();
|
Event | getSelectedEvent()
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
return view.getSelectedEvent();
|
public long | getSelectedTime()
return getSelectedTimeInMillis();
|
public long | getSelectedTimeInMillis()Returns the selected time in milliseconds. The milliseconds are measured
in UTC milliseconds from the epoch and uniquely specifies any selectable
time.
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
return view.getSelectedTimeInMillis();
|
public void | goTo(android.text.format.Time time)
CalendarView current = (CalendarView) mViewSwitcher.getCurrentView();
if (current.getSelectedTime().before(time)) {
mViewSwitcher.setInAnimation(mInAnimationForward);
mViewSwitcher.setOutAnimation(mOutAnimationForward);
} else {
mViewSwitcher.setInAnimation(mInAnimationBackward);
mViewSwitcher.setOutAnimation(mOutAnimationBackward);
}
CalendarView next = (CalendarView) mViewSwitcher.getNextView();
next.setSelectedDay(time);
next.reloadEvents();
mViewSwitcher.showNext();
next.requestFocus();
|
public void | goToToday()
mSelectedDay.set(System.currentTimeMillis());
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
view.setSelectedDay(mSelectedDay);
view.reloadEvents();
|
boolean | isEventSelected()
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
return view.isEventSelected();
|
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);
setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
mContentResolver = getContentResolver();
mInAnimationForward = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
mOutAnimationForward = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
mInAnimationBackward = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
mOutAnimationBackward = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);
mGestureDetector = new GestureDetector(this, new CalendarGestureListener());
mEventLoader = new EventLoader(this);
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
if (! MenuHelper.onCreateOptionsMenu(menu)) {
return false;
}
return super.onCreateOptionsMenu(menu);
|
protected void | onDestroy()
if (mAccountMonitor != null) {
mAccountMonitor.close();
}
super.onDestroy();
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
if (MenuHelper.onOptionsItemSelected(this, item, this)) {
return true;
}
return super.onOptionsItemSelected(item);
|
protected void | onPause()
super.onPause();
mContentResolver.unregisterContentObserver(mObserver);
unregisterReceiver(mIntentReceiver);
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
view.cleanup();
view = (CalendarView) mViewSwitcher.getNextView();
view.cleanup();
mEventLoader.stopBackgroundThread();
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
MenuHelper.onPrepareOptionsMenu(this, menu);
return super.onPrepareOptionsMenu(menu);
|
protected void | onRestoreInstanceState(android.os.Bundle savedInstanceState)
super.onRestoreInstanceState(savedInstanceState);
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
Time time = new Time();
time.set(savedInstanceState.getLong(BUNDLE_KEY_RESTORE_TIME));
view.setSelectedDay(time);
|
protected void | onResume()
super.onResume();
mEventLoader.startBackgroundThread();
eventsChanged();
// 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(Calendar.Events.CONTENT_URI,
true, mObserver);
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
outState.putLong(BUNDLE_KEY_RESTORE_TIME, getSelectedTimeInMillis());
|
public boolean | onTouchEvent(android.view.MotionEvent ev)
if (mGestureDetector.onTouchEvent(ev)) {
return true;
}
return super.onTouchEvent(ev);
|
void | startProgressSpinner()
// start the progress spinner
mProgressBar.setVisibility(View.VISIBLE);
|
void | stopProgressSpinner()
// stop the progress spinner
mProgressBar.setVisibility(View.GONE);
|
public android.view.View | switchViews(boolean forward, float xOffSet, float width)
float progress = Math.abs(xOffSet) / width;
if (progress > 1.0f) {
progress = 1.0f;
}
float inFromXValue, inToXValue;
float outFromXValue, outToXValue;
if (forward) {
inFromXValue = 1.0f - progress;
inToXValue = 0.0f;
outFromXValue = -progress;
outToXValue = -1.0f;
} else {
inFromXValue = progress - 1.0f;
inToXValue = 0.0f;
outFromXValue = progress;
outToXValue = 1.0f;
}
// We have to allocate these animation objects each time we switch views
// because that is the only way to set the animation parameters.
TranslateAnimation inAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, inFromXValue,
Animation.RELATIVE_TO_SELF, inToXValue,
Animation.ABSOLUTE, 0.0f,
Animation.ABSOLUTE, 0.0f);
TranslateAnimation outAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, outFromXValue,
Animation.RELATIVE_TO_SELF, outToXValue,
Animation.ABSOLUTE, 0.0f,
Animation.ABSOLUTE, 0.0f);
// Reduce the animation duration based on how far we have already swiped.
long duration = (long) (ANIMATION_DURATION * (1.0f - progress));
inAnimation.setDuration(duration);
outAnimation.setDuration(duration);
mViewSwitcher.setInAnimation(inAnimation);
mViewSwitcher.setOutAnimation(outAnimation);
CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
view.cleanup();
mViewSwitcher.showNext();
view = (CalendarView) mViewSwitcher.getCurrentView();
view.requestFocus();
view.reloadEvents();
return view;
|