private void addNewDataAndRememberPositionAutoRefresh(MessageListBean newValue) { int size = newValue.getSize(); if (getActivity() != null && newValue.getSize() > 0) { getList().addNewData(newValue); int index = getListView().getFirstVisiblePosition(); newMsgTipBar.setValue(newValue, false); newMsgTipBar.setType(TopTipBar.Type.ALWAYS); View v = getListView().getChildAt(1); int top = (v == null) ? 0 : v.getTop(); getAdapter().notifyDataSetChanged(); int ss = index + size; getListView().setSelectionFromTop(ss + 1, top); } }
@Override protected void newMsgOnPostExecute(MessageListBean newValue) { if (getActivity() != null && newValue.getSize() > 0) { getList().addNewData(newValue); getAdapter().notifyDataSetChanged(); getListView().setSelectionAfterHeaderView(); } }
@Override protected void oldMsgOnPostExecute(MessageListBean newValue) { if (newValue != null && newValue.getSize() > 1) { getList().addOldData(newValue); } else { Toast.makeText(getActivity(), getString(R.string.older_message_empty), Toast.LENGTH_SHORT) .show(); } }
public MessageListBean getGSONMsgList() throws WeiboException { String json = getMsgListJson(); Gson gson = new Gson(); MessageListBean value = null; try { value = gson.fromJson(json, MessageListBean.class); } catch (JsonSyntaxException e) { AppLogger.e(e.getMessage()); return null; } if (value != null && value.getItemList().size() > 0) { TimeLineUtility.filterMessage(value); } return value; }
private RefreshReCmtCountTask( FriendsTimeLineFragment friendsTimeLineFragment, MessageListBean data) { fragmentWeakReference = new WeakReference<FriendsTimeLineFragment>(friendsTimeLineFragment); msgIds = new ArrayList<String>(); List<MessageBean> msgList = data.getItemList(); for (MessageBean msg : msgList) { if (msg != null) { msgIds.add(msg.getId()); } } }
@Override public void onReceive(Context context, Intent intent) { AccountBean intentAccount = intent.getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA); if (accountBean.equals(intentAccount)) { MessageListBean mentionsWeibo = intent.getParcelableExtra(BundleArgsConstants.MENTIONS_WEIBO_EXTRA); CommentListBean mentionsComment = intent.getParcelableExtra(BundleArgsConstants.MENTIONS_COMMENT_EXTRA); CommentListBean commentsToMe = intent.getParcelableExtra(BundleArgsConstants.COMMENTS_TO_ME_EXTRA); int unreadCount = (mentionsWeibo != null ? mentionsWeibo.getSize() : 0) + (mentionsComment != null ? mentionsComment.getSize() : 0) + (commentsToMe != null ? commentsToMe.getSize() : 0); String tip = String.format( context.getString(R.string.you_have_new_unread_count), String.valueOf(unreadCount)); Toast.makeText(MainTimeLineActivity.this, tip, Toast.LENGTH_LONG).show(); abortBroadcast(); } }
@Override protected void oldMsgLoaderSuccessCallback(MessageListBean oldValue) { if (Utility.isAllNotNull(getActivity(), oldValue) && oldValue.getSize() > 1) { getList().addOldData(oldValue); putToGroupDataMemoryCache(currentGroupId, getList()); FriendsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid(), currentGroupId); } else if (Utility.isAllNotNull(getActivity())) { Toast.makeText(getActivity(), getString(R.string.older_message_empty), Toast.LENGTH_SHORT) .show(); } }
protected void middleMsgLoaderSuccessCallback( int position, MessageListBean newValue, boolean towardsBottom) { if (newValue == null) { return; } int size = newValue.getSize(); if (getActivity() != null && newValue.getSize() > 0) { getList().addMiddleData(position, newValue, towardsBottom); if (towardsBottom) { getAdapter().notifyDataSetChanged(); } else { View v = Utility.getListViewItemViewFromPosition(getListView(), position + 1 + 1); int top = (v == null) ? 0 : v.getTop(); getAdapter().notifyDataSetChanged(); int ss = position + 1 + size - 1; getListView().setSelectionFromTop(ss, top); } } }
@Override protected void newMsgLoaderSuccessCallback(MessageListBean newValue, Bundle loaderArgs) { if (Utility.isAllNotNull(getActivity(), newValue) && newValue.getSize() > 0) { if (loaderArgs != null && loaderArgs.getBoolean(BundleArgsConstants.AUTO_REFRESH, false)) { addNewDataAndRememberPositionAutoRefresh(newValue); } else { boolean scrollToTop = SettingUtility.isReadStyleEqualWeibo(); if (scrollToTop) { addNewDataWithoutRememberPosition(newValue); } else { addNewDataAndRememberPosition(newValue); } } putToGroupDataMemoryCache(currentGroupId, getList()); FriendsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid(), currentGroupId); } }
@Override protected void onPostExecute(MessageListBean newValue) { super.onPostExecute(newValue); if (newTask != null && newTask.getStatus() != MyAsyncTask.Status.FINISHED) { return; } if (oldTask != null && oldTask.getStatus() != MyAsyncTask.Status.FINISHED) { return; } if (middleTask != null && middleTask.getStatus() != MyAsyncTask.Status.FINISHED) { return; } if (newValue == null || newValue.getSize() == 0 || getActivity() == null || isListViewFling()) return; int firstPosition = getListView().getFirstVisiblePosition(); int size = newValue.getSize(); if (newValue.getItemList().size() < AppConfig.DEFAULT_MSG_NUMBERS) { // for speed, add old data after new data newValue.getItemList().addAll(getList().getItemList()); } else { // null is flag means this position has some old messages which dont appear if (getList().getSize() > 0) { newValue.getItemList().add(null); } newValue.getItemList().addAll(getList().getItemList()); } int index = getListView().getFirstVisiblePosition(); clearAndReplaceValue(newValue); View v = getListView().getChildAt(1); int top = (v == null) ? 0 : v.getTop(); timeLineAdapter.notifyDataSetChanged(); int ss = index + size; // if (firstPosition == 0) { //// // } else { getListView().setSelectionFromTop(ss + 1, top); // } // getListView().setLayoutTransition(null); }
private void putToGroupDataMemoryCache(String groupId, MessageListBean value) { MessageListBean copy = new MessageListBean(); copy.addNewData(value); groupDataCache.put(groupId, copy); }
protected void listViewItemClick(AdapterView parent, View view, int position, long id) { Intent intent = new Intent(getActivity(), BrowserWeiboMsgActivity.class); intent.putExtra("token", token); intent.putExtra("msg", bean.getItem(position)); startActivity(intent); }