Methods Summary |
---|
public boolean | isAutoStart()Returns true if this view automatically calls {@link #startFlipping()}
when it becomes attached to a window.
return mAutoStart;
|
public boolean | isFlipping()Returns true if the child views are flipping.
return mStarted;
|
protected void | onAttachedToWindow()
super.onAttachedToWindow();
// Listen for broadcasts related to user-presence
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_USER_PRESENT);
// OK, this is gross but needed. This class is supported by the
// remote views machanism and as a part of that the remote views
// can be inflated by a context for another user without the app
// having interact users permission - just for loading resources.
// For exmaple, when adding widgets from a user profile to the
// home screen. Therefore, we register the receiver as the current
// user not the one the context is for.
getContext().registerReceiverAsUser(mReceiver, android.os.Process.myUserHandle(),
filter, null, mHandler);
if (mAutoStart) {
// Automatically start when requested
startFlipping();
}
|
protected void | onDetachedFromWindow()
super.onDetachedFromWindow();
mVisible = false;
getContext().unregisterReceiver(mReceiver);
updateRunning();
|
public void | onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
super.onInitializeAccessibilityEvent(event);
event.setClassName(ViewFlipper.class.getName());
|
public void | onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(ViewFlipper.class.getName());
|
protected void | onWindowVisibilityChanged(int visibility)
super.onWindowVisibilityChanged(visibility);
mVisible = visibility == VISIBLE;
updateRunning(false);
|
public void | setAutoStart(boolean autoStart)Set if this view automatically calls {@link #startFlipping()} when it
becomes attached to a window.
mAutoStart = autoStart;
|
public void | setFlipInterval(int milliseconds)How long to wait before flipping to the next view
mFlipInterval = milliseconds;
|
public void | startFlipping()Start a timer to cycle through child views
mStarted = true;
updateRunning();
|
public void | stopFlipping()No more flips
mStarted = false;
updateRunning();
|
private void | updateRunning()Internal method to start or stop dispatching flip {@link Message} based
on {@link #mRunning} and {@link #mVisible} state.
updateRunning(true);
|
private void | updateRunning(boolean flipNow)Internal method to start or stop dispatching flip {@link Message} based
on {@link #mRunning} and {@link #mVisible} state.
boolean running = mVisible && mStarted && mUserPresent;
if (running != mRunning) {
if (running) {
showOnly(mWhichChild, flipNow);
Message msg = mHandler.obtainMessage(FLIP_MSG);
mHandler.sendMessageDelayed(msg, mFlipInterval);
} else {
mHandler.removeMessages(FLIP_MSG);
}
mRunning = running;
}
if (LOGD) {
Log.d(TAG, "updateRunning() mVisible=" + mVisible + ", mStarted=" + mStarted
+ ", mUserPresent=" + mUserPresent + ", mRunning=" + mRunning);
}
|