Search in sources :

Example 1 with LikeBean

use of org.aisen.weibo.sina.support.bean.LikeBean in project AisenWeiBo by wangdan.

the class DoLikeAction method doAction.

@Override
public void doAction() {
    final String key = String.valueOf(data.getId());
    LikeBean likeBean = likeCache.get(key);
    // 如果还没有点赞过,首先添加一个点赞
    if (likeBean == null) {
        likeBean = new LikeBean();
        likeBean.setLiked(like);
        likeBean.setStatusId(key);
        LikeDB.insert(likeBean);
        likeCache.put(key, likeBean);
    } else // 点赞过了,刷新内存,刷新DB
    {
        likeBean.setLiked(like);
        LikeDB.insert(likeBean);
    }
    // 开始处理点赞
    new LikeTask().execute();
    MobclickAgent.onEvent(bizFragment.getActivity(), "do_like");
}
Also used : LikeBean(org.aisen.weibo.sina.support.bean.LikeBean)

Example 2 with LikeBean

use of org.aisen.weibo.sina.support.bean.LikeBean in project AisenWeiBo by wangdan.

the class TimelineDetailPagerFragment method setLikeText.

private void setLikeText() {
    // 点赞数
    LikeBean likeBean = DoLikeAction.likeCache.get(mStatusContent.getId() + "");
    if (txtAttitudes != null) {
        txtAttitudes.setTag(mStatusContent);
        txtAttitudes.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                LikeBean likeBean = DoLikeAction.likeCache.get(mStatusContent.getId() + "");
                boolean like = likeBean == null || !likeBean.isLiked();
                bizFragment.doLike(mStatusContent, like, v, TimelineDetailPagerFragment.this);
            }
        });
        if (likeBean != null && likeBean.isLiked()) {
            if (mStatusContent.getAttitudes_count() > 0)
                txtAttitudes.setText(String.format(getString(R.string.attitudes_format), AisenUtils.getCounter(mStatusContent.getAttitudes_count(), "+1")));
            else
                txtAttitudes.setText(String.format(getString(R.string.attitudes_format), "+1"));
        } else {
            if (mStatusContent.getAttitudes_count() > 0)
                txtAttitudes.setText(String.format(getString(R.string.attitudes_format), AisenUtils.getCounter(mStatusContent.getAttitudes_count())));
            else
                txtAttitudes.setText("");
        }
    }
}
Also used : LikeBean(org.aisen.weibo.sina.support.bean.LikeBean) View(android.view.View) TimelineDetailScrollView(org.aisen.weibo.sina.ui.widget.TimelineDetailScrollView) TextView(android.widget.TextView)

Example 3 with LikeBean

use of org.aisen.weibo.sina.support.bean.LikeBean in project AisenWeiBo by wangdan.

the class TimelineItemView method setLikeView.

public void setLikeView() {
    LikeBean likeBean = DoLikeAction.likeCache.get(data.getId() + "");
    if (btnLike != null) {
        btnLike.setTag(data);
        btnLike.setOnClickListener(this);
        if (likeBean != null && likeBean.isLiked()) {
            imgLike.setSelected(true);
            if (data.getAttitudes_count() > 0)
                txtLike.setText(AisenUtils.getCounter(data.getAttitudes_count(), "+1"));
            else
                txtLike.setText("+1");
        } else {
            imgLike.setSelected(false);
            if (data.getAttitudes_count() > 0)
                txtLike.setText(AisenUtils.getCounter(data.getAttitudes_count()) + "");
            else
                txtLike.setText("");
        }
    }
}
Also used : LikeBean(org.aisen.weibo.sina.support.bean.LikeBean)

Example 4 with LikeBean

use of org.aisen.weibo.sina.support.bean.LikeBean in project AisenWeiBo by wangdan.

the class TimelineItemView method onClick.

@Override
public void onClick(View v) {
    // 查看转发微博信息
    if (v.getId() == R.id.layRe) {
        StatusContent reContent = (StatusContent) v.getTag();
        TimelineDetailPagerFragment.launch(fragment.getActivity(), reContent);
    } else // 转发
    if (v.getId() == R.id.btnRepost) {
        StatusContent status = (StatusContent) v.getTag();
        bizFragment.statusRepost(status);
    } else // 评论
    if (v.getId() == R.id.btnCmt) {
        StatusContent status = (StatusContent) v.getTag();
        bizFragment.commentCreate(status);
    } else // 点赞
    if (v.getId() == R.id.btnLike) {
        StatusContent status = (StatusContent) v.getTag();
        LikeBean likeBean = DoLikeAction.likeCache.get(status.getId() + "");
        boolean like = likeBean == null || !likeBean.isLiked();
        v.findViewById(R.id.imgLike).setSelected(like);
        bizFragment.doLike(status, like, v, this);
    } else // 溢出菜单
    if (v.getId() == R.id.btnMenus) {
        final String[] timelineMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.timeline_menus);
        final StatusContent status = (StatusContent) v.getTag();
        List<String> menuList = new ArrayList<String>();
        if (status.getRetweeted_status() != null && status.getRetweeted_status().getUser() != null)
            menuList.add(timelineMenuArr[0]);
        //			menuList.add(timelineMenuArr[3]);
        //			if (status.getVisible() == null || "0".equals(status.getVisible().getType()))
        //				menuList.add(timelineMenuArr[2]);
        menuList.add(timelineMenuArr[4]);
        menuList.add(timelineMenuArr[5]);
        menuList.add(timelineMenuArr[1]);
        if (status.getUser() != null && status.getUser().getIdstr().equals(AppContext.getAccount().getUser().getIdstr()))
            menuList.add(timelineMenuArr[6]);
        if (fragment instanceof MentionTimelineFragment)
            menuList.add(timelineMenuArr[7]);
        final String[] menus = new String[menuList.size()];
        for (int i = 0; i < menuList.size(); i++) menus[i] = menuList.get(i);
        AisenUtils.showMenuDialog(fragment, v, menus, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                AisenUtils.timelineMenuSelected(fragment, menus[which], status);
            }
        });
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) MentionTimelineFragment(org.aisen.weibo.sina.ui.fragment.mention.MentionTimelineFragment) LikeBean(org.aisen.weibo.sina.support.bean.LikeBean)

Aggregations

LikeBean (org.aisen.weibo.sina.support.bean.LikeBean)4 DialogInterface (android.content.DialogInterface)1 View (android.view.View)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)1 MentionTimelineFragment (org.aisen.weibo.sina.ui.fragment.mention.MentionTimelineFragment)1 TimelineDetailScrollView (org.aisen.weibo.sina.ui.widget.TimelineDetailScrollView)1