Exemple #1
0
    @Override
    protected String doInBackground(String... params) {
      // TODO Auto-generated method stub
      RoomTaskState = false;
      jsonParser = new JSONParser();
      ArrayList<NameValuePair> parames = new ArrayList<NameValuePair>();
      parames.add(new BasicNameValuePair("id_lampe", data.get(lightindex).getId_equip()));
      parames.add(new BasicNameValuePair("etat", lightindex + ""));

      JSONObject json =
          jsonParser.makeHttpRequest(
              new Settings(Lights.this).getHost() + "/Domotique/statslight.php", "GET", parames);

      try {
        int success = json.getInt("success");
        RoomTaskState = true;
        if (success == 1) {

          lightImageState = Integer.parseInt(json.getString("etat_lampe"));
          message = json.getString("message");
          autostate = Integer.parseInt(json.getString("auto_lampe"));
          return "success";

        } else {
          message = json.getString("message");
          return "fail";
        }

      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return null;
    }
Exemple #2
0
    @Override
    protected String doInBackground(String... params) {
      // TODO Auto-generated method stub
      jParser = new JSONParser();

      ArrayList<NameValuePair> parames = new ArrayList<NameValuePair>();
      parames.add(new BasicNameValuePair("id_user", new Settings(Lights.this).getID()));
      parames.add(
          new BasicNameValuePair("id_maison", new Settings(Lights.this).getselectedhouse()));

      JSONObject json =
          jParser.makeHttpRequest(
              new Settings(Lights.this).getHost() + "/Domotique/LightState.php", "GET", parames);
      Log.d("shutter", json.toString());
      try {
        int success = json.getInt("success");

        if (success == 1) {

          JSONArray lampes = json.getJSONArray("lampe");
          Log.i("allobjectlampe", lampes.toString());
          for (int i = 0; i < lampes.length(); i++) {
            JSONObject lamp = lampes.getJSONObject(i);

            String id_lampe = lamp.getString("id_lampe");
            Log.i("id_shutter", id_lampe);
            String id_rm = lamp.getString("id_rm");
            String des_rm = lamp.getString("des_rm");
            int temp_rm = lamp.getInt("temp_rm");
            int himu_rm = lamp.getInt("himu_rm");
            int etat_lampe = lamp.getInt("etat_lampe");
            Lampe lp =
                new Lampe(id_lampe, "LAMPE", etat_lampe, new Room(id_rm, des_rm, temp_rm, himu_rm));

            // if (Integer.parseInt(sh_s)==1)
            data.add(lp);
          }

          message = json.getString("message");
          return "success";

        } else {
          message = json.getString("message");
          return "fail";
        }
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return null;
    }