Exemplo n.º 1
0
 public void leaveGroup(String idRoom) {
   int n = 0;
   ChatScreen cs;
   TombolRoomField trf;
   for (n = 0; n < chatss.length; n++) {
     cs = chatss[n];
     if (cs != null)
       if (cs.getIdRoom().equals(idRoom)) {
         this.chatss[n] = null;
         break;
       }
   }
   for (n = 0; n < AktifRoom.getFieldCount(); n++) {
     trf = (TombolRoomField) AktifRoom.getField(n);
     if (trf.getRoom().getIdRoom().equals(idRoom)) {
       AktifRoom.delete(trf);
     }
   }
   PushController.updateIndicator(false);
   InetConn.getWebData(
       Util.GetURLChat()
           + "inout.php?id="
           + idRoom
           + "&pin="
           + pin
           + "&in=false&nick="
           + DBStor.get_setting().getNick(),
       new WebDataCallback() {
         public void callback(String data) {}
       });
   cs = null;
   trf = null;
 }
Exemplo n.º 2
0
  public void addToActive(TombolRoomField tf) {
    if (!DBStor.get_setting().isTest() && !DeviceInfo.isSimulator()) {
      Dialog.alert("Please try Test Push, until get Success notification.");
      return;
    }
    PushController.updateIndicator(false);
    if (Integer.parseInt(tf.getTotalperson()) > 49) {
      Dialog.alert("Room Full!");
    }
    int n = 0, a = 0;
    for (n = 0; n < chatss.length; n++) {
      ChatScreen css = chatss[n];
      if (css != null) {
        a++;
      }
    }
    if (a < 5) {
      ChatScreen cs;

      for (n = 0; n < chatss.length; n++) {
        cs = chatss[n];
        if (cs != null) {
          if (cs.getIdRoom().equals(tf.getRoom().getIdRoom())) {
            UiApplication.getUiApplication().pushScreen(cs);
            return;
          }
        }
      }
      TombolRoomField tfs = new TombolRoomField(tf.getRoom(), "0", USE_ALL_WIDTH);
      tfs.setChangeListener(this);
      tfs.setActive(true);
      AktifRoom.add(tfs);
      cs = new ChatScreen(tf.getRoom().getIdRoom(), tfs.getLabel(), this, tfs);
      for (n = 0; n < chatss.length; n++) {
        ChatScreen css = chatss[n];
        if (css == null) {
          this.chatss[n] = cs;
          break;
        }
      }
      UiApplication.getUiApplication().pushScreen(cs);
      cs = null;
    } else {
      ChatScreen cs;
      for (n = 0; n < chatss.length; n++) {
        cs = chatss[n];
        if (cs != null) {
          if (cs.getIdRoom().equals(tf.getRoom().getIdRoom())) {
            UiApplication.getUiApplication().pushScreen(cs);
            return;
          }
        }
      }
      Dialog.alert("Max 5 Active Room");
    }
  }
Exemplo n.º 3
0
  public void callback(String data) {
    Util.Log("rooms" + data);
    setShowLoader(false);
    if (data.startsWith("Exception")) {
      Dialog.alert("Failed to connect to server.");
    } else if (data.startsWith("room:")) {
      String[] temps = Util.split(data.substring(5), "<room>");
      for (int n = 0; n < temps.length; n++) {
        String[] temp = Util.split(temps[n], "||");
        reloadActive(new RoomChat(temp[1], temp[0]));
      }
      // reloadActive();

      setShowLoader(true);
      if (DeviceInfo.isSimulator()) {
        callbackLBS(DBStor.get_setting().getLat(), DBStor.get_setting().getLon());
      } else {
        LBS.getLocation(this);
      }
    } else if (data.startsWith("empty")) {
      if (DeviceInfo.isSimulator()) {
        callbackLBS(DBStor.get_setting().getLat(), DBStor.get_setting().getLon());
      } else {
        LBS.getLocation(this);
      }
    } else if (data.startsWith("done:")) {
      ChatRoom.deleteAll();
      String temps[] = Util.split(data.substring(5), "<<>>");
      String temp[];
      for (int n = 0; n < temps.length; n++) {
        temp = Util.split(temps[n], "||");
        TombolRoomField tl =
            new TombolRoomField(new RoomChat(temp[1], temp[0]), temp[2], USE_ALL_WIDTH);
        tl.setChangeListener(this);
        ChatRoom.add(tl);
      }
    }
  }
Exemplo n.º 4
0
  public void reloadActive(RoomChat tf) {
    int n = 0, a = 0;
    for (n = 0; n < chatss.length; n++) {
      ChatScreen css = chatss[n];
      if (css != null) {
        a++;
      }
    }
    if (a < 5) {
      ChatScreen cs;
      for (n = 0; n < chatss.length; n++) {
        ChatScreen f2 = chatss[n];
        if (f2 != null)
          if (f2.getIdRoom().equals(tf.getIdRoom())) {
            return;
          }
      }

      TombolRoomField tfs = new TombolRoomField(tf, "0", USE_ALL_WIDTH);
      tfs.setChangeListener(this);
      tfs.setActive(true);
      AktifRoom.add(tfs);
      cs = new ChatScreen(tf.getIdRoom(), tf.getNamaRoom(), this, tfs);
      // UiApplication.getUiApplication().pushScreen(cs);

      for (n = 0; n < chatss.length; n++) {
        ChatScreen css = chatss[n];
        if (css == null) {
          this.chatss[n] = cs;
          break;
        }
      }
      cs = null;
    } else {
      // Dialog.alert("Max 5 Room active");
    }
  }
Exemplo n.º 5
0
 public void addToFav(TombolRoomField tf) {
   int n = 0;
   RoomChat tf2;
   boolean ada = false;
   for (n = 0; n < favRomm.size(); n++) {
     tf2 = (RoomChat) favRomm.elementAt(n);
     if (tf2.getIdRoom().equals(tf.getRoom().getIdRoom())) {
       ada = true;
       break;
     }
   }
   if (ada) {
     Dialog.alert("Room Chat exist");
   } else {
     favRomm.addElement(tf.getRoom());
     DBStor.set_roomFav(favRomm);
     TombolRoomField tfs = new TombolRoomField(tf.getRoom(), "0", USE_ALL_WIDTH);
     tfs.setChangeListener(this);
     tfs.setFavourite(true);
     Favourite.add(tfs);
   }
 }
Exemplo n.º 6
0
 public void reloadFav(RoomChat tf) {
   TombolRoomField tfs = new TombolRoomField(tf, "0", USE_ALL_WIDTH);
   tfs.setChangeListener(this);
   tfs.setFavourite(true);
   Favourite.add(tfs);
 }