Search in sources :

Example 1 with RecyclerViewItemDecoration

use of com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration in project BBS-Android by bdpqchen.

the class CollectionActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSlideBackLayout.lock(!PrefUtil.isSlideBackMode());
    final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    collection_recyclerView.setLayoutManager(linearLayoutManager);
    collectionAdapter = new CollectionAdapter(this, collectionBean, collectionPresenter);
    collection_recyclerView.setAdapter(collectionAdapter);
    collection_recyclerView.addItemDecoration(new RecyclerViewItemDecoration(10));
    collectionPresenter.loadCollections();
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Example 2 with RecyclerViewItemDecoration

use of com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration in project BBS-Android by bdpqchen.

the class MyReplyFragment method initFragment.

@Override
protected void initFragment() {
    myReplyAdapter = new MyReplyAdapter(getActivity(), data);
    layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setHasFixedSize(true);
    rv.setLayoutManager(layoutManager);
    rv.setAdapter(myReplyAdapter);
    rv.addItemDecoration(new RecyclerViewItemDecoration(5));
    srl.setOnRefreshListener(this);
    srl.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
    eros = new EndlessRecyclerOnScrollListener(layoutManager) {

        @Override
        public void onLoadMore() {
            mPresenter.getMyReplyList();
        }
    };
    rv.addOnScrollListener(eros);
    mPresenter.initMyReplyList();
}
Also used : EndlessRecyclerOnScrollListener(com.twtstudio.bbs.bdpqchen.bbs.individual.my_release.EndlessRecyclerOnScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Example 3 with RecyclerViewItemDecoration

use of com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration in project BBS-Android by bdpqchen.

the class TopTenFragment method initFragment.

@Override
protected void initFragment() {
    mAdapter = new TopTenAdapter(getActivity());
    linearLayoutManager = new LinearLayoutManager(getActivity());
    recyclerview.setLayoutManager(linearLayoutManager);
    recyclerview.addItemDecoration(new RecyclerViewItemDecoration(5));
    recyclerview.setAdapter(mAdapter);
    layoutSwipeRefresh.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
    layoutSwipeRefresh.setOnRefreshListener(() -> {
        mPresenter.getHomeDataList();
        mRefreshing = true;
        layoutSwipeRefresh.setRefreshing(true);
    });
    mPresenter.getHomeDataList();
    LogUtil.d("top ten init ");
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Example 4 with RecyclerViewItemDecoration

use of com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration in project BBS-Android by bdpqchen.

the class ThreadActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    mThreadId = intent.getIntExtra(INTENT_THREAD_ID, 0);
    mThreadFloor = intent.getIntExtra(INTENT_THREAD_FLOOR, 1);
    mThreadTitle = intent.getStringExtra(INTENT_THREAD_TITLE);
    super.onCreate(savedInstanceState);
    mSlideBackLayout.lock(!PrefUtil.isSlideBackMode());
    mContext = this;
    mPresenter.getThread(mThreadId, 0);
    mAdapter = new PostAdapter(mContext);
    mLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
    mRvThreadPost.addItemDecoration(new RecyclerViewItemDecoration(5));
    mRvThreadPost.setLayoutManager(mLayoutManager);
    mRvThreadPost.setAdapter(mAdapter);
    mRvThreadPost.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItemPosition + 1 == mAdapter.getItemCount()) {
                if (!mEnding) {
                    mPage++;
                    mIsLoadingMore = true;
                    mPresenter.getThread(mThreadId, mPage);
                }
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            lastVisibleItemPosition = mLayoutManager.findLastVisibleItemPosition();
        }
    });
    mFbThreadWritePost.setOnClickListener(v -> {
        showCommentInput();
        resetReply();
    });
    mEtComment.addTextChangedListener(new TextWatcher() {

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

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mEtComment != null && mEtComment.getText().toString().length() > 0) {
                mIvCommentOut.setVisibility(View.GONE);
                mIvCommentSend.setVisibility(View.VISIBLE);
            } else {
                mIvCommentOut.setVisibility(View.VISIBLE);
                mIvCommentSend.setVisibility(View.GONE);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mIvCommentOut.setOnClickListener(v -> showFab());
    mIvCommentSend.setOnClickListener(v -> sendComment(mReplyId));
    mIvStaredThread.setOnClickListener(v -> {
        if (PrefUtil.hadLogin()) {
            mPresenter.unStarThread(mThreadId);
        }
    });
    mIvStarThread.setOnClickListener(v -> {
        if (PrefUtil.hadLogin()) {
            mPresenter.starThread(mThreadId);
        }
    });
    mSrlThreadList.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
    mSrlThreadList.setOnRefreshListener(() -> {
        mRefreshing = true;
        mPage = 0;
        mPresenter.getThread(mThreadId, mPage);
    });
    mAdapter.setOnItemClickListener((view, position) -> {
        postPosition = position;
        mReplyId = mAdapter.getPostId(position);
        showCommentInput();
    });
    mCbAnonymousComment.setOnCheckedChangeListener((buttonView, isChecked) -> {
        mIsAnonymous = isChecked;
    });
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Example 5 with RecyclerViewItemDecoration

use of com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration in project BBS-Android by bdpqchen.

the class ThreadListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    mBoardId = intent.getIntExtra(INTENT_BOARD_ID, 0);
    mThreadTitle = intent.getStringExtra(INTENT_BOARD_TITLE);
    LogUtil.dd(mThreadTitle);
    super.onCreate(savedInstanceState);
    mToolbar.setTitle(mThreadTitle);
    mContext = this;
    mSlideBackLayout.lock(!PrefUtil.isSlideBackMode());
    mPresenter.getThreadList(mBoardId, mPage);
    mAdapter = new ThreadListAdapter(this);
    mAdapter.setShowFooter(true);
    mLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.addItemDecoration(new RecyclerViewItemDecoration(10));
    mSrlThreadList.setRefreshing(true);
    mSrlThreadList.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
    mSrlThreadList.setOnRefreshListener(() -> {
        mRefreshing = true;
        mPresenter.getThreadList(mBoardId, 0);
    });
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItemPosition + 1 == mAdapter.getItemCount()) {
                mPage++;
                mPresenter.getThreadList(mBoardId, mPage);
                mIsLoadingMore = true;
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            lastVisibleItemPosition = mLayoutManager.findLastVisibleItemPosition();
        }
    });
}
Also used : Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewItemDecoration(com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 RecyclerViewItemDecoration (com.twtstudio.bbs.bdpqchen.bbs.commons.helper.RecyclerViewItemDecoration)9 Intent (android.content.Intent)3 RecyclerView (android.support.v7.widget.RecyclerView)2 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 EndlessRecyclerOnScrollListener (com.twtstudio.bbs.bdpqchen.bbs.individual.my_release.EndlessRecyclerOnScrollListener)1