RuffyCommandsV1Impl: actually do delegation.

(cherry picked from commit 5e447ad)
This commit is contained in:
Johannes Mockenhaupt 2017-11-28 19:34:32 +01:00
parent dfcf0a7e2a
commit a6cba8b2d1
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 11 additions and 33 deletions

View file

@ -9,16 +9,21 @@ import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.BolusProgressReporter;
import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.RuffyCommands;
import de.jotomo.ruffy.spi.history.PumpHistory;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
public class RuffyCommandsV1Impl implements RuffyCommands {
private static RuffyCommandsV1Impl instance;
private static RuffyCommands delegate;
@NonNull
public static RuffyCommands getInstance(Context context) {
if (delegate == null) delegate = new RuffyScripter(context);
return delegate;
if (instance == null) {
instance = new RuffyCommandsV1Impl();
delegate = new RuffyScripter(context);
}
return instance;
}
private RuffyCommandsV1Impl() {}
@ -85,19 +90,17 @@ public class RuffyCommandsV1Impl implements RuffyCommands {
@Override
public CommandResult readHistory(PumpHistoryRequest request) {
return delegate.readHistory(request);
return delegate.readPumpState().history(new PumpHistory());
}
/** Not supported by RuffyScripter */
@Override
public CommandResult readBasalProfile() {
return new CommandResult().success(false);
return delegate.readBasalProfile();
}
/** Not supported by RuffyScripter */
@Override
public CommandResult setBasalProfile(BasalProfile basalProfile) {
return new CommandResult().success(false);
return delegate.setBasalProfile(basalProfile);
}
/** Not supported by RuffyScripter */

View file

@ -43,7 +43,6 @@ import de.jotomo.ruffyscripter.commands.ReadHistoryCommand;
import de.jotomo.ruffyscripter.commands.ReadPumpStateCommand;
import de.jotomo.ruffyscripter.commands.ReadReservoirLevelAndLastBolus;
import de.jotomo.ruffyscripter.commands.SetBasalProfileCommand;
import de.jotomo.ruffyscripter.commands.SetDateAndTimeCommand;
import de.jotomo.ruffyscripter.commands.SetTbrCommand;
/**
@ -793,7 +792,7 @@ public class RuffyScripter implements RuffyCommands {
@Override
public CommandResult setDateAndTime() {
return runCommand(new SetDateAndTimeCommand());
throw new RuntimeException("Not supported");
}
@Override

View file

@ -1,24 +0,0 @@
package de.jotomo.ruffyscripter.commands;
import android.os.SystemClock;
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
import de.jotomo.ruffy.spi.CommandResult;
public class SetDateAndTimeCommand extends BaseCommand {
@Override
public void execute() {
throw new RuntimeException("Not implemented yet");
/* scripter.navigateToMenu(MenuType.DATE_AND_TIME_MENU);
scripter.pressCheckKey();
// TODO ruffy does'n support date/time menu yet
result.success = true;
*/
}
@Override
public String toString() {
return "SetDateAndTimeCommand{}";
}
}