io.voucherify.client.utils.Platform Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of voucherify-java-sdk Show documentation
Show all versions of voucherify-java-sdk Show documentation
Voucherify-java-sdk is a Java client (can be used in Android application as well) which was created to simplify integration with Voucherify backend (http://www.voucherify.io)
package io.voucherify.client.utils;
import retrofit.android.MainThreadExecutor;
import java.util.concurrent.Executor;
public abstract class Platform {
private static final Platform PLATFORM = findPlatform();
public static Platform get() {
return PLATFORM;
}
private static Platform findPlatform() {
try {
Class.forName("android.os.Build");
return new Android();
} catch (ClassNotFoundException ignored) {
}
return new Base();
}
public abstract Executor callbackExecutor();
private static class Base extends Platform {
@Override
public Executor callbackExecutor() {
return new SynchronousExecutor();
}
}
private static class Android extends Platform {
@Override
public Executor callbackExecutor() {
return new MainThreadExecutor();
}
}
static class SynchronousExecutor implements Executor {
@Override
public void execute(Runnable runnable) {
runnable.run();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy