public void setImageResource(int resourceId) {
    if (resourceId == R.color.placeholder) {
      // ignore
    } else if (resourceId == R.color.error) {
      mInstrumentation.onFailure();
    } else {
      throw new IllegalArgumentException("Unrecognized resourceId");
    }
    super.setImageResource(resourceId);
  }
{@link NetworkImageView} that notifies its instance of {@link Instrumentation} whenever an image
request lifecycle event happens.
samples/comparison/src/main/java/com/facebook/samples/comparison/instrumentation/InstrumentedNetworkImageView.java