示例#1
0
  public void setBuffer(int bufferId) {
    Log.d(TAG, "Setting buffer and chat is visible: " + getUserVisibleHint());
    this.bufferId = bufferId;
    if (adapter != null && networks != null) {
      if (adapter.buffer != null && bufferId != adapter.buffer.getInfo().id) {
        updateMarkerLine();
      }
      adapter.clearBuffer();
      Buffer buffer = networks.getBufferById(bufferId);
      if (buffer != null) {
        adapter.setBuffer(buffer, networks);
        nickCompletionHelper = new NickCompletionHelper(buffer.getUsers().getUniqueUsers());
        autoCompleteButton.setEnabled(true);
        inputField.setEnabled(true);
        if (getUserVisibleHint() == true) buffer.setDisplayed(true);
        BusProvider.getInstance()
            .post(new ManageChannelEvent(buffer.getInfo().id, ChannelAction.HIGHLIGHTS_READ));

        // Move list to correct position
        if (adapter.buffer.getTopMessageShown() == 0) {
          backlogList.setSelection(adapter.getCount() - 1);
        } else {
          adapter.setListTopMessage(adapter.buffer.getTopMessageShown());
        }
      } else {
        resetFragment();
      }
    }
  }
示例#2
0
 private void updateMarkerLine() {
   BusProvider.getInstance()
       .post(
           new ManageMessageEvent(
               adapter.getBufferId(),
               adapter.buffer.getLastSeenMessage(),
               MessageAction.MARKER_LINE));
 }
示例#3
0
 @Override
 public void onStop() {
   Log.d(TAG, "Stopping fragment");
   super.onStop();
   if (Quasseldroid.status == ConnectionChangedEvent.Status.Connected && getUserVisibleHint())
     updateRead();
   adapter.clearBuffer();
   BusProvider.getInstance().unregister(this);
   setUserVisibleHint(false);
 }
示例#4
0
 @Subscribe
 public void onBufferOpened(BufferOpenedEvent event) {
   if (event.bufferId != -1) {
     this.bufferId = event.bufferId;
     if (networks != null) {
       observer.setBuffer(networks.getBufferById(bufferId));
       updateUsers();
       BusProvider.getInstance().post(new BufferDetailsChangedEvent(bufferId));
     }
   }
 }
示例#5
0
 @Subscribe
 public void onNetworksAvailable(NetworksAvailableEvent event) {
   if (event.networks != null) {
     this.networks = event.networks;
     if (bufferId != -1) {
       observer.setBuffer(networks.getBufferById(bufferId));
       updateUsers();
       BusProvider.getInstance().post(new BufferDetailsChangedEvent(bufferId));
     }
   }
 }
示例#6
0
 @Override
 public void onStart() {
   Log.d(TAG, "Starting fragment");
   super.onStart();
   dynamicBacklogAmount =
       Integer.parseInt(
           preferences.getString(getString(R.string.preference_dynamic_backlog), "10"));
   autoCompleteButton.setEnabled(false);
   inputField.setEnabled(false);
   BusProvider.getInstance().register(this);
   setUserVisibleHint(true);
 }
示例#7
0
 @Override
 public void update(Observable observable, Object data) {
   if (data == null) {
     return;
   }
   switch ((Integer) data) {
     case R.id.BUFFERUPDATE_TOPICCHANGED:
       BusProvider.getInstance().post(new BufferDetailsChangedEvent(bufferId));
       break;
     default:
   }
 }
示例#8
0
  private void updateRead() {
    Log.d(TAG, "Updating buffer read, chat is visible: " + getUserVisibleHint());
    if (adapter.buffer != null) {

      // Don't save position if list is at bottom
      if (backlogList.getLastVisiblePosition() == adapter.getCount() - 1) {
        adapter.buffer.setTopMessageShown(0);
      } else {
        adapter.buffer.setTopMessageShown(adapter.getListTopMessageId());
      }
      if (adapter.buffer.getUnfilteredSize() != 0) {
        BusProvider.getInstance()
            .post(new ManageChannelEvent(adapter.getBufferId(), ChannelAction.MARK_AS_READ));
        BusProvider.getInstance()
            .post(
                new ManageMessageEvent(
                    adapter.getBufferId(),
                    adapter.buffer.getUnfilteredBacklogEntry(adapter.buffer.getUnfilteredSize() - 1)
                        .messageId,
                    MessageAction.LAST_SEEN));
      }
    }
  }
示例#9
0
 public void getMoreBacklog() {
   adapter.buffer.setBacklogPending(true);
   BusProvider.getInstance()
       .post(new GetBacklogEvent(adapter.getBufferId(), dynamicBacklogAmount));
 }
示例#10
0
 private void queryUser(String nick) {
   BusProvider.getInstance().post(new UserClickedEvent(bufferId, nick));
 }
示例#11
0
 @Override
 public void onStop() {
   super.onStop();
   adapter.stopObserving();
   BusProvider.getInstance().unregister(this);
 }
示例#12
0
 @Override
 public void onStart() {
   super.onStart();
   BusProvider.getInstance().register(this);
 }