@Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   if (!isLoadingMore) {
     isLoadingMore = true;
     footerProgressBar.setVisibility(View.VISIBLE);
     refreshDelegate.startLoadMore();
   }
 }
  public void onRefreshStart() {
    headerRelativeLayout.setPadding(
        headerRelativeLayout.getPaddingLeft(),
        HEADER_TOP,
        0,
        headerRelativeLayout.getPaddingBottom());

    progressBar.setVisibility(View.VISIBLE);
    arrowImage.setVisibility(View.GONE);
    isLoading = true;

    if (refreshDelegate != null) {
      refreshDelegate.startFresh();
    }
  }
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    // TODO Auto-generated method stub
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        // isDragging = true;
        startY = ev.getY();
        if (topRowIndex > 1) {
          showRefreshButton = false;
        } else {
          showRefreshButton = true;
        }
        break;
      case MotionEvent.ACTION_MOVE:
        if (!isLoading && showRefreshButton) {
          deltaY = ev.getY() - startY;

          Log.d("debug", String.valueOf(deltaY));

          headerRelativeLayout.setPadding(
              headerRelativeLayout.getPaddingLeft(),
              -1 * HEADER_HEIGHT + (int) deltaY,
              0,
              headerRelativeLayout.getPaddingBottom());

          if (headerRelativeLayout.getPaddingTop() >= HEADER_HEIGHT
              && currentState == STATE_PULL_TO_REFRESH) {
            // change state
            currentState = STATE_RELEASE_TO_UPDATE;
            arrowImage.clearAnimation();
            arrowImage.startAnimation(rotateAnimation);
            headerTextView.setText(R.string.release_to_refresh);
          } else if (headerRelativeLayout.getPaddingTop() < HEADER_HEIGHT
              && currentState == STATE_RELEASE_TO_UPDATE) {
            currentState = STATE_PULL_TO_REFRESH;
            arrowImage.clearAnimation();
            arrowImage.startAnimation(reverseRotateAnimation);
            headerTextView.setText(R.string.pull_to_refresh);
          }
        }
        break;
      case MotionEvent.ACTION_UP:
        // isDragging = false;

        if (!isLoading && showRefreshButton) {
          if (headerRelativeLayout.getPaddingTop() < HEADER_HEIGHT) {
            // come back
            headerRelativeLayout.setPadding(
                headerRelativeLayout.getPaddingLeft(),
                -1 * HEADER_HEIGHT,
                0,
                headerRelativeLayout.getPaddingBottom());
          } else {
            // come to HEADER_HEIGHT and start the trigger
            headerRelativeLayout.setPadding(
                headerRelativeLayout.getPaddingLeft(),
                HEADER_TOP,
                0,
                headerRelativeLayout.getPaddingBottom());
            headerTextView.setText(R.string.loading);
            progressBar.setVisibility(View.VISIBLE);
            arrowImage.clearAnimation();
            arrowImage.setVisibility(View.GONE);

            // START LOADING
            isLoading = true;
            if (refreshDelegate != null) {
              refreshDelegate.startFresh();
            }
          }
        }
        break;
      default:
        break;
    }

    return super.onTouchEvent(ev);
  }