Search in sources :

Example 1 with Error7ElectronicError

use of sugar.free.sightparser.applayer.descriptors.alerts.Error7ElectronicError in project SightRemote by TebbeUbben.

the class AlertService method onResult.

@Override
public void onResult(Object result) {
    if (result instanceof ActiveAlertMessage) {
        ActiveAlertMessage activeAlertMessage = (ActiveAlertMessage) result;
        if (activeAlertMessage.getAlert() instanceof Error7ElectronicError) {
            serviceConnector.disconnect();
            return;
        }
        Alert alert = activeAlertMessage.getAlert();
        if (alert == null) {
            serviceConnector.disconnect();
            return;
        } else
            serviceConnector.connect();
        if (latestId != activeAlertMessage.getAlertID()) {
            if (alertActivity != null)
                alertActivity.finish();
            if (activeAlertMessage.getAlertStatus() == AlertStatus.MUTED)
                return;
            latestId = activeAlertMessage.getAlertID();
            Intent intent = new Intent(this, AlertActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("alertMessage", SerializationUtils.serialize(activeAlertMessage));
            startActivity(intent);
            Answers.getInstance().logCustom(new CustomEvent("Active Alert").putCustomAttribute("Alert", alert.getClass().getSimpleName()));
        } else if (alertActivity != null) {
            alertActivity.setAlertMessage(activeAlertMessage);
            alertActivity.update();
        }
    }
}
Also used : CustomEvent(com.crashlytics.android.answers.CustomEvent) ActiveAlertMessage(sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage) Alert(sugar.free.sightparser.applayer.descriptors.alerts.Alert) Intent(android.content.Intent) Error7ElectronicError(sugar.free.sightparser.applayer.descriptors.alerts.Error7ElectronicError)

Aggregations

Intent (android.content.Intent)1 CustomEvent (com.crashlytics.android.answers.CustomEvent)1 Alert (sugar.free.sightparser.applayer.descriptors.alerts.Alert)1 Error7ElectronicError (sugar.free.sightparser.applayer.descriptors.alerts.Error7ElectronicError)1 ActiveAlertMessage (sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage)1