com.umeng.comm.ui.adapters.viewholders.FeedItemViewHolder.java Source code

Java tutorial

Introduction

Here is the source code for com.umeng.comm.ui.adapters.viewholders.FeedItemViewHolder.java

Source

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2015 Umeng, Inc
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.umeng.comm.ui.adapters.viewholders;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewStub;
import android.view.animation.ScaleAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.umeng.comm.core.beans.CommUser;
import com.umeng.comm.core.beans.FeedItem;
import com.umeng.comm.core.beans.ImageItem;
import com.umeng.comm.core.beans.Like;
import com.umeng.comm.core.beans.ShareContent;
import com.umeng.comm.core.beans.Topic;
import com.umeng.comm.core.constants.Constants;
import com.umeng.comm.core.db.ctrl.impl.DatabaseAPI;
import com.umeng.comm.core.imageloader.ImgDisplayOption;
import com.umeng.comm.core.listener.Listeners;
import com.umeng.comm.core.listeners.Listeners.OnItemViewClickListener;
import com.umeng.comm.core.listeners.Listeners.OnResultListener;
import com.umeng.comm.core.sdkmanager.ShareSDKManager;
import com.umeng.comm.core.utils.CommonUtils;
import com.umeng.comm.core.utils.ResFinder;
import com.umeng.comm.core.utils.ResFinder.ResType;
import com.umeng.comm.core.utils.TimeUtils;
import com.umeng.comm.ui.activities.LocationFeedActivity;
import com.umeng.comm.ui.activities.TopicDetailActivity;
import com.umeng.comm.ui.activities.UserInfoActivity;
import com.umeng.comm.ui.presenter.impl.FeedContentPresenter;
import com.umeng.common.ui.adapters.FeedImageAdapter;
import com.umeng.common.ui.adapters.viewholders.ViewHolder;
import com.umeng.common.ui.colortheme.ColorQueque;
import com.umeng.common.ui.dialogs.FeedListActionDialog;
import com.umeng.common.ui.emoji.EmojiTextView;
import com.umeng.common.ui.listener.FrinendClickSpanListener;
import com.umeng.common.ui.listener.TopicClickSpanListener;
import com.umeng.common.ui.mvpview.MvpFeedDetailActivityView;
import com.umeng.common.ui.mvpview.MvpLikeView;
import com.umeng.common.ui.presenter.impl.LikePresenter;
import com.umeng.common.ui.util.FeedViewRender;
import com.umeng.common.ui.util.UserTypeUtil;
import com.umeng.common.ui.util.ViewFinder;
import com.umeng.common.ui.widgets.NetworkImageView;
import com.umeng.common.ui.widgets.RoundImageView;
import com.umeng.common.ui.widgets.WrapperGridView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * ListViewFeed Item View?. ( ?, , ?. )
 */
public class FeedItemViewHolder extends ViewHolder implements MvpLikeView, MvpFeedDetailActivityView {
    private static final String M = "m";

    public ImageView mFeedTypeImgView;
    public RoundImageView mProfileImgView;
    public View mShareBtn;
    public TextView mUserNameTv;
    public EmojiTextView mFeedTextTv;
    public ImageView mLocationImgView;
    public TextView mLocationTv;
    public RelativeLayout mForwardLayout;
    public TextView mForwardTextTv;
    public ViewStub mImageGvViewStub;
    public WrapperGridView mImageGv;
    public View mButtomLayout;
    public TextView mTimeTv;
    public TextView mLikeCountTextView;
    public TextView mForwardCountTextView;
    public TextView mCommentCountTextView;
    public TextView mDistanceTextView;
    public RelativeLayout mfeedTypeContainer;
    public LinearLayout muserTypeContainer;
    private boolean isShowMedals = true;
    protected FeedItem mFeedItem;
    FeedListActionDialog mActionDialog;
    FeedContentPresenter mPresenter;
    LikePresenter mLikePresenter;

    private String mContainerClzName;

    private boolean mIsShowDistance = false;

    //    private boolean mOriginFeedContenIsEmpty;

    OnItemViewClickListener<FeedItem> mItemViewClickListener;

    private ArrayMap<String, FeedItem> mCacheArrayMap;

    public FeedItemViewHolder() {
    }

    public FeedItemViewHolder(ArrayMap arrayMap) {
        this.mCacheArrayMap = arrayMap;
    }

    public void setIsShowMedals(boolean isShowMedals) {
        this.isShowMedals = isShowMedals;
    }

    public FeedItemViewHolder(Context context, View rootView) {
        mContext = context;
        itemView = rootView;
        mViewFinder = new ViewFinder(rootView);
        mActionDialog = new FeedListActionDialog(context);
        initWidgets();
    }

    @Override
    protected int getItemLayout() {
        return ResFinder.getLayout("umeng_comm_feed_lv_item");
    }

    @Override
    protected void initWidgets() {
        inflateFromXML();
        initEventHandle();
        initPresenters();
    }

    protected void initPresenters() {
        mPresenter = new FeedContentPresenter();
        mPresenter.attach(mContext);
        mLikePresenter = new LikePresenter(this);
        mLikePresenter.attach(mContext);
        mLikePresenter.setFeedItem(mFeedItem);
    }

    public void setContainerClass(String clz) {
        mContainerClzName = clz;
    }

    protected void setupImageGridView() {
        if (mFeedItem.getImages() != null && mFeedItem.getImages().size() > 0) {
            showImageGridView();
        } else {
            hideImageGridView();
        }
    }

    public void showImageGridView() {
        // ?
        mForwardLayout.setVisibility(View.VISIBLE);
        if (mImageGvViewStub.getVisibility() == View.GONE) {
            mImageGvViewStub.setVisibility(View.VISIBLE);
            int imageGvResId = ResFinder.getId("umeng_comm_msg_gridview");
            mImageGv = (WrapperGridView) findViewById(imageGvResId);
            mImageGv.hasScrollBar = true;
        }

        mImageGv.setBackgroundColor(Color.TRANSPARENT);
        mImageGv.setVisibility(View.VISIBLE);
        // adapter
        FeedImageAdapter gridviewAdapter = new FeedImageAdapter(mContext);
        gridviewAdapter.addDatasOnly(mFeedItem.getImages());
        // 
        mImageGv.setAdapter(gridviewAdapter);
        // 
        mImageGv.updateColumns(3);

        // GridView
        mImageGv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
                mPresenter.jumpToImageBrowser(mFeedItem.getImages(), pos);
            }
        });
    }

    protected void hideImageGridView() {
        if (mImageGv != null) {
            mImageGv.setAdapter(new FeedImageAdapter(mContext));
            mImageGv.setVisibility(View.GONE);
        }
    }

    protected void inflateFromXML() {
        int feedTypeResId = ResFinder.getId("feed_type_img_btn");
        int userIconResId = ResFinder.getId("user_portrait_img_btn");
        int userNameResId = ResFinder.getId("umeng_comm_msg_user_name");
        int textResId = ResFinder.getId("umeng_comm_msg_text");
        int timeResId = ResFinder.getId("umeng_comm_msg_time_tv");
        int locResId = ResFinder.getId("umeng_comm_msg_location");
        int locTextResId = ResFinder.getId("umeng_comm_msg_location_text");
        int gvStubResId = ResFinder.getId("umeng_comm_msg_images_gv_viewstub");
        int forwardgvResId = ResFinder.getId("forward_image_gv_layout");
        int forwardTextResId = ResFinder.getId("umeng_comm_forard_text_tv");
        int distanceTextResId = ResFinder.getId("umeng_comm_distance");
        int feedTypeIconContainerId = ResFinder.getId("feed_type_icon_container");
        int userTypeIconContainerId = ResFinder.getId("user_type_icon_container");

        // ?feed
        mFeedTypeImgView = findViewById(feedTypeResId);
        mfeedTypeContainer = findViewById(feedTypeIconContainerId);
        muserTypeContainer = findViewById(userTypeIconContainerId);
        mFeedTypeImgView = findViewById(feedTypeResId);
        // ?
        mProfileImgView = findViewById(userIconResId);

        // ??
        mUserNameTv = findViewById(userNameResId);
        // 
        mFeedTextTv = findViewById(textResId);

        // feedtime????
        mButtomLayout = findViewById(ResFinder.getId("umeng_comm_feed_action_layout"));
        // 
        mTimeTv = findViewById(timeResId);

        // ?
        mLocationImgView = findViewById(locResId);
        // ??
        mLocationTv = findViewById(locTextResId);
        /**
         * ?View Stub
         */
        mImageGvViewStub = findViewById(gvStubResId);
        // ??, ????popupwindow
        // mOpetationBtn = findViewById(commentBtnResId);

        // ?textgv
        mForwardLayout = findViewById(forwardgvResId);
        // ?
        mForwardTextTv = findViewById(forwardTextResId);
        // ?feed?
        mShareBtn = findViewById(ResFinder.getId("umeng_comm_dialog_btn"));

        mLikeCountTextView = findViewById(ResFinder.getId("umeng_comm_like_tv"));
        mForwardCountTextView = findViewById(ResFinder.getId("umeng_comm_forward_tv"));
        mCommentCountTextView = findViewById(ResFinder.getId("umeng_comm_comment_tv"));
        mDistanceTextView = findViewById(distanceTextResId);
    }

    protected void initEventHandle() {
        mLikeCountTextView
                .setOnClickListener(new com.umeng.comm.core.listener.Listeners.LoginOnViewClickListener() {
                    @Override
                    protected void doAfterLogin(View v) {
                        clickAnima(mLikeCountTextView);
                        mLikePresenter.setFeedItem(mFeedItem);
                        if (mFeedItem.isLiked) {
                            mLikePresenter.postUnlike(mFeedItem.id);
                        } else {
                            mLikePresenter.postLike(mFeedItem.id);
                        }
                    }
                });

        // ?
        mForwardCountTextView
                .setOnClickListener(new com.umeng.comm.core.listener.Listeners.LoginOnViewClickListener() {

                    @Override
                    protected void doAfterLogin(View v) {
                        clickAnima(mForwardCountTextView);
                        mPresenter.gotoForwardActivity(mFeedItem);
                    }
                });

        mLocationImgView.setOnClickListener(mLocationClickListener);
        mLocationTv.setOnClickListener(mLocationClickListener);

    }

    /**
     * ??LocationFeedActivity?
     */
    private OnClickListener mLocationClickListener = new com.umeng.comm.core.listener.Listeners.LoginOnViewClickListener() {

        @Override
        protected void doAfterLogin(View v) {
            Intent intent = new Intent(mContext, LocationFeedActivity.class);
            intent.putExtra(Constants.FEED, mFeedItem);
            mContext.startActivity(intent);
        }
    };

    private void clickAnima(View targetView) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
        scaleAnimation.setDuration(100);
        targetView.startAnimation(scaleAnimation);
    }

    public void setShareActivity(final Activity activity) {
        mShareBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                //                shareToSns(activity);
                mActionDialog.show();
            }
        });
    }

    private void shareToSns(Activity activity) {
        ShareContent shareItem = new ShareContent();
        shareItem.mText = mFeedItem.text;
        List<ImageItem> imageItems = mFeedItem.imageUrls;
        if (mFeedItem.sourceFeed != null) {
            imageItems = mFeedItem.sourceFeed.imageUrls;
        }
        if (imageItems.size() > 0) {
            shareItem.mImageItem = imageItems.get(0);
        }
        shareItem.mTargetUrl = mFeedItem.shareLink;
        if (TextUtils.isEmpty(shareItem.mTargetUrl) && mFeedItem.sourceFeed != null) {
            shareItem.mTargetUrl = mFeedItem.sourceFeed.shareLink;
        }
        shareItem.mFeedId = mFeedItem.id;
        shareItem.mTitle = mFeedItem.text;
        ShareSDKManager.getInstance().getCurrentSDK().share(activity, shareItem);
    }

    /**
     * ??ListView??
     */
    protected void bindFeedItemData() {

        if (TextUtils.isEmpty(mFeedItem.id)) {
            return;
        }
        // ?
        setBaseFeeditemInfo();
        // 
        setupImageGridView();
        // feed
        // ?feed
        if (mFeedItem.sourceFeed != null) {
            // ?
            setForwardViewVisibility(mFeedItem);
            // ??
            setForwardItemData(mFeedItem);
        } else {
            // feeditem view??
            setCommFeedViewVisibility(mFeedItem);
        }

        String likeCount = CommonUtils.getLimitedCount(mFeedItem.likeCount);
        mLikeCountTextView.setText(likeCount);
        String commentCount = CommonUtils.getLimitedCount(mFeedItem.commentCount);
        mCommentCountTextView.setText(commentCount);
        String forwardCount = CommonUtils.getLimitedCount(mFeedItem.forwardCount);
        mForwardCountTextView.setText(forwardCount);
        like(mFeedItem.id, mFeedItem.isLiked);
    }

    /**
     * feed??
     *
     * @param item
     */
    private void setCommFeedViewVisibility(FeedItem item) {
        // ??
        mForwardLayout.setBackgroundColor(Color.TRANSPARENT);
        // mForwardLayout.setVisibility(View.GONE);
        mForwardLayout.setPadding(0, 0, 0, 0);
        if (mImageGv != null) {
            mImageGv.setPadding(0, 0, 0, 0);
        }
        // ???
        mForwardTextTv.setVisibility(View.GONE);

        // 
        mTimeTv.setVisibility(View.VISIBLE);
        // 
        mUserNameTv.setVisibility(View.VISIBLE);
        // ???
        mProfileImgView.setVisibility(View.VISIBLE);
    }

    /**
     * ??
     *
     * @param item ?feed item
     */
    private void setForwardItemData(FeedItem item) {
        // @feed
        //        atOriginFeedCreator(item.sourceFeed);
        // 2feed?
        if ((item.sourceFeed.status >= FeedItem.STATUS_SPAM && mFeedItem.status != FeedItem.STATUS_LOCK)
                || isDeleted(item.sourceFeed)) {
            mForwardTextTv.setGravity(Gravity.CENTER);
            mForwardTextTv.setText(ResFinder.getString("umeng_comm_feed_deleted"));
            if (mImageGv != null) {
                mImageGv.setVisibility(View.GONE);
            }
            // feed??feed?feed?feed?
            if (item.status >= FeedItem.STATUS_SPAM && item.sourceFeed.status >= FeedItem.STATUS_SPAM
                    && mFeedItem.status != FeedItem.STATUS_LOCK) {
                mForwardLayout.setVisibility(View.GONE);
            } else {
                // ?feed
                deleteInvalidateFeed(item.sourceFeed);
            }
        } else {
            mForwardTextTv.setGravity(Gravity.LEFT | Gravity.CENTER);

            String contextText = item.sourceFeed.text;
            // @?
            String atPrefix = "@" + item.sourceFeed.creator.name + ": ";
            if (TextUtils.isEmpty(contextText)) {
                contextText = ResFinder.getString("umeng_comm_forward_default_text");
            }
            contextText = atPrefix + contextText;

            List<CommUser> atFriends = new ArrayList<CommUser>(item.sourceFeed.atFriends);
            atFriends.add(item.sourceFeed.creator);

            // ??@?
            FeedViewRender.parseTopicsAndFriends(mForwardTextTv, contextText, atFriends, item.topics,
                    new TopicClickSpanListener() {
                        @Override
                        public void onClick(Topic topic) {
                            Intent intent = new Intent(mContext, TopicDetailActivity.class);
                            intent.putExtra(Constants.TAG_TOPIC, topic);
                            mContext.startActivity(intent);
                        }
                    }, new FrinendClickSpanListener() {
                        @Override
                        public void onClick(CommUser user) {
                            Intent intent = new Intent(mContext, UserInfoActivity.class);
                            intent.putExtra(Constants.TAG_USER, user);
                            mContext.startActivity(intent);
                        }
                    });
            if (mImageGv != null) {
                mImageGv.setVisibility(View.VISIBLE);
            }
        }
    }

    /**
     * @param feedItem
     */
    protected void deleteInvalidateFeed(FeedItem feedItem) {
        DatabaseAPI.getInstance().getFeedDBAPI().deleteFeedFromDB(feedItem.id);
    }

    /**
     * ?feed?@,??,?@?.
     *
     * @param feedItem
     */
    protected void atOriginFeedCreator(FeedItem feedItem) {
        String contextText = feedItem.text;
        // @?
        final String atPrefix = "@" + feedItem.creator.name + ": ";
        if (!contextText.contains(atPrefix)) {
            feedItem.text = atPrefix + contextText;
            feedItem.atFriends.add(feedItem.creator);
        }
    }

    /**
     * feed?[?]</br>
     *
     * @param item
     * @return
     */
    private boolean isDeleted(FeedItem item) {
        if (TextUtils.isEmpty(item.publishTime)) {
            return true;
        }
        return false;
    }

    /**
     * ?feed??
     */
    @SuppressWarnings("deprecation")
    private void setForwardViewVisibility(FeedItem item) {
        // ?
        mForwardLayout.setVisibility(View.VISIBLE);
        int padding = CommonUtils.dip2px(mContext, 6);
        mForwardLayout.setPadding(padding, padding, padding, padding);
        mForwardLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mPresenter.clickOriginFeedItem(mFeedItem);
            }
        });
        //        if (mImageGv != null) {
        //            mImageGv.setPadding(10, 2, 10, 10);
        //        }

        // ?
        //        mForwardLayout.setBackgroundDrawable(ResFinder
        //                .getDrawable("umeng_comm_forward_bg"));
        mForwardLayout.setBackgroundColor(ColorQueque.getColor("umeng_comm_feed_list_bg"));
        // ?
        mForwardTextTv.setVisibility(View.VISIBLE);
        mForwardTextTv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mPresenter.clickOriginFeedItem(mFeedItem);
            }
        });

        // ???
        mLocationImgView.setVisibility(View.GONE);
        mLocationTv.setVisibility(View.GONE);
    }

    /**
     * feedItem????</br>
     */
    protected void setBaseFeeditemInfo() {
        // feed
        setTypeIcon();
        setUserIcon();
        // ?
        setupUserIcon(mProfileImgView, mFeedItem.creator);
        // 
        mUserNameTv.setText(mFeedItem.creator.name);
        // 
        Date date = new Date(Long.parseLong(mFeedItem.publishTime));
        mTimeTv.setText(TimeUtils.format(date));
        // feed

        FeedItem temp = buildTempFeed();
        FeedViewRender.parseTopicsAndFriends(mFeedTextTv, temp, new TopicClickSpanListener() {
            @Override
            public void onClick(Topic topic) {
                Intent intent = new Intent(mContext, TopicDetailActivity.class);
                intent.putExtra(Constants.TAG_TOPIC, topic);
                mContext.startActivity(intent);
            }
        }, new FrinendClickSpanListener() {
            @Override
            public void onClick(CommUser user) {
                Intent intent = new Intent(mContext, UserInfoActivity.class);
                intent.putExtra(Constants.TAG_USER, user);
                mContext.startActivity(intent);
            }
        });

        // ???
        if (TextUtils.isEmpty(mFeedItem.locationAddr)) {
            mLocationTv.setVisibility(View.GONE);
            mLocationImgView.setVisibility(View.GONE);
        } else {
            mLocationTv.setVisibility(View.VISIBLE);
            mLocationImgView.setVisibility(View.VISIBLE);
            mLocationTv.setText(mFeedItem.locationAddr);
        }

        // Text??,??
        if (TextUtils.isEmpty(mFeedItem.text)) {
            mFeedTextTv.setVisibility(View.GONE);
        } else {
            mFeedTextTv.setVisibility(View.VISIBLE);
        }
        mFeedTextTv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mPresenter.clickFeedItem();
            }
        });
        if (mIsShowDistance) {
            //            int distance = CommonUtils.getLimitedCount(mFeedItem.distance);
            int distance = mFeedItem.distance;
            mDistanceTextView.setText(CommonUtils.formatDistance(distance));
        }
    }

    /* 1.replace('\\s','') s.replace('\n','');*/
    protected String replaceBlank(String text) {
        return text.replaceAll("\n", "");
    }

    private FeedItem buildTempFeed() {
        FeedItem temp = null;
        if (mCacheArrayMap != null) {
            temp = mCacheArrayMap.get(mFeedItem.id);
        }
        if (temp == null) {
            temp = new FeedItem();
            temp.topics = mFeedItem.topics;
            temp.atFriends = mFeedItem.atFriends;
            temp.text = replaceBlank(mFeedItem.text);
            if (mCacheArrayMap != null) {
                mCacheArrayMap.put(mFeedItem.id, temp);
            }
        }
        return temp;
    }

    /**
     * feed icon</br>
     */
    protected void setTypeIcon() {
        Drawable drawable = null;
        if (mFeedItem.type == FeedItem.ANNOUNCEMENT_FEED) {
            drawable = ColorQueque.getDrawable("umeng_comm_discuss_announce");
            mFeedTypeImgView.setVisibility(View.VISIBLE);
            mFeedTypeImgView.setImageDrawable(drawable);
        } else {
            mFeedTypeImgView.setVisibility(View.INVISIBLE);

        }
        mfeedTypeContainer.removeAllViews();
        if (mFeedItem.isTop == FeedItem.TOP_FEED) {
            ImageView img = new ImageView(mContext);
            img.setImageDrawable(ColorQueque.getDrawable("umeng_comm_weibo_ding"));
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            mfeedTypeContainer.addView(img, lp);
        }
        if (mFeedItem.tag == 1) {
            ImageView img = new ImageView(mContext);
            img.setImageDrawable(ColorQueque.getDrawable("umeng_comm_weibo_jing"));
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            if (mFeedItem.isTop == FeedItem.TOP_FEED) {
                lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            }
            mfeedTypeContainer.addView(img, lp);
        }

    }

    private void setUserIcon() {
        if (isShowMedals) {
            UserTypeUtil.SetUserType(mContext, mFeedItem.creator, muserTypeContainer);
        }
    }

    /**
     * ?
     *
     * @param userIconImageView ?SquareImageView
     * @param user              ?url
     */
    private void setupUserIcon(final NetworkImageView userIconImageView, final CommUser user) {
        if (user == null || userIconImageView == null) {
            return;
        }

        ImgDisplayOption option = ImgDisplayOption.getOptionByGender(user.gender);
        userIconImageView.setImageUrl(user.iconUrl, option);
        userIconImageView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // ??
                mPresenter.gotoUserInfoActivity(user, mContainerClzName);
            }
        });
    }

    public void setFeedItem(FeedItem feedItem) {
        mFeedItem = feedItem;
        mPresenter.setFeedItem(mFeedItem);
        if (mActionDialog == null) {
            mActionDialog = new FeedListActionDialog(mContext);
        }
        mActionDialog.setFeedItem(mFeedItem);
        mActionDialog.attachView(this);
        bindFeedItemData();
    }

    public FeedItem getFeedItem() {
        return mFeedItem;
    }

    /**
     * feed??????
     */
    public void hideActionButtons() {
        //        mLikeCountTextView.setVisibility(View.GONE);
        //        mCommentCountTextView.setVisibility(View.GONE);
        //        mForwardCountTextView.setVisibility(View.GONE);

    }

    public void setOnItemViewClickListener(final int position, final OnItemViewClickListener<FeedItem> listener) {
        mItemViewClickListener = listener;
        mCommentCountTextView.setOnClickListener(new Listeners.LoginOnViewClickListener() {

            @Override
            protected void doAfterLogin(View v) {
                clickAnima(mCommentCountTextView);
                if (mItemViewClickListener != null) {
                    mItemViewClickListener.onItemClick(position, mFeedItem);
                }
            }
        });
    }

    public void setOnUpdateListener(OnResultListener listener) {
        mLikePresenter.setResultListener(listener);
    }

    @Override
    public void like(String id, boolean isLiked) {
        if (!mFeedItem.id.equals(id)) {
            return;
        }
        mFeedItem.isLiked = isLiked;
        mLikeCountTextView.setSelected(isLiked);
        if (mFeedItem.isLiked) {
            mLikeCountTextView.setCompoundDrawablesWithIntrinsicBounds(
                    ResFinder.getResourceId(ResType.DRAWABLE, "umeng_comm_feed_detail_like_p"), 0, 0, 0);
        } else {
            mLikeCountTextView.setCompoundDrawablesWithIntrinsicBounds(
                    ResFinder.getResourceId(ResType.DRAWABLE, "umeng_comm_feed_detail_like_n"), 0, 0, 0);
        }
    }

    @Override
    public void updateLikeView(String nextUrl) {
        //        mFeedItem.likeCount+=1;
        String likeCount = CommonUtils.getLimitedCount(mFeedItem.likeCount);
        mLikeCountTextView.setText(likeCount);
    }

    public void setShowDistance() {
        mIsShowDistance = true;
        mDistanceTextView.setVisibility(View.VISIBLE);
    }

    @Override
    public void deleteFeedSuccess() {

    }

    @Override
    public void showLoading(boolean show) {

    }

    @Override
    public void fetchFeedFaild() {

    }

    @Override
    public void fetchDataComplete(FeedItem result) {

    }

    @Override
    public void favoriteFeedComplete(String feedId, boolean isFavorite) {
        if (feedId.equals(mFeedItem.id)) {
            mActionDialog.updateFavoriteBtnState();
        }
    }

    @Override
    public void forbidUserComplete() {

    }

    @Override
    public void cancelForbidUserComplete() {

    }

    @Override
    public void loadMoreLike(List<Like> likes) {

    }
}