Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ public static <T> T execute(ExecutesMethod executesMethod, String command) {
}

private static <T> T handleResponse(Response response) {
if (response != null) {
return (T) response.getValue();
}
return null;
//noinspection unchecked
return response == null ? null : (T) response.getValue();
}

public static <T> T executeScript(ExecutesMethod executesMethod, String scriptName) {
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/io/appium/java_client/HasDeviceTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@

package io.appium.java_client;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.Response;

import java.util.Map;

import static io.appium.java_client.MobileCommand.GET_DEVICE_TIME;

public interface HasDeviceTime extends ExecutesMethod {

Expand All @@ -38,12 +31,9 @@ public interface HasDeviceTime extends ExecutesMethod {
* @return Device time string
*/
default String getDeviceTime(String format) {
Map<String, ?> params = ImmutableMap.of(
"script", "mobile: getDeviceTime",
"args", ImmutableList.of(ImmutableMap.of("format", format))
return CommandExecutionHelper.executeScript(
this, "mobile: getDeviceTime", ImmutableMap.of("format", format)
);
Response response = execute(DriverCommand.EXECUTE_SCRIPT, params);
return response.getValue().toString();
}

/**
Expand All @@ -53,7 +43,6 @@ default String getDeviceTime(String format) {
* @return Device time string
*/
default String getDeviceTime() {
Response response = execute(GET_DEVICE_TIME);
return response.getValue().toString();
return CommandExecutionHelper.executeScript(this, "mobile: getDeviceTime");
}
}