示例#1
0
  public PtrFrameLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mPtrIndicator = new PtrIndicator();

    TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.PtrFrameLayout, 0, 0);
    if (arr != null) {

      mHeaderId = arr.getResourceId(R.styleable.PtrFrameLayout_ptr_header, mHeaderId);
      mContainerId = arr.getResourceId(R.styleable.PtrFrameLayout_ptr_content, mContainerId);

      mPtrIndicator.setResistance(
          arr.getFloat(R.styleable.PtrFrameLayout_ptr_resistance, mPtrIndicator.getResistance()));

      mDurationToClose =
          arr.getInt(R.styleable.PtrFrameLayout_ptr_duration_to_close, mDurationToClose);
      mDurationToCloseHeader =
          arr.getInt(
              R.styleable.PtrFrameLayout_ptr_duration_to_close_header, mDurationToCloseHeader);

      float ratio = mPtrIndicator.getRatioOfHeaderToHeightRefresh();
      ratio = arr.getFloat(R.styleable.PtrFrameLayout_ptr_ratio_of_header_height_to_refresh, ratio);
      mPtrIndicator.setRatioOfHeaderHeightToRefresh(ratio);

      mKeepHeaderWhenRefresh =
          arr.getBoolean(
              R.styleable.PtrFrameLayout_ptr_keep_header_when_refresh, mKeepHeaderWhenRefresh);

      mPullToRefresh = arr.getBoolean(R.styleable.PtrFrameLayout_ptr_pull_to_fresh, mPullToRefresh);
      arr.recycle();
    }

    mScrollChecker = new ScrollChecker();

    final ViewConfiguration conf = ViewConfiguration.get(getContext());
    mPagingTouchSlop = conf.getScaledTouchSlop() * 2;
  }
示例#2
0
 public void setResistance(float resistance) {
   mPtrIndicator.setResistance(resistance);
 }