Java Code Examples for com.eveningoutpost.dexdrip.Models.Calibration#byuuid()

The following examples show how to use com.eveningoutpost.dexdrip.Models.Calibration#byuuid() . 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: UndoRedo.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static boolean undoNextItem() {
    if (undoListHasItems()) {
        synchronized (queue_lock) {
            final int location = undo_queue.size() - 1;
            Undo_item item = undo_queue.get(location);
            if (item.Treatment_uuid != null) {
                try {
                    item.saved_data = Treatments.byuuid(item.Treatment_uuid).toJSON();
                    item.expires = JoH.ts() + EXPIRY_TIME;
                    redo_queue.add(item);
                    undo_queue.remove(location);
                    Treatments.delete_by_uuid(item.Treatment_uuid,true);
                } catch (NullPointerException e) {
                    UserError.Log.wtf(TAG, "Null pointer exception in undoNext()");
                    undo_queue.remove(location);
                }
                return true;
            } else if (item.Calibration_uuid != null) {
                // TODO try catch
                Calibration calibration = Calibration.byuuid(item.Calibration_uuid);
                if(calibration != null) {
                    item.saved_data = calibration.toS();
                    item.expires = JoH.ts() + EXPIRY_TIME;
                    redo_queue.add(item);
                    undo_queue.remove(location);
                    Calibration.clear_byuuid(item.Calibration_uuid, true); // from interactive
                    return true;
                }
            }

        }
        return false;
    } else {
        return false;
    }

}
 
Example 2
Source File: UndoRedo.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static boolean undoNextItem() {
    if (undoListHasItems()) {
        synchronized (queue_lock) {
            final int location = undo_queue.size() - 1;
            Undo_item item = undo_queue.get(location);
            if (item.Treatment_uuid != null) {
                try {
                    item.saved_data = Treatments.byuuid(item.Treatment_uuid).toJSON();
                    item.expires = JoH.ts() + EXPIRY_TIME;
                    redo_queue.add(item);
                    undo_queue.remove(location);
                    Treatments.delete_by_uuid(item.Treatment_uuid,true);
                } catch (NullPointerException e) {
                    UserError.Log.wtf(TAG, "Null pointer exception in undoNext()");
                    undo_queue.remove(location);
                }
                return true;
            } else if (item.Calibration_uuid != null) {
                // TODO try catch
                Calibration calibration = Calibration.byuuid(item.Calibration_uuid);
                if(calibration != null) {
                    item.saved_data = calibration.toS();
                    item.expires = JoH.ts() + EXPIRY_TIME;
                    redo_queue.add(item);
                    undo_queue.remove(location);
                    Calibration.clear_byuuid(item.Calibration_uuid, true); // from interactive
                    return true;
                }
            }

        }
        return false;
    } else {
        return false;
    }

}