android.media.midi.MidiDeviceInfo Java Examples

The following examples show how to use android.media.midi.MidiDeviceInfo. 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 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 #2
Source File: MidiTools.java    From media-samples with Apache License 2.0 6 votes vote down vote up
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
Example #3
Source File: MidiPortWrapper.java    From android-MidiScope with Apache License 2.0 6 votes vote down vote up
private void updateString() {
    if (mInfo == null) {
        mString = "- - - - - -";
    } else {
        StringBuilder sb = new StringBuilder();
        String name = mInfo.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_NAME);
        if (name == null) {
            name = mInfo.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER) + ", "
                    + mInfo.getProperties()
                            .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
        }
        sb.append("#" + mInfo.getId());
        sb.append(", ").append(name);
        PortInfo portInfo = findPortInfo();
        sb.append("[" + mPortIndex + "]");
        if (portInfo != null) {
            sb.append(", ").append(portInfo.getName());
        } else {
            sb.append(", null");
        }
        mString = sb.toString();
    }
}
 
Example #4
Source File: MidiInputPortSelector.java    From media-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
Example #5
Source File: MidiPortWrapper.java    From media-samples with Apache License 2.0 6 votes vote down vote up
private void updateString() {
    if (mInfo == null) {
        mString = "- - - - - -";
    } else {
        StringBuilder sb = new StringBuilder();
        String name = mInfo.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_NAME);
        if (name == null) {
            name = mInfo.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER) + ", "
                    + mInfo.getProperties()
                            .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
        }
        sb.append("#" + mInfo.getId());
        sb.append(", ").append(name);
        PortInfo portInfo = findPortInfo();
        sb.append("[" + mPortIndex + "]");
        if (portInfo != null) {
            sb.append(", ").append(portInfo.getName());
        } else {
            sb.append(", null");
        }
        mString = sb.toString();
    }
}
 
Example #6
Source File: MidiInputPortSelector.java    From media-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
Example #7
Source File: MidiTools.java    From media-samples with Apache License 2.0 6 votes vote down vote up
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
Example #8
Source File: MidiPortWrapper.java    From media-samples with Apache License 2.0 6 votes vote down vote up
private void updateString() {
    if (mInfo == null) {
        mString = "- - - - - -";
    } else {
        StringBuilder sb = new StringBuilder();
        String name = mInfo.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_NAME);
        if (name == null) {
            name = mInfo.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER) + ", "
                    + mInfo.getProperties()
                            .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
        }
        sb.append("#" + mInfo.getId());
        sb.append(", ").append(name);
        PortInfo portInfo = findPortInfo();
        sb.append("[" + mPortIndex + "]");
        if (portInfo != null) {
            sb.append(", ").append(portInfo.getName());
        } else {
            sb.append(", null");
        }
        mString = sb.toString();
    }
}
 
Example #9
Source File: MidiTools.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
Example #10
Source File: MidiInputPortSelector.java    From android-MidiSynth with Apache License 2.0 6 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
Example #11
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 #12
Source File: MidiPrinter.java    From media-samples with Apache License 2.0 6 votes vote down vote up
public static String formatDeviceInfo(MidiDeviceInfo info) {
    StringBuilder sb = new StringBuilder();
    if (info != null) {
        Bundle properties = info.getProperties();
        for (String key : properties.keySet()) {
            Object value = properties.get(key);
            sb.append(key).append(" = ").append(value).append('\n');
        }
        for (PortInfo port : info.getPorts()) {
            sb.append((port.getType() == PortInfo.TYPE_INPUT) ? "input" : "output")
                    .append("[")
                    .append(port.getPortNumber())
                    .append("] = \"")
                    .append(port.getName()).append("\"\n");
        }
    }
    return sb.toString();
}
 
Example #13
Source File: MidiTools.java    From android-MidiScope with Apache License 2.0 6 votes vote down vote up
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
Example #14
Source File: MidiInputPortSelector.java    From android-MidiScope with Apache License 2.0 6 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
Example #15
Source File: MidiPrinter.java    From android-MidiScope with Apache License 2.0 6 votes vote down vote up
public static String formatDeviceInfo(MidiDeviceInfo info) {
    StringBuilder sb = new StringBuilder();
    if (info != null) {
        Bundle properties = info.getProperties();
        for (String key : properties.keySet()) {
            Object value = properties.get(key);
            sb.append(key).append(" = ").append(value).append('\n');
        }
        for (PortInfo port : info.getPorts()) {
            sb.append((port.getType() == PortInfo.TYPE_INPUT) ? "input" : "output")
                    .append("[")
                    .append(port.getPortNumber())
                    .append("] = \"")
                    .append(port.getName()).append("\"\n");
        }
    }
    return sb.toString();
}
 
Example #16
Source File: MidiInputPortSelector.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
Example #17
Source File: MidiPrinter.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
public static String formatDeviceInfo(MidiDeviceInfo info) {
    StringBuilder sb = new StringBuilder();
    if (info != null) {
        Bundle properties = info.getProperties();
        for (String key : properties.keySet()) {
            Object value = properties.get(key);
            sb.append(key).append(" = ").append(value).append('\n');
        }
        for (PortInfo port : info.getPorts()) {
            sb.append((port.getType() == PortInfo.TYPE_INPUT) ? "input"
                    : "output");
            sb.append("[").append(port.getPortNumber()).append("] = \"").append(port.getName()
                    + "\"\n");
        }
    }
    return sb.toString();
}
 
Example #18
Source File: MidiTools.java    From android-MidiSynth with Apache License 2.0 6 votes vote down vote up
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
Example #19
Source File: MidiPortWrapper.java    From android-midisuite with Apache License 2.0 6 votes vote down vote up
private void updateString() {
    if (mInfo == null) {
        mString = "- - - - - -";
    } else {
        StringBuilder sb = new StringBuilder();
        String name = mInfo.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_NAME);
        if (name == null) {
            name = mInfo.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER) + ", "
                    + mInfo.getProperties()
                            .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
        }
        sb.append("#" + mInfo.getId());
        sb.append(", ").append(name);
        PortInfo portInfo = findPortInfo();
        sb.append("[" + mPortIndex + "]");
        if (portInfo != null) {
            sb.append(", ").append(portInfo.getName());
        } else {
            sb.append(", null");
        }
        mString = sb.toString();
    }
}
 
Example #20
Source File: MidiManagerAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a midi device is detached.
 * @param info the detached device information.
 */
private void onDeviceRemoved(MidiDeviceInfo info) {
    for (MidiDeviceAndroid device : mDevices) {
        if (device.isOpen() && device.getInfo().getId() == info.getId()) {
            device.close();
            nativeOnDetached(mNativeManagerPointer, device);
        }
    }
}
 
Example #21
Source File: MidiPortSelector.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onDeviceRemoved(final MidiDeviceInfo info) {
    int portCount = getInfoPortCount(info);
    for (int i = 0; i < portCount; ++i) {
        MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
        MidiPortWrapper currentWrapper = mCurrentWrapper;
        mAdapter.remove(wrapper);
        // If the currently selected port was removed then select no port.
        if (wrapper.equals(currentWrapper)) {
            clearSelection();
        }
        mAdapter.notifyDataSetChanged();
        Log.i(MidiConstants.TAG, wrapper + " was removed");
    }
}
 
Example #22
Source File: MidiOutputPortImpl.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String getKey(){
	if( this.key == null ) {
		Bundle properties = this.info.getProperties();
		String deviceName = properties.getString(MidiDeviceInfo.PROPERTY_PRODUCT);
		if( deviceName == null ) {
			deviceName = properties.getString(MidiDeviceInfo.PROPERTY_NAME);
		}

		String portName = this.portInfo.getName();
		if( portName == null ) {
			portName = ("#" + this.portInfo.getPortNumber());
		}

		StringBuilder sb = new StringBuilder();
		if( deviceName != null ) {
			sb.append(deviceName);
		}

		if( sb.length() > 0 ) {
			sb.append(": ");
		}
		sb.append(portName);

		this.key = sb.toString();
	}
	return this.key;
}
 
Example #23
Source File: MainActivity.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
public void addDevice(BluetoothMidiDeviceTracker deviceTracker) {
    if (!mOpenDevices.contains(deviceTracker)) {
        mOpenDevices.add(deviceTracker);
        MidiDeviceInfo info = deviceTracker.midiDevice.getInfo();
        mInfoTrackerMap.put(info, deviceTracker);
        notifyDataSetChanged();
    }
}
 
Example #24
Source File: MidiPortConnector.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
/**
 * Open a source device and connect its output port to the
 * destinationInputPort.
 *
 * @param sourceDeviceInfo
 * @param sourcePortIndex
 * @param destinationInputPort
 */
private void connectToDevicePort(final MidiDeviceInfo sourceDeviceInfo,
        final int sourcePortIndex,
        final MidiInputPort destinationInputPort,
        final OnPortsConnectedListener listener, final Handler handler) {
    mMidiManager.openDevice(sourceDeviceInfo,
            new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open " + sourceDeviceInfo);
                        safeClose();
                        if (listener != null) {
                            listener.onPortsConnected(null);
                        }
                    } else {
                        Log.i(MidiConstants.TAG,
                                "connectToDevicePort opened "
                                        + sourceDeviceInfo);
                        // Device was opened so connect the ports.
                        mSourceDevice = device;
                        mConnection = device.connectPorts(
                                destinationInputPort, sourcePortIndex);
                        if (mConnection == null) {
                            Log.e(MidiConstants.TAG, "could not connect to "
                                    + sourceDeviceInfo);
                            safeClose();
                        }
                        if (listener != null) {
                            listener.onPortsConnected(mConnection);
                        }
                    }
                }
            }, handler);
}
 
Example #25
Source File: MidiDeviceAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the product name.
 */
@CalledByNative
String getProduct() {
    String product = getProperty(MidiDeviceInfo.PROPERTY_PRODUCT);
    // TODO(crbug.com/636455): Following code to use PROPERTY_NAME is a
    // workaround for a BLE MIDI device issue that Android does not provide
    // information for PROPERTY_MANUFACTURER, PROPERTY_PRODUCT, and
    // PROPERTY_VERSION. Confirmed on Android M and N.
    // See discussion at http://crbug.com/636455 and http://b/32259464.
    if (product == null || product.isEmpty()) {
        return getProperty(MidiDeviceInfo.PROPERTY_NAME);
    }
    return product;
}
 
Example #26
Source File: MidiOutputPortSelector.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    Log.i(MidiConstants.TAG, "onPortSelected: " + wrapper);
    close();

    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {

                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mOutputPort = device.openOutputPort(wrapper.getPortIndex());
                    if (mOutputPort == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open output port for " + info);
                        return;
                    }
                    mOutputPort.connect(mDispatcher);
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openOutputPort might take a while.
    }
}
 
Example #27
Source File: MidiManagerAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void openDevice(final MidiDeviceInfo info) {
    mManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
        @Override
        public void onDeviceOpened(MidiDevice device) {
            MidiManagerAndroid.this.onDeviceOpened(device, info);
        }
    }, mHandler);
}
 
Example #28
Source File: MidiPortConnector.java    From android-MidiSynth with Apache License 2.0 5 votes vote down vote up
/**
 * Open a source device and connect its output port to the
 * destinationInputPort.
 *
 * @param sourceDeviceInfo
 * @param sourcePortIndex
 * @param destinationInputPort
 */
private void connectToDevicePort(final MidiDeviceInfo sourceDeviceInfo,
        final int sourcePortIndex,
        final MidiInputPort destinationInputPort,
        final OnPortsConnectedListener listener, final Handler handler) {
    mMidiManager.openDevice(sourceDeviceInfo,
            new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open " + sourceDeviceInfo);
                        safeClose();
                        if (listener != null) {
                            listener.onPortsConnected(null);
                        }
                    } else {
                        Log.i(MidiConstants.TAG,
                                "connectToDevicePort opened "
                                        + sourceDeviceInfo);
                        // Device was opened so connect the ports.
                        mSourceDevice = device;
                        mConnection = device.connectPorts(
                                destinationInputPort, sourcePortIndex);
                        if (mConnection == null) {
                            Log.e(MidiConstants.TAG, "could not connect to "
                                    + sourceDeviceInfo);
                            safeClose();
                        }
                        if (listener != null) {
                            listener.onPortsConnected(mConnection);
                        }
                    }
                }
            }, handler);
}
 
Example #29
Source File: MidiPortSelector.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onDeviceStatusChanged(final MidiDeviceStatus status) {
    // If an input port becomes busy then remove it from the menu.
    // If it becomes free then add it back to the menu.
    if (mType == MidiDeviceInfo.PortInfo.TYPE_INPUT) {
        MidiDeviceInfo info = status.getDeviceInfo();
        Log.i(MidiConstants.TAG, "MidiPortSelector.onDeviceStatusChanged status = " + status
                + ", mType = " + mType
                + ", activity = " + mActivity.getPackageName()
                + ", info = " + info);
        // Look for transitions from free to busy.
        int portCount = info.getInputPortCount();
        for (int i = 0; i < portCount; ++i) {
            MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
            if (!wrapper.equals(mCurrentWrapper)) {
                if (status.isInputPortOpen(i)) { // busy?
                    if (!mBusyPorts.contains(wrapper)) {
                        // was free, now busy
                        mBusyPorts.add(wrapper);
                        mAdapter.remove(wrapper);
                        mAdapter.notifyDataSetChanged();
                    }
                } else {
                    if (mBusyPorts.remove(wrapper)) {
                        // was busy, now free
                        mAdapter.add(wrapper);
                        mAdapter.notifyDataSetChanged();
                    }
                }
            }
        }
    }
}
 
Example #30
Source File: MidiPortSelector.java    From android-midisuite with Apache License 2.0 5 votes vote down vote up
@Override
public void onDeviceAdded(final MidiDeviceInfo info) {
    int portCount = getInfoPortCount(info);
    for (int i = 0; i < portCount; ++i) {
        MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
        mAdapter.add(wrapper);
        Log.i(MidiConstants.TAG, wrapper + " was added to " + this);
        mAdapter.notifyDataSetChanged();
    }
}