All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.voucherify.client.utils.Platform Maven / Gradle / Ivy

Go to download

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)

There is a newer version: 16.0.2
Show newest version
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