Search in sources :

Example 1 with CommentListFragment

use of com.codez.collar.fragment.CommentListFragment in project Collar by CodeZsx.

the class StatusDetailActivity method initView.

@Override
public void initView() {
    setToolbarTitle(mBinding.toolbar, "微博正文");
    // 获取intent传递过来的bean
    mBean = (StatusBean) getIntent().getSerializableExtra(StatusBean.INTENT_SERIALIZABLE);
    isFromComment = getIntent().getBooleanExtra(INTENT_FROM_COMMENT, false);
    if (isFromComment) {
        mBinding.appbar.setExpanded(false);
    }
    mBinding.setStatus(mBean);
    // 微博正文
    mBinding.tvContent.setText(StatusContentTextUtil.getWeiBoContent(mBean.getText(), this, mBinding.tvContent));
    // 微博图片,根据无图片、多张图片进行不同的显示方式
    setStatusImage(mBinding.recyclerView, mBean.getPic_urls());
    // 转发微博体
    if (mBean.getRetweeted_status() == null) {
        mBinding.llRetweeted.setVisibility(View.GONE);
    } else {
        // 转发微博体的正文
        mBinding.retweetedContent.setText(StatusContentTextUtil.getWeiBoContent("@" + mBean.getRetweeted_status().getUser().getScreen_name() + ":" + mBean.getRetweeted_status().getText(), this, mBinding.retweetedContent));
        // 转发微博体的图片
        setStatusImage(mBinding.retweetedRecyclerView, mBean.getRetweeted_status().getPic_urls());
        mBinding.llRetweeted.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle mBundle = new Bundle();
                mBundle.putSerializable(StatusBean.INTENT_SERIALIZABLE, mBean);
                StatusDetailActivity.this.startActivity(new Intent(StatusDetailActivity.this, StatusDetailActivity.class).putExtras(mBundle));
            }
        });
    }
    // 设置评论和转发列表
    mBinding.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        String[] titles = { "评论 " + mBean.getComments_count(), "转发 " + mBean.getReposts_count() };

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return new CommentListFragment().newInstance(mBean.getId(), CommentListFragment.TYPE_COMMENT_STATUS_DETAIL);
            } else {
                return new RepostListFragment().newInstance(mBean.getId());
            }
        }

        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    });
    mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
    // 设置edittext
    mBinding.etContent.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 ("".equals(s.toString())) {
                mBinding.ivCommit.setSelected(false);
            } else {
                mBinding.ivCommit.setSelected(true);
            }
            mBinding.tvStatusLength.setText((COMMENT_MAX_LENGTH - s.length()) + "");
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mBinding.etContent.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                mBinding.rlAdditional.setVisibility(View.VISIBLE);
            } else {
                mBinding.rlAdditional.setVisibility(View.GONE);
            }
        }
    });
    mBinding.ivCommit.setOnClickListener(this);
    reloadData();
}
Also used : Bundle(android.os.Bundle) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) CommentListFragment(com.codez.collar.fragment.CommentListFragment) Intent(android.content.Intent) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Fragment(android.support.v4.app.Fragment) RepostListFragment(com.codez.collar.fragment.RepostListFragment) CommentListFragment(com.codez.collar.fragment.CommentListFragment) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RepostListFragment(com.codez.collar.fragment.RepostListFragment)

Example 2 with CommentListFragment

use of com.codez.collar.fragment.CommentListFragment in project Collar by CodeZsx.

the class CommentActivity method initView.

@Override
public void initView() {
    setToolbarTitle(mBinding.toolbar, "评论");
    mBinding.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        String[] titles = { "收到的评论", "发出的评论" };

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return new CommentListFragment().newInstance(null, CommentListFragment.TYPE_COMMENT_TO_ME);
            } else {
                return new CommentListFragment().newInstance(null, CommentListFragment.TYPE_COMMENT_BY_ME);
            }
        }

        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    });
    mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) CommentListFragment(com.codez.collar.fragment.CommentListFragment) Fragment(android.support.v4.app.Fragment) CommentListFragment(com.codez.collar.fragment.CommentListFragment)

Example 3 with CommentListFragment

use of com.codez.collar.fragment.CommentListFragment in project Collar by CodeZsx.

the class MentionActivity method initView.

@Override
public void initView() {
    setToolbarTitle(mBinding.toolbar, "@我的");
    mBinding.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        String[] titles = { "微博", "评论" };

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return new StatusListFragment().newInstance(null, null, StatusListFragment.VALUE_MENTION);
            } else {
                return new CommentListFragment().newInstance(null, CommentListFragment.TYPE_COMMENT_MENTION);
            }
        }

        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    });
    mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) StatusListFragment(com.codez.collar.fragment.StatusListFragment) CommentListFragment(com.codez.collar.fragment.CommentListFragment) Fragment(android.support.v4.app.Fragment) CommentListFragment(com.codez.collar.fragment.CommentListFragment) StatusListFragment(com.codez.collar.fragment.StatusListFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)3 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)3 CommentListFragment (com.codez.collar.fragment.CommentListFragment)3 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 RepostListFragment (com.codez.collar.fragment.RepostListFragment)1 StatusListFragment (com.codez.collar.fragment.StatusListFragment)1