Search in sources :

Example 6 with BaseQuickAdapter

use of com.chad.library.adapter.base.BaseQuickAdapter in project BaseRecyclerViewAdapterHelper by CymChad.

the class PullToRefreshUseActivity method initAdapter.

private void initAdapter() {
    pullToRefreshAdapter = new PullToRefreshAdapter();
    pullToRefreshAdapter.setOnLoadMoreListener(this, mRecyclerView);
    pullToRefreshAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
    //        pullToRefreshAdapter.setAutoLoadMoreSize(3);
    mRecyclerView.setAdapter(pullToRefreshAdapter);
    mCurrentCounter = pullToRefreshAdapter.getData().size();
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {

        @Override
        public void onSimpleItemClick(final BaseQuickAdapter adapter, final View view, final int position) {
            Toast.makeText(PullToRefreshUseActivity.this, Integer.toString(position), Toast.LENGTH_LONG).show();
        }
    });
}
Also used : OnItemClickListener(com.chad.library.adapter.base.listener.OnItemClickListener) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) PullToRefreshAdapter(com.chad.baserecyclerviewadapterhelper.adapter.PullToRefreshAdapter) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CustomLoadMoreView(com.chad.baserecyclerviewadapterhelper.loadmore.CustomLoadMoreView) View(android.view.View)

Example 7 with BaseQuickAdapter

use of com.chad.library.adapter.base.BaseQuickAdapter in project BaseRecyclerViewAdapterHelper by CymChad.

the class SectionUseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_section_uer);
    setBackBtn();
    setTitle("Section Use");
    mRecyclerView = (RecyclerView) findViewById(R.id.rv_list);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    mData = DataServer.getSampleData();
    SectionAdapter sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, mData);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {

        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            MySection mySection = mData.get(position);
            if (mySection.isHeader)
                Toast.makeText(SectionUseActivity.this, mySection.header, Toast.LENGTH_LONG).show();
            else
                Toast.makeText(SectionUseActivity.this, mySection.t.getName(), Toast.LENGTH_LONG).show();
        }

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            Toast.makeText(SectionUseActivity.this, "onItemChildClick" + position, Toast.LENGTH_LONG).show();
        }
    });
    mRecyclerView.setAdapter(sectionAdapter);
}
Also used : MySection(com.chad.baserecyclerviewadapterhelper.entity.MySection) OnItemClickListener(com.chad.library.adapter.base.listener.OnItemClickListener) SectionAdapter(com.chad.baserecyclerviewadapterhelper.adapter.SectionAdapter) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 8 with BaseQuickAdapter

use of com.chad.library.adapter.base.BaseQuickAdapter in project BaseRecyclerViewAdapterHelper by CymChad.

the class AnimationUseActivity method initAdapter.

private void initAdapter() {
    mAnimationAdapter = new AnimationAdapter();
    mAnimationAdapter.openLoadAnimation();
    mAnimationAdapter.setNotDoAnimationCount(mFirstPageItemCount);
    mRecyclerView.addOnItemTouchListener(new OnItemChildClickListener() {

        @Override
        public void onSimpleItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            String content = null;
            Status status = (Status) adapter.getItem(position);
            switch(view.getId()) {
                case R.id.img:
                    content = "img:" + status.getUserAvatar();
                    Toast.makeText(AnimationUseActivity.this, content, Toast.LENGTH_LONG).show();
                    break;
                case R.id.tweetName:
                    content = "name:" + status.getUserName();
                    Toast.makeText(AnimationUseActivity.this, content, Toast.LENGTH_LONG).show();
                    break;
                case R.id.tweetText:
                    // you have set clickspan .so there should not solve any click event ,just empty
                    break;
            }
        }
    });
    mRecyclerView.setAdapter(mAnimationAdapter);
}
Also used : Status(com.chad.baserecyclerviewadapterhelper.entity.Status) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnItemChildClickListener(com.chad.library.adapter.base.listener.OnItemChildClickListener) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AnimationAdapter(com.chad.baserecyclerviewadapterhelper.adapter.AnimationAdapter)

Example 9 with BaseQuickAdapter

use of com.chad.library.adapter.base.BaseQuickAdapter in project BaseRecyclerViewAdapterHelper by CymChad.

the class HeaderAndFooterUseActivity method initAdapter.

private void initAdapter() {
    headerAndFooterAdapter = new HeaderAndFooterAdapter(PAGE_SIZE);
    headerAndFooterAdapter.openLoadAnimation();
    mRecyclerView.setAdapter(headerAndFooterAdapter);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {

        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            Toast.makeText(HeaderAndFooterUseActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show();
        }
    });
}
Also used : OnItemClickListener(com.chad.library.adapter.base.listener.OnItemClickListener) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) HeaderAndFooterAdapter(com.chad.baserecyclerviewadapterhelper.adapter.HeaderAndFooterAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) View(android.view.View)

Example 10 with BaseQuickAdapter

use of com.chad.library.adapter.base.BaseQuickAdapter in project BaseRecyclerViewAdapterHelper by CymChad.

the class SimpleClickListener method onInterceptTouchEvent.

@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
    if (recyclerView == null) {
        this.recyclerView = rv;
        this.baseQuickAdapter = (BaseQuickAdapter) recyclerView.getAdapter();
        mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
    } else if (recyclerView != rv) {
        this.recyclerView = rv;
        this.baseQuickAdapter = (BaseQuickAdapter) recyclerView.getAdapter();
        mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
    }
    if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
        if (mPressedView != null) {
            BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView);
            if (vh == null || !isHeaderOrFooterView(vh.getItemViewType())) {
                mPressedView.setPressed(false);
            }
        }
        mIsShowPress = false;
        mIsPrepressed = false;
    }
    return false;
}
Also used : BaseViewHolder(com.chad.library.adapter.base.BaseViewHolder) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat)

Aggregations

BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)11 RecyclerView (android.support.v7.widget.RecyclerView)10 View (android.view.View)10 OnItemClickListener (com.chad.library.adapter.base.listener.OnItemClickListener)6 Intent (android.content.Intent)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 ImageView (android.widget.ImageView)2 BindView (butterknife.BindView)2 BaseViewHolder (com.chad.library.adapter.base.BaseViewHolder)2 Canvas (android.graphics.Canvas)1 Paint (android.graphics.Paint)1 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 LayoutAnimationController (android.view.animation.LayoutAnimationController)1 TextView (android.widget.TextView)1 AnimationAdapter (com.chad.baserecyclerviewadapterhelper.adapter.AnimationAdapter)1 HeaderAndFooterAdapter (com.chad.baserecyclerviewadapterhelper.adapter.HeaderAndFooterAdapter)1 HomeAdapter (com.chad.baserecyclerviewadapterhelper.adapter.HomeAdapter)1 ItemDragAdapter (com.chad.baserecyclerviewadapterhelper.adapter.ItemDragAdapter)1