private void handleEvent(PresenterEvent presenterEvent) {
        Log.i(TAG, presenterEvent.toString());
        if (presenterEvent instanceof InfoEvent) {
            InfoEvent infoEvent = (InfoEvent) presenterEvent;
            final String infoText = infoEvent.infoText;
            showNotification(infoText);
        }
        if (presenterEvent instanceof CompatibilityModeEvent) {
            final CompatibilityModeEvent compatibilityModeEvent = (CompatibilityModeEvent) presenterEvent;
            final boolean isCompatibility = compatibilityModeEvent.show;
            compatOnlyWarningTextView.setVisibility(isCompatibility ? View.VISIBLE : View.INVISIBLE);
            if (isCompatibility) {
                /*
                All characteristics that have PROPERTY_NOTIFY or PROPERTY_INDICATE should contain
                a Client Characteristic Config Descriptor. The RxAndroidBle supports compatibility mode
                for setting the notifications / indications because it is not possible to fix the firmware
                in some third party peripherals. If you have possibility - inform the developer
                of the firmware that it is an error so they can fix.
                */
                Log.e(TAG, "THIS PERIPHERAL CHARACTERISTIC HAS PROPERTY_NOTIFY OR PROPERTY_INDICATE "
                        + "BUT DOES NOT HAVE CLIENT CHARACTERISTIC CONFIG DESCRIPTOR WHICH VIOLATES "
                        + "BLUETOOTH SPECIFICATION - CONTACT THE FIRMWARE DEVELOPER TO FIX IF POSSIBLE");
            }
        }
        if (presenterEvent instanceof ResultEvent) {
            final ResultEvent resultEvent = (ResultEvent) presenterEvent;
            switch (resultEvent.type) {

                case READ:
                    final byte[] updateReadValue = resultEvent.result;
                    final String stringValue = new String(updateReadValue);
                    readOutputView.setText(stringValue);
                    final String hexValueText = HexString.bytesToHex(updateReadValue);
                    readHexOutputView.setText(hexValueText);
                    writeInput.setText(hexValueText);
                    break;
                case WRITE:
                    showNotification("Write success");
                    break;
                case NOTIFY:
                    showNotification("Notification: " + HexString.bytesToHex(resultEvent.result));
                    break;
                case INDICATE:
                default: // added because Checkstyle is complaining
                    showNotification("Indication: " + HexString.bytesToHex(resultEvent.result));
                    break;
            }
        }
        if (presenterEvent instanceof ErrorEvent) {
            final ErrorEvent errorEvent = (ErrorEvent) presenterEvent;
            final Throwable throwable = errorEvent.error;
            final String notificationText;
            switch (errorEvent.type) {

                case READ:
                    notificationText = "Read error: " + throwable;
                    break;
                case WRITE:
                    notificationText = "Write error: " + throwable;
                    break;
                case NOTIFY:
                    notificationText = "Notifications error: " + throwable;
                    break;
                case INDICATE:
                default: // added because Checkstyle is complaining
                    notificationText = "Indications error: " + throwable;
                    break;
            }
            showNotification(notificationText);
        }
    }
Function that returns a {@link io.reactivex.ObservableTransformer} which will on subscribe
set a text on a button using a proper thread

@param button the button to set text on
@param textResId the text resource id
@return the transformer
sample/src/main/java/com/polidea/rxandroidble2/sample/example4_characteristic/advanced/AdvancedCharacteristicOperationExampleActivity.java