iifast

ServiceTask.java

Jun 11th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. //File Name : ServiceTask.java
  2.  
  3. package com.mycompany.myapp.services;
  4. /**
  5. *
  6. *@author
  7. */
  8.  
  9. public class ServiceTask {
  10. //creer une variable pour le resultat d'ajout
  11.  
  12. public boolean resultOK;
  13.  
  14. //Creer la methode addTask
  15. public boolean addTask(Task t) {
  16.  
  17. String url = Statics.BASE_URL+"/tasks/"+t.getName()+"/"+t.getStatus();
  18. ConnectionRequest req = new ConnectionRequest(url);
  19. req.addResponseListener(new ActionListeneer<NetworkEvent>() {
  20. @Override
  21.     public void actionPerformed(NetworkEvent evt) {
  22. //ajouter une action à la reception de la reponse
  23.     //verifier le status de la reponse
  24.     resultOK = req.getResponseCode() == 200; //code HTTP 200 OK
  25.     }
  26.  
  27. });
  28. NetworkManager.getInstance().addToQueueAndWait(req);
  29. return resultOK;
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment