Advertisement
seba101

Untitled

Jul 3rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. protected User doInBackground(String... args) {
  2.  
  3.  
  4.  
  5. boolean connected=UtilityMethods.isConnected(Main6Activity.this);
  6. if(!connected)
  7. {
  8. return new User(-245,"Brak Polaczenia z Internetem");
  9. }
  10. JSONObject json = jsonParser.makeHttpRequest(url_log_new,null,null);
  11.  
  12.  
  13. String name="";
  14. String logMessage="";
  15. String surname="";
  16. String date="";
  17. String description="";
  18. String JLogin="";
  19. String JPassword="";
  20. // check log cat fro response
  21. Log.d("Create Response", json.toString());
  22. int flag=0;
  23. // check for success tag
  24. try {
  25.  
  26. int success = json.getInt(UtilityMethods.JSONCONSTANTS.success.toString());
  27.  
  28. if(success==1) {
  29. flag=1;
  30. JLogin=json.getString(UtilityMethods.JSONCONSTANTS.Login.toString());
  31. name=json.getString(UtilityMethods.JSONCONSTANTS.Imie.toString());
  32. surname=json.getString(UtilityMethods.JSONCONSTANTS.Nazwisko.toString());
  33. date=json.getString(UtilityMethods.JSONCONSTANTS.Data.toString());
  34.  
  35. this.wait(2000);
  36. //To-do next Activity to open here
  37. finish();
  38.  
  39. }
  40. else if(success==-1)
  41. {
  42. flag=-1;
  43. logMessage=json.getString(UtilityMethods.JSONCONSTANTS.message.toString());
  44. //wrong password or login
  45.  
  46. }
  47. else if(success==0)
  48. {
  49.  
  50. flag=-5;
  51. logMessage=json.getString(UtilityMethods.JSONCONSTANTS.message.toString());
  52. }
  53. } catch (JSONException e) {
  54. e.printStackTrace();
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. }
  58.  
  59.  
  60.  
  61. return new User(flag, logMessage, name, surname, date, JLogin, JPassword, description);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement