@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_public_user_profile);

    mSocket = SocketManager.getMySocket();
    mSocket.on("RGetAllMyDogs", onRGetAllMyDogs);

    int idUser = getIntent().getIntExtra("USER", -1);
    System.out.println("ID U : " + idUser);
    mSocket.emit("getUserById", idUser);
    mSocket.on("RGetUser", onRGetUser);
    mSocket.emit("getAllMyDogs", idUser);

    // Mise en page formulaire
    tvMail = (TextView) findViewById(R.id.userPublicProfileMail_tv);
    tvPhone = (TextView) findViewById(R.id.userPublicProfilePhoneNumber_tv);
    style();
  }
Esempio n. 2
0
        public void call(final Object... args) {
          JSONObject data = (JSONObject) args[0];
          Log.d("JSON", data.toString());
          try {

            socket.emit("recevied", "");
            // Add the new topic to the view
            String title = data.getString("title");
            String description = data.getString("description");
            Boolean interesting = data.getBoolean("interesting");
            Boolean difficulty = data.getBoolean("difficulty");

            Boolean quiz = data.getBoolean("quiz");
            Topic theTopic = new Topic(title, description, interesting, difficulty, quiz);

            if (difficulty) {
              int maxDifficulty = data.getInt("maxDifficulty");
              int minDifficulty = data.getInt("minDifficulty");
              theTopic.maxDifficulty = maxDifficulty;
              theTopic.minDifficulty = minDifficulty;
            }

            if (quiz) {
              theTopic.questionType = data.getJSONObject("question").getString("type");
              theTopic.questionText = data.getJSONObject("question").getString("text");
              JSONArray answersArray = data.getJSONArray("answers");
              for (int i = 0; i < answersArray.length(); i++) {
                JSONObject a = (JSONObject) answersArray.get(i);
                String text = a.getString("text");
                Boolean correct = a.getBoolean("correct");
                Answer answer = new Answer(text, correct);

                theTopic.answers.add(theTopic.answers.size(), answer);
              }
            }

            add(theTopic);

          } catch (Exception e) {
            e.printStackTrace();
          }
        }
Esempio n. 3
0
 /** Publishes a message containing name, and text. */
 public void pushMessage(String name, String text) {
   socket.emit("status added", text, name);
 }