private void setListViewPositionFromPositionsCache() { Utility.setListViewSelectionFromTop( getListView(), timeLinePosition != null ? timeLinePosition.position : 0, timeLinePosition != null ? timeLinePosition.top : 0, new Runnable() { @Override public void run() { setListViewUnreadTipBar(timeLinePosition); } }); }
private void addNewDataAndRememberPosition(final CommentListBean newValue) { int initSize = getDataList().getSize(); if (getActivity() != null && newValue.getSize() > 0) { final boolean jumpToTop = getDataList().getSize() == 0; getDataList().addNewData(newValue); if (!jumpToTop) { int index = getListView().getFirstVisiblePosition(); getAdapter().notifyDataSetChanged(); int finalSize = getDataList().getSize(); final int positionAfterRefresh = index + finalSize - initSize + getListView().getHeaderViewsCount(); // use 1 px to show newMsgTipBar Utility.setListViewSelectionFromTop( getListView(), positionAfterRefresh, 1, new Runnable() { @Override public void run() { newMsgTipBar.setValue(newValue, false); } }); } else { newMsgTipBar.setValue(newValue, true); newMsgTipBar.clearAndReset(); getAdapter().notifyDataSetChanged(); getListView().setSelection(0); } CommentToMeTimeLineDBTask.asyncReplace(getDataList(), accountBean.getUid()); saveTimeLinePositionToDB(); } }