This source file includes following definitions.
- handleMessage
- postViewScrolledAccessibilityEventCallback
- removePostedViewScrolledAccessibilityEventCallback
- removePostedCallbacks
package org.chromium.android_webview;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
class ScrollAccessibilityHelper {
private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
private class HandlerCallback implements Handler.Callback {
public static final int MSG_VIEW_SCROLLED = 1;
private View mEventSender;
public HandlerCallback(View eventSender) {
mEventSender = eventSender;
}
@Override
public boolean handleMessage(Message msg) {
switch(msg.what) {
case MSG_VIEW_SCROLLED:
mMsgViewScrolledQueued = false;
mEventSender.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED);
break;
default:
throw new IllegalStateException(
"AccessibilityInjector: unhandled message: " + msg.what);
}
return true;
}
}
private Handler mHandler;
private boolean mMsgViewScrolledQueued;
public ScrollAccessibilityHelper(View eventSender) {
mHandler = new Handler(new HandlerCallback(eventSender));
}
public void postViewScrolledAccessibilityEventCallback() {
if (mMsgViewScrolledQueued)
return;
mMsgViewScrolledQueued = true;
Message msg = mHandler.obtainMessage(HandlerCallback.MSG_VIEW_SCROLLED);
mHandler.sendMessageDelayed(msg, SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS);
}
public void removePostedViewScrolledAccessibilityEventCallback() {
if (!mMsgViewScrolledQueued)
return;
mMsgViewScrolledQueued = false;
mHandler.removeMessages(HandlerCallback.MSG_VIEW_SCROLLED);
}
public void removePostedCallbacks() {
removePostedViewScrolledAccessibilityEventCallback();
}
}