Search in sources :

Example 1 with SearchUserAdapter

use of com.rideread.rideread.common.adapter.SearchUserAdapter in project ride-read-android by Ride-Read.

the class SearchActivity method initView.

@Override
public void initView() {
    mSearchUsers = new ArrayList<>();
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        search();
    });
    mRecycleView.setHasFixedSize(true);
    mAdapter = new SearchUserAdapter(this, mSearchUsers);
    mRecycleView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecycleView.setLayoutManager(mLayoutManager);
    mRecycleView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
            int totalItemCount = mLayoutManager.getItemCount();
            if (lastVisibleItem >= totalItemCount - 1 && dy > 0) {
                if (!isLoadingMore) {
                    search();
                }
            }
        }
    });
    mEdtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence keyword, int start, int before, int count) {
            search();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : SearchUserAdapter(com.rideread.rideread.common.adapter.SearchUserAdapter) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 SearchUserAdapter (com.rideread.rideread.common.adapter.SearchUserAdapter)1