コード例 #1
0
  public void buildActionBarNav() {
    if ((((MainTimeLineActivity) getActivity()).getMenuFragment()).getCurrentIndex()
        != LeftMenuFragment.HOME_INDEX) {
      return;
    }
    ((MainTimeLineActivity) getActivity()).setCurrentFragment(this);

    getActivity().getActionBar().setDisplayShowTitleEnabled(false);
    getActivity().getActionBar().setDisplayHomeAsUpEnabled(Utility.isDevicePort());
    getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    List<GroupBean> list = new ArrayList<GroupBean>();
    if (GlobalContext.getInstance().getGroup() != null) {
      list = GlobalContext.getInstance().getGroup().getLists();
    } else {
      list = new ArrayList<GroupBean>();
    }

    navAdapter = new FriendsTimeLineListNavAdapter(getActivity(), buildListNavData(list));
    final List<GroupBean> finalList = list;
    getActivity()
        .getActionBar()
        .setListNavigationCallbacks(
            navAdapter,
            new ActionBar.OnNavigationListener() {
              @Override
              public boolean onNavigationItemSelected(int which, long itemId) {

                if (!Utility.isTaskStopped(dbTask)) {
                  return true;
                }

                String groupId = getGroupIdFromIndex(which, finalList);

                if (!groupId.equals(currentGroupId)) {

                  switchFriendsGroup(groupId);
                }
                return true;
              }
            });
    currentGroupId =
        FriendsTimeLineDBTask.getRecentGroupId(GlobalContext.getInstance().getCurrentAccountId());

    if (Utility.isDevicePort()) {
      ((MainTimeLineActivity) getActivity()).setTitle("");
      getActivity().getActionBar().setIcon(R.drawable.ic_menu_home);
    } else {
      ((MainTimeLineActivity) getActivity()).setTitle("");
      getActivity().getActionBar().setIcon(R.drawable.ic_launcher);
    }

    if (getActivity().getActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST
        && isVisible()) {
      getActivity().getActionBar().setSelectedNavigationItem(getRecentNavIndex());
    }
  }
コード例 #2
0
 private void savePositionToDB() {
   TimeLinePosition position = positionCache.get(currentGroupId);
   if (position == null) {
     savePositionToPositionsCache();
     position = positionCache.get(currentGroupId);
   }
   position.newMsgIds = newMsgTipBar.getValues();
   final String groupId = currentGroupId;
   FriendsTimeLineDBTask.asyncUpdatePosition(
       position, GlobalContext.getInstance().getCurrentAccountId(), groupId);
 }
コード例 #3
0
  @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();
    }
  }
コード例 #4
0
  private void updateTimeLineMessageCommentAndRepostData(List<MessageReCmtCountBean> value) {

    if (getList().getSize() <= value.size()) {
      return;
    }

    for (int i = 0; i < value.size(); i++) {
      MessageBean msg = getList().getItem(i);
      MessageReCmtCountBean count = value.get(i);
      if (msg != null && msg.getId().equals(count.getId())) {
        msg.setReposts_count(count.getReposts());
        msg.setComments_count(count.getComments());
      }
    }
    getAdapter().notifyDataSetChanged();
    FriendsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid(), currentGroupId);
  }
コード例 #5
0
 @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);
   }
 }
コード例 #6
0
 @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;
       }
     }
   }
 }
コード例 #7
0
 @Override
 protected List<MessageTimeLineData> doInBackground(Void... params) {
   MessageTimeLineData recentGroupData = FriendsTimeLineDBTask.getRecentGroupData(accountId);
   publishProgress(recentGroupData);
   return FriendsTimeLineDBTask.getOtherGroupData(accountId, recentGroupData.groupId);
 }
コード例 #8
0
 private void saveGroupIdToDB() {
   FriendsTimeLineDBTask.asyncUpdateRecentGroupId(
       GlobalContext.getInstance().getCurrentAccountId(), currentGroupId);
 }