public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == Activity.RESULT_OK) {
     synchronized (cells) {
       cells.remove(formCell);
       cells.add(formCell);
     }
     observable.notifyChanged();
   }
 }
Beispiel #2
0
 public boolean removeHeader(View v) {
   for (int i = 0; i < mHeaderViewInfos.size(); i++) {
     FixedViewInfo info = mHeaderViewInfos.get(i);
     if (info.view == v) {
       mHeaderViewInfos.remove(i);
       mAreAllFixedViewsSelectable = areAllListInfosSelectable(mHeaderViewInfos);
       mDataSetObservable.notifyChanged();
       return true;
     }
   }
   return false;
 }
  @Override
  public void onUpdate(SortedSet<Post> posts) {
    synchronized (cells) {
      boolean formCellAdded = false;
      long beforeFormCellId = Long.MAX_VALUE;
      if (!cells.get(cells.size() - 1).equals(formCell)) {
        final int currentPos = cells.indexOf(formCell);
        beforeFormCellId = cells.get(currentPos - 1).getItemId();
      }

      cells.clear();
      Date prevDate = null;
      Date lastSeparatorDate = null;
      ListCell prevCell = null;
      for (Post post : posts) {
        Date currentDate = Post.virtualTimestampToDate(post.getVirtualTimestamp());
        if (prevDate == null || !isSameDate(prevDate, currentDate)) {
          lastSeparatorDate = currentDate;
          prevCell = new DateSeparatorCell(currentDate);
          cells.add(prevCell);
          if (!formCellAdded && prevCell.getItemId() == beforeFormCellId) {
            cells.add(formCell);
            formCellAdded = true;
          }
        }
        prevDate = currentDate;

        prevCell = new PostCell(post);
        cells.add(prevCell);
        if (!formCellAdded && prevCell.getItemId() == beforeFormCellId) {
          cells.add(formCell);
          formCellAdded = true;
        }
      }

      if (lastSeparatorDate == null || !isSameDate(lastSeparatorDate, new Date())) {
        cells.add(new DateSeparatorCell(new Date()));
      }

      if (!formCellAdded) {
        cells.add(formCell);
      }
      observable.notifyChanged();
    }
  }
    @Override
    public void notifyChanged() {
      // 数据改变 若已翻至末端 则立即调用addNewItems
      Log.i(VIEW_LOG_TAG, "收到数据改变通知");

      if (adapter.getCount() <= itemIds.size()) {
        // 删减刷新
        clear();
        Message msg = handler.obtainMessage();
        msg.what = ACTION_INIT_ITEMS;
        handler.sendMessageDelayed(msg, DELAY);

      } else {
        // 添加刷新
        if ((colCount - selectCol) < screenMaxColumns) {
          Message msg = handler.obtainMessage();
          msg.what = ACTION_ADD_ITEMS;
          handler.sendMessageDelayed(msg, DELAY);
        }
      }

      super.notifyChanged();
    }
 public void notifyDataSetChanged() {
   mDataSetObservable.notifyChanged();
 }
Beispiel #6
0
 @Override
 public void notifyChanged() {
   super.notifyChanged();
   mGlobalObservable.notifyChanged();
 }
Beispiel #7
0
 /** Calls {@link DataSetObserver#onChanged()} on all observers. */
 protected void notifyDataSetChanged() {
   if (DBG) Log.d(TAG, "notifyDataSetChanged()");
   mDataSetObservable.notifyChanged();
 }