huxq17 / XRefreshView

一个万能的android下拉上拉刷新的框架,完美支持recyclerview
1.7k stars 501 forks source link

上拉加载自定义布局实现IFooterCallBack,有些方法不执行 #91

Closed darkcgd closed 7 years ago

darkcgd commented 7 years ago

上拉加载自定义布局实现IFooterCallBack,有些方法不回调,例如callWhenNotAutoLoadMore().onStateReady(),onReleaseToLoadMore()

以下是我上拉加载自定义布局的代码 public class LoadDataFootView extends LinearLayout implements IFooterCallBack { private ImageView imgAnim; AnimationDrawable drawable; private TextView move; private View view;

private boolean showing = true;
public LoadDataFootView(Context context) {
    super(context);
    setBackgroundColor(Color.parseColor("#f3f3f3"));
    initView(context);
}

/**
 * @param context
 * @param attrs
 */
public LoadDataFootView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setBackgroundColor(Color.parseColor("#f3f3f3"));
    initView(context);
}

private void initView(Context context) {
    view = LayoutInflater.from(context).inflate(R.layout.load_foot_tip_view, this);
    imgAnim = (ImageView) findViewById(R.id.refresh);
    drawable = (AnimationDrawable) imgAnim.getDrawable();
    move = (TextView) findViewById(R.id.handler_move);
}

@Override
public void show(boolean show) {
    if (show == showing) {
        return;
    }
    showing = show;
    LayoutParams lp = (LayoutParams) view.getLayoutParams();
    lp.height = show ? LayoutParams.WRAP_CONTENT : 0;
    view.setLayoutParams(lp);
}

@Override
public void callWhenNotAutoLoadMore(final XRefreshView xRefreshView) {
    move.setText("点击加载更多");
    move.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            xRefreshView.notifyLoadMore();
        }
    });
}

@Override
public void onStateReady() {
    move.setText("松开加载更多");
    drawable.start();
}

@Override
public void onStateRefreshing() {
    move.setText("正在加载...");
    drawable.start();
    show(true);
}

@Override
public void onReleaseToLoadMore() {
    move.setText("松开加载更多");
    drawable.start();
}

@Override
public void onStateFinish(boolean success) {
    drawable.stop();
}

@Override
public void onStateComplete() {
    //setVisibility(View.GONE);
    AbToastUtil.showToast("onStateComplete");
}

@Override
public boolean isShowing() {
    return showing;
}

@Override
public int getFooterHeight() {
    return getMeasuredHeight();
}

}

我用的是 xRefreshview.setCustomFooterView(new LoadDataFootView(getActivity()));

求解

huxq17 commented 7 years ago

see #93