Search in sources :

Example 1 with SetAlarmRequest

use of nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetAlarmRequest in project Gadgetbridge by Freeyourgadget.

the class LefunDeviceSupport method onSetAlarms.

@Override
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
    int i = 0;
    for (Alarm alarm : alarms) {
        try {
            TransactionBuilder builder = performInitialized(SetAlarmRequest.class.getSimpleName());
            SetAlarmRequest request = new SetAlarmRequest(this, builder);
            request.setIndex(i);
            request.setEnabled(alarm.getEnabled());
            request.setDayOfWeek(alarm.getRepetition());
            request.setHour(alarm.getHour());
            request.setMinute(alarm.getMinute());
            request.perform();
            inProgressRequests.add(request);
            performConnected(builder.getTransaction());
        } catch (IOException e) {
            GB.toast(getContext(), "Failed to set alarm", Toast.LENGTH_SHORT, GB.ERROR, e);
        }
        ++i;
    }
}
Also used : Alarm(nodomain.freeyourgadget.gadgetbridge.model.Alarm) TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) IOException(java.io.IOException) SetAlarmRequest(nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetAlarmRequest)

Aggregations

IOException (java.io.IOException)1 Alarm (nodomain.freeyourgadget.gadgetbridge.model.Alarm)1 TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)1 SetAlarmRequest (nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetAlarmRequest)1