Search in sources :

Example 21 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class TimeLineUtility method filterHomeTimeLineSinaWeiboAd.

public static void filterHomeTimeLineSinaWeiboAd(MessageListBean value) {
    if (!SettingUtility.isFilterSinaAd()) {
        return;
    }
    List<MessageBean> msgList = value.getItemList();
    Iterator<MessageBean> iterator = msgList.iterator();
    final List<AdBean> adBeanList = value.getAd();
    if (adBeanList.size() > 0) {
        AppLogger.i("filter " + adBeanList.size() + " sina weibo ads");
        List<String> adIdList = new ArrayList<String>();
        for (AdBean adBean : adBeanList) {
            adIdList.add(adBean.getId());
        }
        while (iterator.hasNext()) {
            MessageBean msg = iterator.next();
            UserBean user = msg.getUser();
            if (user == null) {
                continue;
            }
            if (adIdList.contains(msg.getId())) {
                iterator.remove();
                value.removedCountPlus();
            }
        }
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) UserBean(org.qii.weiciyuan.bean.UserBean) DMUserBean(org.qii.weiciyuan.bean.DMUserBean) AdBean(org.qii.weiciyuan.bean.AdBean) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString)

Example 22 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class TimeLineUtility method filterMessage.

public static void filterMessage(MessageListBean value) {
    List<MessageBean> msgList = value.getItemList();
    Iterator<MessageBean> iterator = msgList.iterator();
    List<String> keywordFilter = FilterDBTask.getFilterKeywordList(FilterDBTask.TYPE_KEYWORD);
    List<String> userFilter = FilterDBTask.getFilterKeywordList(FilterDBTask.TYPE_USER);
    List<String> topicFilter = FilterDBTask.getFilterKeywordList(FilterDBTask.TYPE_TOPIC);
    List<String> sourceFilter = FilterDBTask.getFilterKeywordList(FilterDBTask.TYPE_SOURCE);
    while (iterator.hasNext()) {
        MessageBean msg = iterator.next();
        if (msg.getUser() == null) {
            iterator.remove();
            value.removedCountPlus();
        } else if (SettingUtility.isEnableFilter() && TimeLineUtility.haveFilterWord(msg, keywordFilter, userFilter, topicFilter, sourceFilter)) {
            iterator.remove();
            value.removedCountPlus();
        } else {
            msg.getListViewSpannableString();
            TimeUtility.dealMills(msg);
        }
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) SpannableString(android.text.SpannableString)

Example 23 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class FriendsTimeLineFragment method updateTimeLineMessageCommentAndRepostData.

private void updateTimeLineMessageCommentAndRepostData(List<MessageReCmtCountBean> value) {
    if (value == null) {
        return;
    }
    HashMap<String, MessageReCmtCountBean> messageReCmtCountBeanHashMap = new HashMap<String, MessageReCmtCountBean>();
    for (MessageReCmtCountBean count : value) {
        messageReCmtCountBeanHashMap.put(count.getId(), count);
    }
    for (int i = 0; i < getList().getSize(); i++) {
        MessageBean msg = getList().getItem(i);
        if (msg == null) {
            continue;
        }
        MessageReCmtCountBean count = messageReCmtCountBeanHashMap.get(msg.getId());
        if (count != null) {
            msg.setReposts_count(count.getReposts());
            msg.setComments_count(count.getComments());
        }
    }
    getAdapter().notifyDataSetChanged();
    FriendsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid(), currentGroupId);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) HashMap(java.util.HashMap) MessageReCmtCountBean(org.qii.weiciyuan.bean.MessageReCmtCountBean)

Example 24 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class FriendsTimeLineFragment method addNewDataAndRememberPosition.

private void addNewDataAndRememberPosition(final MessageListBean newValue) {
    int initSize = getList().getSize();
    if (getActivity() != null && newValue.getSize() > 0) {
        MessageBean previousFirstItem = getList().getSize() > 0 ? getList().getItem(0) : null;
        int index = getListView().getFirstVisiblePosition();
        getList().addNewData(newValue);
        getAdapter().notifyDataSetChanged();
        int finalSize = getList().getSize();
        int positionAfterRefresh = index + finalSize - initSize + getListView().getHeaderViewsCount();
        //make sure isMiddleUnreadItem item is visible at first ListView visible position
        if (previousFirstItem != null) {
            int itemPositionAfterRefresh = getList().getItemList().indexOf(previousFirstItem);
            if (getList().getItem(itemPositionAfterRefresh - 1).isMiddleUnreadItem()) {
                positionAfterRefresh -= 1;
            }
        }
        //use 1 px to show newMsgTipBar
        Utility.setListViewItemPosition(getListView(), positionAfterRefresh, 1, new Runnable() {

            @Override
            public void run() {
                newMsgTipBar.setValue(newValue, false);
                newMsgTipBar.setType(TopTipBar.Type.AUTO);
            }
        });
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) WifiAutoDownloadPictureRunnable(org.qii.weiciyuan.othercomponent.WifiAutoDownloadPictureRunnable)

Example 25 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.

the class FriendsTimeLineFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    //use Up instead of Back to reach this fragment
    if (data == null) {
        return;
    }
    final MessageBean msg = (MessageBean) data.getParcelableExtra("msg");
    if (msg != null) {
        for (int i = 0; i < getList().getSize(); i++) {
            if (msg.equals(getList().getItem(i))) {
                MessageBean ori = getList().getItem(i);
                if (ori.getComments_count() != msg.getComments_count() || ori.getReposts_count() != msg.getReposts_count()) {
                    ori.setReposts_count(msg.getReposts_count());
                    ori.setComments_count(msg.getComments_count());
                    FriendsTimeLineDBTask.asyncUpdateCount(msg.getId(), msg.getComments_count(), msg.getReposts_count());
                    getAdapter().notifyDataSetChanged();
                }
                break;
            }
        }
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean)

Aggregations

MessageBean (org.qii.weiciyuan.bean.MessageBean)52 Gson (com.google.gson.Gson)21 JsonSyntaxException (com.google.gson.JsonSyntaxException)16 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)8 Cursor (android.database.Cursor)7 Intent (android.content.Intent)6 CommentBean (org.qii.weiciyuan.bean.CommentBean)6 UserBean (org.qii.weiciyuan.bean.UserBean)6 DatabaseUtils (android.database.DatabaseUtils)4 SQLException (android.database.SQLException)4 View (android.view.View)4 PendingIntent (android.app.PendingIntent)3 Drawable (android.graphics.drawable.Drawable)3 SpannableString (android.text.SpannableString)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 RelativeLayout (android.widget.RelativeLayout)3 TextView (android.widget.TextView)3