Program: 32111
Project: 32111
Buggy source:
@Override public void onEvent(final Event event,final EventTimeline.Direction direction,final RoomState roomState){
  if (direction == EventTimeline.Direction.FORWARDS) {
    getUiHandler().post(new Runnable(){
      @Override public void run(){
        if (Event.EVENT_TYPE_REDACTION.equals(event.type)) {
          MessageRow messageRow=mAdapter.getMessageRow(event.getRedacts());
          if (null != messageRow) {
            Event prunedEvent=mSession.getDataHandler().getStore().getEvent(event.getRedacts(),event.roomId);
            if (null == prunedEvent) {
              mAdapter.removeEventById(event.getRedacts());
            }
 else {
              messageRow.updateEvent(prunedEvent);
              JsonObject content=messageRow.getEvent().getContentAsJsonObject();
              boolean hasToRemoved=(null == content) || (null == content.entrySet()) || (0 == content.entrySet().size());
              if (!hasToRemoved) {
                EventDisplay eventDisplay=new EventDisplay(getActivity(),prunedEvent,roomState);
                hasToRemoved=TextUtils.isEmpty(eventDisplay.getTextualDisplay());
              }
              if (hasToRemoved) {
                mAdapter.removeEventById(prunedEvent.eventId);
              }
            }
            mAdapter.notifyDataSetChanged();
          }
        }
 else         if (Event.EVENT_TYPE_TYPING.equals(event.type)) {
          if (null != mRoom) {
            mAdapter.setTypingUsers(mRoom.getTypingUsers());
          }
        }
 else {
          if (canAddEvent(event)) {
            mAdapter.add(new MessageRow(event,roomState),(null == mEventTimeLine) || mEventTimeLine.isLiveTimeline());
          }
        }
      }
    }
);
  }
 else {
    if (canAddEvent(event)) {
      mAdapter.addToFront(event,roomState);
    }
  }
}

Fixed version (ground truth):
@Override public void onEvent(final Event event,final EventTimeline.Direction direction,final RoomState roomState){
  if (direction == EventTimeline.Direction.FORWARDS) {
    getUiHandler().post(new Runnable(){
      @Override public void run(){
        if (Event.EVENT_TYPE_REDACTION.equals(event.type)) {
          MessageRow messageRow=mAdapter.getMessageRow(event.getRedacts());
          if (null != messageRow) {
            Event prunedEvent=mSession.getDataHandler().getStore().getEvent(event.getRedacts(),event.roomId);
            if (null == prunedEvent) {
              mAdapter.removeEventById(event.getRedacts());
            }
 else {
              messageRow.updateEvent(prunedEvent);
              JsonObject content=messageRow.getEvent().getContentAsJsonObject();
              boolean hasToRemoved=(null == content) || (null == content.entrySet()) || (0 == content.entrySet().size());
              if (!hasToRemoved && (null != getActivity())) {
                EventDisplay eventDisplay=new EventDisplay(getActivity(),prunedEvent,roomState);
                hasToRemoved=TextUtils.isEmpty(eventDisplay.getTextualDisplay());
              }
              if (hasToRemoved) {
                mAdapter.removeEventById(prunedEvent.eventId);
              }
            }
            mAdapter.notifyDataSetChanged();
          }
        }
 else         if (Event.EVENT_TYPE_TYPING.equals(event.type)) {
          if (null != mRoom) {
            mAdapter.setTypingUsers(mRoom.getTypingUsers());
          }
        }
 else {
          if (canAddEvent(event)) {
            mAdapter.add(new MessageRow(event,roomState),(null == mEventTimeLine) || mEventTimeLine.isLiveTimeline());
          }
        }
      }
    }
);
  }
 else {
    if (canAddEvent(event)) {
      mAdapter.addToFront(event,roomState);
    }
  }
}