android.hardware.display.DisplayManager.DisplayListener Java Examples

The following examples show how to use android.hardware.display.DisplayManager.DisplayListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DisplayManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void registerDisplayListener(DisplayListener listener, Handler handler) {
    if (listener == null) {
        throw new IllegalArgumentException("listener must not be null");
    }

    synchronized (mLock) {
        int index = findDisplayListenerLocked(listener);
        if (index < 0) {
            mDisplayListeners.add(new DisplayListenerDelegate(listener, handler));
            registerCallbackIfNeededLocked();
        }
    }
}
 
Example #2
Source File: DisplayManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void unregisterDisplayListener(DisplayListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("listener must not be null");
    }

    synchronized (mLock) {
        int index = findDisplayListenerLocked(listener);
        if (index >= 0) {
            DisplayListenerDelegate d = mDisplayListeners.get(index);
            d.clearEvents();
            mDisplayListeners.remove(index);
        }
    }
}
 
Example #3
Source File: DisplayManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int findDisplayListenerLocked(DisplayListener listener) {
    final int numListeners = mDisplayListeners.size();
    for (int i = 0; i < numListeners; i++) {
        if (mDisplayListeners.get(i).mListener == listener) {
            return i;
        }
    }
    return -1;
}
 
Example #4
Source File: DisplayManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public DisplayListenerDelegate(DisplayListener listener, Handler handler) {
    super(handler != null ? handler.getLooper() : Looper.myLooper(), null, true /*async*/);
    mListener = listener;
}