示例#1
0
  @Override
  protected final void onSizeChanged(int w, int h, int oldw, int oldh) {
    if (DEBUG) {
      Log.d(LOG_TAG, String.format("onSizeChanged. W: %d, H: %d", w, h));
    }

    super.onSizeChanged(w, h, oldw, oldh);

    // We need to update the header/footer when our size changes
    refreshLoadingViewsSize();

    // Update the Refreshable View layout
    refreshRefreshableViewSize(w, h);

    /**
     * As we're currently in a Layout Pass, we need to schedule another one to layout any changes
     * we've made here
     */
    post(
        new Runnable() {
          @Override
          public void run() {
            requestLayout();
          }
        });
  }
示例#2
0
  /**
   * Updates the View State when the mode has been set. This does not do any checking that the mode
   * is different to current state so always updates.
   */
  protected void updateUIForMode() {
    // We need to use the correct LayoutParam values, based on scroll
    // direction
    final LayoutParams lp = getLoadingLayoutLayoutParams();

    // Remove Header, and then add Header Loading View again if needed
    if (this == mHeaderLayout.getParent()) {
      removeView(mHeaderLayout);
    }
    if (mMode.showHeaderLoadingLayout()) {
      addViewInternal(mHeaderLayout, 0, lp);
    }

    // Remove Footer, and then add Footer Loading View again if needed
    if (this == mFooterLayout.getParent()) {
      removeView(mFooterLayout);
    }
    if (mMode.showFooterLoadingLayout()) {
      addViewInternal(mFooterLayout, lp);
    }

    // Hide Loading Views
    refreshLoadingViewsSize();

    // If we're not using Mode.BOTH, set mCurrentMode to mMode, otherwise
    // set it to pull down
    mCurrentMode = (mMode != Mode.BOTH) ? mMode : Mode.PULL_FROM_START;
  }