예제 #1
0
 public void onTimeoutDetected() {
   // Log.d("JsIdle", "onTimeoutDetected");
   if (isAppVisible) {
     isAppVisible = false;
     messenger.onAppHidden();
   }
 }
예제 #2
0
 public void onActionDetected() {
   // Log.d("JsIdle", "onActionDetected");
   if (!isAppVisible) {
     isAppVisible = true;
     messenger.onAppVisible();
   }
   self().sendOnce(new FlushTimeout(), TIMEOUT);
 }
예제 #3
0
  public static JsGroup fromGroupVM(GroupVM groupVM, JsMessenger messenger) {
    int online = groupVM.getPresence().get();
    String presence = messenger.getFormatter().formatGroupMembers(groupVM.getMembersCount());
    if (online > 0) {
      presence += ", " + messenger.getFormatter().formatGroupOnline(online);
    }
    String fileUrl = null;
    String bigFileUrl = null;
    Avatar avatar = groupVM.getAvatar().get();
    if (avatar != null) {
      if (avatar.getSmallImage() != null) {
        fileUrl = messenger.getFileUrl(avatar.getSmallImage().getFileReference());
      }
      if (avatar.getLargeImage() != null) {
        bigFileUrl = messenger.getFileUrl(avatar.getLargeImage().getFileReference());
      }
    }

    ArrayList<JsGroupMember> convertedMembers = new ArrayList<JsGroupMember>();
    HashSet<GroupMember> groupMembers = groupVM.getMembers().get();
    GroupMember[] members = groupMembers.toArray(new GroupMember[groupMembers.size()]);
    for (GroupMember g : members) {
      JsPeerInfo peerInfo = messenger.buildPeerInfo(Peer.user(g.getUid()));
      Log.d("JsGroup", "PeerInfo: " + peerInfo);
      convertedMembers.add(
          JsGroupMember.create(
              peerInfo,
              g.isAdministrator(),
              g.getInviterUid() == messenger.myUid()
                  || groupVM.getCreatorId() == messenger.myUid()));
    }
    Collections.sort(
        convertedMembers,
        new Comparator<JsGroupMember>() {
          @Override
          public int compare(JsGroupMember o1, JsGroupMember o2) {
            return o1.getPeerInfo().getTitle().compareToIgnoreCase(o2.getPeerInfo().getTitle());
          }
        });
    JsArray<JsGroupMember> jsMembers = JsArray.createArray().cast();
    for (JsGroupMember member : convertedMembers) {
      jsMembers.push(member);
    }
    return create(
        groupVM.getId(),
        groupVM.getName().get(),
        fileUrl,
        bigFileUrl,
        Placeholders.getPlaceholder(groupVM.getId()),
        groupVM.getCreatorId(),
        presence,
        jsMembers);
  }