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();
}
}
}
}
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);
}
}
}
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);
}
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);
}
});
}
}
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;
}
}
}
}
Aggregations