Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected User doInBackground(String... args) {
- boolean connected=UtilityMethods.isConnected(Main6Activity.this);
- if(!connected)
- {
- return new User(-245,"Brak Polaczenia z Internetem");
- }
- JSONObject json = jsonParser.makeHttpRequest(url_log_new,null,null);
- String name="";
- String logMessage="";
- String surname="";
- String date="";
- String description="";
- String JLogin="";
- String JPassword="";
- // check log cat fro response
- Log.d("Create Response", json.toString());
- int flag=0;
- // check for success tag
- try {
- int success = json.getInt(UtilityMethods.JSONCONSTANTS.success.toString());
- if(success==1) {
- flag=1;
- JLogin=json.getString(UtilityMethods.JSONCONSTANTS.Login.toString());
- name=json.getString(UtilityMethods.JSONCONSTANTS.Imie.toString());
- surname=json.getString(UtilityMethods.JSONCONSTANTS.Nazwisko.toString());
- date=json.getString(UtilityMethods.JSONCONSTANTS.Data.toString());
- this.wait(2000);
- //To-do next Activity to open here
- finish();
- }
- else if(success==-1)
- {
- flag=-1;
- logMessage=json.getString(UtilityMethods.JSONCONSTANTS.message.toString());
- //wrong password or login
- }
- else if(success==0)
- {
- flag=-5;
- logMessage=json.getString(UtilityMethods.JSONCONSTANTS.message.toString());
- }
- } catch (JSONException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return new User(flag, logMessage, name, surname, date, JLogin, JPassword, description);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement