android.media.midi.MidiManager.DeviceCallback Java Examples

The following examples show how to use android.media.midi.MidiManager.DeviceCallback. 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: MidiDeviceMonitor.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
@Override
public void onDeviceAdded(final MidiDeviceInfo device) {
    // Call all of the locally registered callbacks.
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceAdded(device);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceAdded(device);
                }
            });
        }
    }
}
 
Example #2
Source File: MidiDeviceMonitor.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
@Override
public void onDeviceRemoved(final MidiDeviceInfo device) {
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceRemoved(device);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceRemoved(device);
                }
            });
        }
    }
}
 
Example #3
Source File: MidiDeviceMonitor.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
@Override
public void onDeviceStatusChanged(final MidiDeviceStatus status) {
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceStatusChanged(status);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceStatusChanged(status);
                }
            });
        }
    }
}
 
Example #4
Source File: MidiDeviceMonitor.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
public void registerDeviceCallback(DeviceCallback callback, Handler handler) {
    if (mUseProxy) {
        // Keep our own list of callbacks.
        mCallbacks.put(callback, handler);
    } else {
        mMidiManager.registerDeviceCallback(callback, handler);
    }
}
 
Example #5
Source File: MidiDeviceMonitor.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
public void unregisterDeviceCallback(DeviceCallback callback) {
    if (mUseProxy) {
        mCallbacks.remove(callback);
    } else {
        // This works on N or later.
        mMidiManager.unregisterDeviceCallback(callback);
    }
}