Search in sources :

Example 1 with StatusListFragment

use of com.codez.collar.fragment.StatusListFragment 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)

Example 2 with StatusListFragment

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

the class UserActivity method initView.

@Override
public void initView() {
    setSupportActionBar(mBinding.toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        mBinding.toolbar.setNavigationIcon(R.drawable.ic_toolbar_back);
        mBinding.toolbar.setNavigationOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
    uid = getIntent().getStringExtra(INTENT_KEY_UID);
    screen_name = getIntent().getStringExtra(INTENT_KEY_SCREEN_NAME);
    L.e("uid:" + uid + " screen_name:" + screen_name);
    if (uid != null && uid.equals(AccessTokenKeeper.getInstance().getUid())) {
        mBinding.btnFollow.setVisibility(View.GONE);
    } else {
        // 获取登录用户和此用户的关系
        HttpUtils.getInstance().getFriendshipService().showFriendships(AccessTokenKeeper.getInstance().getUid(), uid).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<FriendshipsShowResultBean>() {

            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
            }

            @Override
            public void onNext(FriendshipsShowResultBean friendshipsShowResultBean) {
                if (friendshipsShowResultBean.getSource().isFollowing()) {
                    if (friendshipsShowResultBean.getSource().isFollowed_by()) {
                        mBinding.btnFollow.setText(BTN_BOTH_SIDE);
                        isFollowMe = true;
                    } else {
                        mBinding.btnFollow.setText(BTN_FOLLOWING);
                    }
                    // selected标志位即为是否关注的标志位
                    mBinding.btnFollow.setSelected(true);
                }
            }
        });
    }
    // 获取用户信息
    HttpUtils.getInstance().getUserService().getUserInfo(uid, screen_name).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<UserBean>() {

        @Override
        public void onCompleted() {
            L.e("onCompleted");
        }

        @Override
        public void onError(Throwable e) {
            L.e("onError");
        }

        @Override
        public void onNext(UserBean userBean) {
            L.e("onNext");
            mUserBean = userBean;
            mBinding.setUser(userBean);
        }
    });
    mBinding.appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (verticalOffset == 0) {
            // 展开状态
            } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
                // 折叠状态
                mBinding.collapsingToolbar.setTitleEnabled(true);
                mBinding.toolbar.setBackgroundResource(R.color.colorToolbarBg);
            } else {
                // 中间状态
                mBinding.collapsingToolbar.setTitleEnabled(false);
                mBinding.toolbar.setBackgroundColor(0x00000000);
            }
        }
    });
    mBinding.viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        String[] titles = { "微博", "相册" };

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return new StatusListFragment().newInstance(uid, screen_name, StatusListFragment.VALUE_USER);
            } else {
                return new UserAlbumFragment().newInstance(uid, screen_name);
            }
        }

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

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    });
    mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
    mBinding.tvFriends.setOnClickListener(this);
    mBinding.tvFriendsCount.setOnClickListener(this);
    mBinding.tvFollowers.setOnClickListener(this);
    mBinding.tvFollowersCount.setOnClickListener(this);
    mBinding.btnFollow.setOnClickListener(this);
}
Also used : UserAlbumFragment(com.codez.collar.fragment.UserAlbumFragment) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) View(android.view.View) Fragment(android.support.v4.app.Fragment) StatusListFragment(com.codez.collar.fragment.StatusListFragment) UserAlbumFragment(com.codez.collar.fragment.UserAlbumFragment) UserBean(com.codez.collar.bean.UserBean) StatusListFragment(com.codez.collar.fragment.StatusListFragment) FriendshipsShowResultBean(com.codez.collar.bean.FriendshipsShowResultBean) AppBarLayout(android.support.design.widget.AppBarLayout) ActionBar(android.support.v7.app.ActionBar)

Aggregations

Fragment (android.support.v4.app.Fragment)2 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)2 StatusListFragment (com.codez.collar.fragment.StatusListFragment)2 AppBarLayout (android.support.design.widget.AppBarLayout)1 ActionBar (android.support.v7.app.ActionBar)1 View (android.view.View)1 FriendshipsShowResultBean (com.codez.collar.bean.FriendshipsShowResultBean)1 UserBean (com.codez.collar.bean.UserBean)1 CommentListFragment (com.codez.collar.fragment.CommentListFragment)1 UserAlbumFragment (com.codez.collar.fragment.UserAlbumFragment)1