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

org.robolectric.shadows.ResourceModeShadowPicker Maven / Gradle / Ivy

package org.robolectric.shadows;

import android.os.Build;
import android.os.Build.VERSION_CODES;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadow.api.ShadowPicker;

public class ResourceModeShadowPicker implements ShadowPicker {

  private Class legacyShadowClass;
  private Class binaryShadowClass;
  private Class binary9ShadowClass;
  private Class binary10ShadowClass;
  private Class binary14ShadowClass;

  public ResourceModeShadowPicker(Class legacyShadowClass,
      Class binaryShadowClass,
      Class binary9ShadowClass) {
    this.legacyShadowClass = legacyShadowClass;
    this.binaryShadowClass = binaryShadowClass;
    this.binary9ShadowClass = binary9ShadowClass;
    this.binary10ShadowClass = binary9ShadowClass;
    this.binary14ShadowClass = binary9ShadowClass;
  }

  public ResourceModeShadowPicker(
      Class legacyShadowClass,
      Class binaryShadowClass,
      Class binary9ShadowClass,
      Class binary10ShadowClass,
      Class binary14ShadowClass) {
    this.legacyShadowClass = legacyShadowClass;
    this.binaryShadowClass = binaryShadowClass;
    this.binary9ShadowClass = binary9ShadowClass;
    this.binary10ShadowClass = binary10ShadowClass;
    this.binary14ShadowClass = binary14ShadowClass;
  }

  @Override
  public Class pickShadowClass() {
    if (ShadowAssetManager.useLegacy()) {
      return legacyShadowClass;
    } else {
      if (RuntimeEnvironment.getApiLevel() >= VERSION_CODES.CUR_DEVELOPMENT) {
        return binary14ShadowClass;
      } else if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.Q) {
        return binary10ShadowClass;
      } else if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.P) {
        return binary9ShadowClass;
      } else {
        return binaryShadowClass;
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy