Ejemplo 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;
 }
Ejemplo 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");
    }
  }
Ejemplo n.º 3
0
 public void callbackLBS(String lat, String lon) {
   Setting set = DBStor.get_setting();
   if (!set.getLat().equals(lat) && !set.getLon().equals(lon)) {
     set.setLat(lat);
     set.setLon(lon);
     DBStor.set_setting(set);
   }
   this.url = Util.GetURLChat() + "room.php?lat=" + lat + "&lon=" + lon;
   InetConn.getWebData(url, this);
 }
Ejemplo n.º 4
0
 public void GetActiveRoom() {
   if (PersistentStorage.isRegistered()) {
     if (DBStor.get_setting().isTest()) {
       InetConn.getWebData(Util.GetURLChat() + "getactiveRoom.php?pin=" + pin, this);
       setShowLoader(true);
     }
   } else if (DeviceInfo.isSimulator()) {
     InetConn.getWebData(Util.GetURLChat() + "getactiveRoom.php?pin=" + pin, this);
     setShowLoader(true);
   }
 }
Ejemplo n.º 5
0
 public void fieldChanged(Field f, int context) {
   if (f == showmaps) {
     UiApplication.getUiApplication().pushScreen(new MapScreen());
   } else if (f == settinng) {
     UiApplication.getUiApplication().pushScreen(new SettingScreen());
   } else if (f == addroom) {
     if (PersistentStorage.isRegistered()) {
       if (DBStor.get_setting().isTest()) {
         UiApplication.getUiApplication().pushScreen(new addRoomChat());
       } else {
         Dialog.alert("Please try Test Push, until get Success notification.");
       }
     } else {
       Dialog.alert("Please Activate room Chat");
     }
   } else if (f == refresh) {
     if (DeviceInfo.isSimulator()) {
       callbackLBS(DBStor.get_setting().getLat(), DBStor.get_setting().getLon());
     }
     if (PersistentStorage.isRegistered()) {
       if (DBStor.get_setting().isTest()) {
         GetActiveRoom();
         LBS.getLocation(this);
         setShowLoader(true);
       } else {
         Dialog.alert("Please try Test Push, until get Success notification.");
       }
     } else {
       Dialog.alert("Please Activate room Chat");
     }
   } else if (f instanceof TombolRoomField) {
     try {
       TombolRoomField tf = (TombolRoomField) f;
       addToActive(tf);
     } catch (Exception e) {
     }
   }
 }
Ejemplo n.º 6
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);
      }
    }
  }