protected LoadingLayout createLoadingLayout(Context context, Mode mode, TypedArray attrs) {
   LoadingLayout layout =
       mLoadingAnimationStyle.createLoadingLayout(
           context, mode, getPullToRefreshScrollDirection(), attrs);
   layout.setVisibility(View.INVISIBLE);
   return layout;
 }
  /**
   * Helper method which just calls scrollTo() in the correct scrolling direction.
   *
   * @param value - New Scroll value
   */
  protected final void setHeaderScroll(int value) {
    if (DEBUG) {
      Log.d(LOG_TAG, "setHeaderScroll: " + value);
    }

    // Clamp value to with pull scroll range
    final int maximumPullScroll = getMaximumPullScroll();
    value = Math.min(maximumPullScroll, Math.max(-maximumPullScroll, value));

    if (mLayoutVisibilityChangesEnabled) {
      if (value < 0) {
        mHeaderLayout.setVisibility(View.VISIBLE);
      } else if (value > 0) {
        mFooterLayout.setVisibility(View.VISIBLE);
      } else {
        mHeaderLayout.setVisibility(View.INVISIBLE);
        mFooterLayout.setVisibility(View.INVISIBLE);
      }
    }

    if (USE_HW_LAYERS) {
      /**
       * Use a Hardware Layer on the Refreshable View if we've scrolled at all. We don't use them on
       * the Header/Footer Views as they change often, which would negate any HW layer performance
       * boost.
       */
      ViewCompat.setLayerType(
          mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE);
    }

    switch (getPullToRefreshScrollDirection()) {
      case VERTICAL:
        scrollTo(0, value);
        break;
      case HORIZONTAL:
        scrollTo(value, 0);
        break;
    }
  }