Search in sources :

Example 1 with SimpleUser

use of me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser in project Douya by DreaminginCodeZH.

the class ProfileActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(0, 0);
    // Calls ensureSubDecor().
    findViewById(android.R.id.content);
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        String userIdOrUid = intent.getStringExtra(EXTRA_USER_ID_OR_UID);
        SimpleUser simpleUser = intent.getParcelableExtra(EXTRA_SIMPLE_USER);
        User user = intent.getParcelableExtra(EXTRA_USER_INFO);
        mProfileFragment = ProfileFragment.newInstance(userIdOrUid, simpleUser, user);
        FragmentUtils.add(mProfileFragment, this, android.R.id.content);
    } else {
        mProfileFragment = FragmentUtils.findById(this, android.R.id.content);
    }
}
Also used : SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser) SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser) User(me.zhanghai.android.douya.network.api.info.apiv2.User) Intent(android.content.Intent)

Example 2 with SimpleUser

use of me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser in project Douya by DreaminginCodeZH.

the class BaseUserAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Context context = RecyclerViewUtils.getContext(holder);
    final SimpleUser user = getItem(position);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            context.startActivity(ProfileActivity.makeIntent(user, context));
        }
    });
    ImageUtils.loadAvatar(holder.avatarImage, user.avatar);
    holder.nameText.setText(user.name);
    //noinspection deprecation
    holder.descriptionText.setText(user.uid);
}
Also used : Context(android.content.Context) SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with SimpleUser

use of me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser in project Douya by DreaminginCodeZH.

the class ProfileFollowshipLayout method bind.

public void bind(final User userInfo, List<SimpleUser> followingList) {
    final Context context = getContext();
    OnClickListener viewFollowingListListener = new OnClickListener() {

        @Override
        public void onClick(View view) {
            context.startActivity(FollowingListActivity.makeIntent(userInfo.getIdOrUid(), context));
        }
    };
    mTitleText.setOnClickListener(viewFollowingListListener);
    mViewMoreText.setOnClickListener(viewFollowingListListener);
    int i = 0;
    for (final SimpleUser user : followingList) {
        if (i >= USER_COUNT_MAX) {
            break;
        }
        if (i >= mFollowingList.getChildCount()) {
            ViewUtils.inflateInto(R.layout.profile_user_item, mFollowingList);
        }
        View userLayout = mFollowingList.getChildAt(i);
        UserLayoutHolder holder = (UserLayoutHolder) userLayout.getTag();
        if (holder == null) {
            holder = new UserLayoutHolder(userLayout);
            userLayout.setTag(holder);
        }
        ImageUtils.loadAvatar(holder.avatarImage, user.avatar);
        holder.nameText.setText(user.name);
        userLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                context.startActivity(ProfileActivity.makeIntent(user, context));
            }
        });
        ++i;
    }
    ViewUtils.setVisibleOrGone(mFollowingList, i != 0);
    ViewUtils.setVisibleOrGone(mEmptyView, i == 0);
    if (userInfo.followingCount > i) {
        mViewMoreText.setText(context.getString(R.string.view_more_with_count_format, userInfo.followingCount));
    } else {
        mViewMoreText.setVisibility(GONE);
    }
    for (int count = mFollowingList.getChildCount(); i < count; ++i) {
        ViewUtils.setVisibleOrGone(mFollowingList.getChildAt(i), false);
    }
    if (userInfo.followerCount > 0) {
        mFollwerText.setText(context.getString(R.string.profile_follower_count_format, userInfo.followerCount));
        mFollwerText.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                context.startActivity(FollowerListActivity.makeIntent(userInfo.getIdOrUid(), context));
            }
        });
    } else {
        mFollwerText.setVisibility(GONE);
    }
}
Also used : Context(android.content.Context) SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) FriendlyCardView(me.zhanghai.android.douya.ui.FriendlyCardView)

Example 4 with SimpleUser

use of me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser in project Douya by DreaminginCodeZH.

the class AccountUserResource method setArguments.

protected AccountUserResource setArguments(Account account) {
    SimpleUser partialUser = makePartialUser(account);
    super.setArguments(partialUser.getIdOrUid(), partialUser, AccountUtils.getUser(account));
    FragmentUtils.ensureArguments(this).putParcelable(EXTRA_ACCOUNT, account);
    return this;
}
Also used : SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)

Example 5 with SimpleUser

use of me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser in project Douya by DreaminginCodeZH.

the class AccountUserResource method makePartialUser.

private SimpleUser makePartialUser(Account account) {
    SimpleUser partialUser = new SimpleUser();
    //noinspection deprecation
    partialUser.id = AccountUtils.getUserId(account);
    //noinspection deprecation
    partialUser.uid = String.valueOf(partialUser.id);
    partialUser.name = AccountUtils.getUserName(account);
    return partialUser;
}
Also used : SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)

Aggregations

SimpleUser (me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)7 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 BindView (butterknife.BindView)3 Context (android.content.Context)2 Intent (android.content.Intent)2 User (me.zhanghai.android.douya.network.api.info.apiv2.User)2 RecyclerView (android.support.v7.widget.RecyclerView)1 FriendlyCardView (me.zhanghai.android.douya.ui.FriendlyCardView)1