Example usage for org.json JSONException printStackTrace

List of usage examples for org.json JSONException printStackTrace

Introduction

In this page you can find the example usage for org.json JSONException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

private void btnconfirm() {

    // Find the SharedPreferences pass Login value
    SharedPreferences prefLoginReturn = getSharedPreferences("LoginData", Context.MODE_PRIVATE);
    System.out.println("LOGIN DATA");
    String userName = prefLoginReturn.getString("sUserName", "");

    String category = prefLoginReturn.getString("sCategory", "");
    System.out.println(category);
    String CardCode = prefLoginReturn.getString("CardCode", "");
    System.out.println(CardCode);

    JSONObject jsonObject = new JSONObject();
    // jsonObject.put("Category", "SPA");
    try {/*from   w  ww  . j a va  2s .  c  om*/
        // Find confirmation message
        // messageResult = jsonObject.getString("Result").toString();

        jsonObject.put("CODE", "");
        jsonObject.put("CARDCODE", CardCode);
        jsonObject.put("TITLETYPE", titleValue);
        jsonObject.put("TITLENO", Title.getText().toString());
        jsonObject.put("LOTTYPE", LotType.getText().toString());
        jsonObject.put("LOTNO", LotNo.getText().toString());
        jsonObject.put("FORMERLY_KNOWN_AS", Knownas.getText().toString());
        jsonObject.put("BPM", Pekan.getText().toString());
        jsonObject.put("STATE", stateval);
        jsonObject.put("AREA", Nageri.getText().toString());
        jsonObject.put("LOTAREA", LotArea.getText().toString());

        jsonObject.put("LASTUPDATEDON", LastUpdate.getText().toString());
        jsonObject.put("DEVELOPER", developerValue);
        jsonObject.put("DVLPR_CODE", developerValue_id);
        jsonObject.put("PROJECT_CODE", ProjectValue_id);
        jsonObject.put("PROJECTNAME", ProjectValue);
        jsonObject.put("DEVLICNO", DevLicense.getText().toString());
        jsonObject.put("DEVSOLICTOR", solicitorValue);
        jsonObject.put("DVLPR_SOL_CODE", solicitorValue_id);
        jsonObject.put("DVLPR_LOC", SolicitorLoc.getText().toString());
        jsonObject.put("LSTCHG_BANKCODE", bankValue_id);
        jsonObject.put("LSTCHG_BANKNAME", bankValue);
        jsonObject.put("LSTCHG_BRANCH", Branch.getText().toString());

        jsonObject.put("LSTCHG_PANO", PAName.getText().toString());
        jsonObject.put("LSTCHG_PRSTNO", PresentaionNo.getText().toString());
        jsonObject.put("PurchasePrice", PurchasePrice.getText().toString());

        if (QryGroup13.isChecked())
            jsonObject.put("PROPERTYCHARGED", "Y");
        else
            jsonObject.put("PROPERTYCHARGED", "N");

        //arrOfJson.put(jsonObject);
        System.out.println("JsonArray:" + jsonObject.toString());

        //upDateList();

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

    RequestParams params = new RequestParams();
    params.put("sJsonInput", jsonObject.toString());
    System.out.println("params");
    System.out.println(params);
    dialog = ProgressDialog.show(AddCaseStep2of4.this, "", "Loading...", true);
    RestService.post(METHOD_ADD_CASE2, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("onFailure");
            dialog.dismiss();

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("onFailure");
            System.out.println("AddCase2 Details Add Confirmed");
            System.out.println(arg2);
            dialog.dismiss();

            // Find status Response
            try {
                StatusResult = jsonResponse.getString("Result").toString();
                messageDisplay = jsonResponse.getString("DisplayMessage").toString();

                if (StatusResult.equals("SUCCESS")) {
                    Intent iAddBack = new Intent(AddCaseStep2of4.this, AddCaseStep3of4.class);

                    startActivity(iAddBack);

                    Toast.makeText(AddCaseStep2of4.this, messageDisplay, Toast.LENGTH_SHORT).show();
                } else if (jsonResponse.getString("CaseFileNo").toString() != "") {
                    // Find Response for ListView
                    try {

                        jsonCaselist = new ArrayList<HashMap<String, String>>();

                        for (int i = 0; i < arrayResponse.length(); i++) {
                            jsonResponse = arrayResponse.getJSONObject(i);
                            /*
                             * [ { "CaseFileNo": "1500000006", "RelatedFileNo":
                             * "", "BranchCode": "", "FileOpenedDate":
                             * "8/1/2015 12:00:00 AM", "IC": "3", "CaseType":
                             * "SPA", "ClientName": "", "BankName": "",
                             * "Branch": "", "LOTNo": "", "CaseAmount": "",
                             * "UserCode": "", "Status": "OPEN",
                             * "FileClosedDate": "" } ]
                             */

                            CaseList_CaseFileNo = jsonResponse.getString("CaseFileNo").toString();
                            CaseList_RelatedFileNo = jsonResponse.getString("RelatedFileNo").toString();
                            CaseList_BranchCode = jsonResponse.getString("BranchCode").toString();
                            CaseList_FileOpenedDate = jsonResponse.getString("FileOpenedDate").toString();
                            CaseList_IC = jsonResponse.getString("IC").toString();
                            CaseList_CaseType = jsonResponse.getString("CaseType").toString();
                            CaseList_ClientName = jsonResponse.getString("ClientName").toString();
                            CaseList_BankName = jsonResponse.getString("BankName").toString();
                            // CaseList_Branch =
                            // jsonResponse.getString("Branch").toString();
                            CaseList_LOTNo = jsonResponse.getString("LOTNo").toString();
                            CaseList_CaseAmount = jsonResponse.getString("CaseAmount").toString();
                            CaseList_UserCode = jsonResponse.getString("UserCode").toString();
                            CaseList_Status = jsonResponse.getString("Status").toString();
                            CaseList_FileClosedDate = jsonResponse.getString("FileClosedDate").toString();

                            // SEND JSON DATA INTO CASELIST
                            HashMap<String, String> caseListProperty = new HashMap<String, String>();

                            // Send JSON Data to list activity
                            System.out.println("SEND JSON CASE LIST");

                            caseListProperty.put("CaseFileNo_List", CaseList_CaseFileNo);
                            System.out.println(CaseList_CaseFileNo);
                            caseListProperty.put("RelatedFileNo_List", CaseList_RelatedFileNo);
                            System.out.println(CaseList_RelatedFileNo);
                            caseListProperty.put("BranchCode_List", CaseList_BranchCode);
                            System.out.println(CaseList_BranchCode);
                            caseListProperty.put("FileOpenedDate_List", CaseList_FileOpenedDate);
                            System.out.println(CaseList_FileOpenedDate);
                            caseListProperty.put("IC_List", CaseList_IC);
                            System.out.println(CaseList_IC);
                            caseListProperty.put("CaseType_List", CaseList_CaseType);
                            System.out.println(CaseList_CaseType);
                            caseListProperty.put("ClientName_List", CaseList_ClientName);
                            System.out.println(CaseList_ClientName);
                            caseListProperty.put("BankName_List", CaseList_BankName);
                            System.out.println(CaseList_BankName);
                            // caseListProperty.put("Branch_List",CaseList_Branch);
                            // System.out.println(CaseList_Branch);
                            caseListProperty.put("LOTNo_List", CaseList_LOTNo);
                            System.out.println(CaseList_LOTNo);
                            caseListProperty.put("CaseAmount_List", CaseList_CaseAmount);
                            System.out.println(CaseList_CaseAmount);
                            caseListProperty.put("UserCode_List", CaseList_UserCode);
                            System.out.println(CaseList_UserCode);
                            caseListProperty.put("Status_List", CaseList_Status);
                            System.out.println(CaseList_Status);
                            caseListProperty.put("FileClosedDate", CaseList_FileClosedDate);
                            System.out.println(CaseList_FileClosedDate);
                            System.out.println(" END SEND JSON CASE LIST");

                            jsonCaselist.add(caseListProperty);
                            System.out.println("JSON CASELIST");
                            System.out.println(jsonCaselist);
                        }

                    } catch (JSONException e) { // TODO Auto-generated catc
                        // block
                        e.printStackTrace();
                    }
                    //Toast.makeText(PropertyActivity.this, "Case Item Found", Toast.LENGTH_SHORT).show();
                    Intent intentList = new Intent(AddCaseStep2of4.this, PropertyRelatedCaseListActivity.class);
                    intentList.putExtra("ProjectJsonList", jsonCaselist);
                    startActivity(intentList);
                    System.out.println(arg2);

                } else {
                    Toast.makeText(AddCaseStep2of4.this, messageDisplay, Toast.LENGTH_SHORT).show();

                }

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

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Addcase3 Details Add Response");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void addCaseListOfItems() {

    RequestParams params = null;//from   ww w. jav  a 2 s . c  o  m
    params = new RequestParams();

    RestService.post(METHOD_ADDCASE_ITEMLIST, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Add Case List Item Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonItemList = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    itemCode = jsonResponse.getString("ItemCode").toString();
                    itemName = jsonResponse.getString("ItemName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> addCaseItemList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND ADD CASE ITEM LIST");
                    addCaseItemList.put("ItemCode_T", itemCode);
                    System.out.println(itemCode);
                    addCaseItemList.put("ItemName_T", itemName);
                    System.out.println(itemName);
                    System.out.println(" END ADD CASE ITEM LIST");

                    jsonItemList.add(addCaseItemList);
                    System.out.println("JSON ADD CASE ITEM LIST");
                    System.out.println(jsonItemList);
                }

            } catch (JSONException e) { // TODO Auto-generated
                // catch
                // block
                e.printStackTrace();
            }
            //Toast.makeText(AddCaseStep2of4.this, "AddCase Item Found", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
            // Simple Adapter for List
            SimpleAdapter simpleAdapter = new SimpleAdapter(AddCaseStep2of4.this, jsonItemList,
                    R.layout.listview_column_addcase_itemlist, new String[] { "ItemCode_T", "ItemName_T" },
                    new int[] { R.id.listAddCaseHeader_ItemCodeText, R.id.listAddCaseHeader_ItemNameText });

            listViewItem.setAdapter(simpleAdapter);

            listViewItem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                View ls = null;

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    if (get() != view && get() != null) {
                        get().setActivated(false);
                    }
                    //Toast.makeText(AddCaseStep2of4.this, "You Clicked at " + jsonItemList.get(position),
                    //   Toast.LENGTH_SHORT).show();
                    System.out.println(position);

                    //int mSelectedItem = position;      

                    view.setActivated(true);

                    // Get list of Item data
                    TextView c = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemCodeText);
                    itemCode = c.getText().toString();
                    System.out.println(itemCode);

                    TextView D = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemNameText);
                    itemName = D.getText().toString();

                    String data = (String) parent.getItemAtPosition(position).toString();
                    System.out.println(data);
                    set(view);

                    //store itemname and code in session
                    SharedPreferences prefLogin = getSharedPreferences("ItemData", Context.MODE_PRIVATE);

                    // We need an editor object to make changes
                    SharedPreferences.Editor edit = prefLogin.edit();

                    // Set/Store data
                    edit.putString("ItemCode", itemCode);
                    edit.putString("ItemName", itemName);
                    // Commit the changes
                    edit.commit();

                }

                private void set(View view) {
                    ls = view;
                }

                private View get() {
                    return ls;
                }
            });

            spinnerpropertyPROJECT.setSelection(2);
        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Add Case List Itemparse ParseResponse");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void dropdownTitle() throws JSONException {

    RequestParams params = null;/*from  w w  w.  j av  a 2 s. com*/
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "@AE_PROPERTY");
    jsonObject.put("FieldName", "TITLETYPE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(TitleType_DROPDOWN, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("Failed");

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("property Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonlistProject = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonlistProject.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonlistProject);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(AddCaseStep2of4.this, jsonlistProject, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertyTitleType.setAdapter(sAdapPROJ);

                /*for (int j = 0; j < jsonlistProject.size(); j++) {
                   if (jsonlistProject.get(j).get("Id_T").equals(projectDetailResponse)) {
                      TitleType_DROPDOWN.setSelection(j);
                      break;
                   }
                }*/

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

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Property Dropdown Details parse Response");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void dropdownBankDeveloperSolicitor() {

    RequestParams params = null;//w  ww  .  j  av a2  s .  co  m
    params = new RequestParams();

    RestService.post(METHOD_PROPERTY_BDS_DROPDOWN, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Property Activity GetDropdown Success Details ");
            try {
                // Create new list
                jsonlistBank = new ArrayList<HashMap<String, String>>();
                jsonlistDeveloper = new ArrayList<HashMap<String, String>>();
                jsonlistSolicitor = new ArrayList<HashMap<String, String>>();

                jsonResponse = new JSONObject(arg2);

                JSONArray jsonBank = jsonResponse.getJSONArray("Bank");
                for (int j = 0; j < jsonBank.length(); j++) {
                    JSONObject bank = jsonBank.getJSONObject(j);

                    id_b = bank.getString("BankCode").toString();
                    name_b = bank.getString("BankName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> bankList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON BANK LIST");
                    bankList.put("Id_T", id_b);
                    System.out.println(name);
                    bankList.put("Name_T", name_b);
                    System.out.println(name);
                    System.out.println(" END SEND JSON BANK LIST");

                    jsonlistBank.add(bankList);
                    System.out.println("JSON BANK LIST");
                    System.out.println(jsonlistProject);

                }

                // Spinner set Array Data in Drop down

                sAdapBANK = new SimpleAdapter(AddCaseStep2of4.this, jsonlistBank, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertyLSTCHG_BANKNAME.setAdapter(sAdapBANK);

                for (int j = 0; j < jsonlistBank.size(); j++) {
                    if (jsonlistBank.get(j).get("Name_T").equals(bankDetailResponse)) {
                        spinnerpropertyLSTCHG_BANKNAME.setSelection(j);
                        break;
                    }
                }

                JSONArray jsonDeveloper = jsonResponse.getJSONArray("Developer");
                for (int j = 0; j < jsonDeveloper.length(); j++) {
                    JSONObject dev = jsonDeveloper.getJSONObject(j);
                    id = dev.getString("DevCode").toString();
                    name = dev.getString("DevName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> devList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON DEV LIST");
                    devList.put("Id_B", id);
                    System.out.println(name);
                    devList.put("Name_B", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON DEV LIST");

                    jsonlistDeveloper.add(devList);
                    System.out.println("JSON DEV LIST");
                    System.out.println(jsonlistDeveloper);

                }
                // Spinner set Array Data in Drop down

                sAdapDEV = new SimpleAdapter(AddCaseStep2of4.this, jsonlistDeveloper, R.layout.spinner_item,
                        new String[] { "Id_B", "Name_B" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertyDEVELOPER.setAdapter(sAdapDEV);

                for (int j = 0; j < jsonlistDeveloper.size(); j++) {
                    if (jsonlistDeveloper.get(j).get("Id_B").equals(developerCodeResponse)) {
                        spinnerpropertyDEVELOPER.setSelection(j);
                        break;
                    }
                }

                JSONArray jsonSolicitor = jsonResponse.getJSONArray("Solicitor");
                for (int j = 0; j < jsonSolicitor.length(); j++) {
                    JSONObject solic = jsonSolicitor.getJSONObject(j);
                    id = solic.getString("SoliCode").toString();
                    name = solic.getString("SoliName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> solicList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON SOLICITOR LIST");
                    solicList.put("Id_T", id);
                    System.out.println(name);
                    solicList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON SOLICITOR LIST");

                    jsonlistSolicitor.add(solicList);
                    System.out.println("JSON SOLICITOR LIST");
                    System.out.println(jsonlistSolicitor);
                }

                // Spinner set Array Data in Drop down
                sAdapSOLIC = new SimpleAdapter(AddCaseStep2of4.this, jsonlistSolicitor, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertyDEVSOLICTOR.setAdapter(sAdapSOLIC);

                for (int j = 0; j < jsonlistSolicitor.size(); j++) {
                    if (jsonlistSolicitor.get(j).get("Id_T").equals(devSolictorCodeResponse)) {
                        spinnerpropertyDEVSOLICTOR.setSelection(j);
                        break;
                    }
                }

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

            System.out.println(arg2);

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {
            // Get Json response

            System.out.println("Property GetDropdown parse Response");
            System.out.println(arg0);
            return null;
        }

    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void dropdownState() throws JSONException {

    RequestParams params = null;//w  w  w.java 2s  .c  o m
    params = new RequestParams();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("TableName", "OCRD");
    jsonObject.put("FieldName", "STATE");
    params.put("sJsonInput", jsonObject.toString());

    RestService.post(METHOD_PROPERTY_STATE, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("State Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonliststate = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonliststate.add(proList);
                    System.out.println("JSON STATE LIST");
                    System.out.println(jsonliststate);
                }
                // Spinner set Array Data in Drop down

                sAdaparea = new SimpleAdapter(AddCaseStep2of4.this, jsonliststate, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertySTATE.setAdapter(sAdaparea);

                for (int j = 0; j < jsonliststate.size(); j++) {
                    if (jsonliststate.get(j).get("Id_T").equals(statevalue)) {
                        spinnerpropertySTATE.setSelection(j);
                        break;
                    }
                }

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

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("State Dropdown Details parse Response");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void dropdownPorject() {

    RequestParams params = null;//from  ww w. java  2s.c  om
    params = new RequestParams();

    RestService.post(METHOD_PROPERTY_LIST_DROPDOWN, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("property Dropdown Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonlistProject = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    id = jsonResponse.getString("Id").toString();
                    name = jsonResponse.getString("Name").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> proList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND JSON  LIST");
                    proList.put("Id_T", id);
                    System.out.println(name);
                    proList.put("Name_T", name);
                    System.out.println(name);
                    System.out.println(" END SEND JSON PROPERTY LIST");

                    jsonlistProject.add(proList);
                    System.out.println("JSON PROPERTY LIST");
                    System.out.println(jsonlistProject);
                }
                // Spinner set Array Data in Drop down

                sAdapPROJ = new SimpleAdapter(AddCaseStep2of4.this, jsonlistProject, R.layout.spinner_item,
                        new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name });

                spinnerpropertyPROJECT.setAdapter(sAdapPROJ);

                for (int j = 0; j < jsonlistProject.size(); j++) {
                    if (jsonlistProject.get(j).get("Id_T").equals(projectDetailResponse)) {
                        spinnerpropertyPROJECT.setSelection(j);
                        break;
                    }
                }

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

        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Property Dropdown Details parse Response");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.handshake.notifications.MyGcmListenerService.java

/**
 * Called when message is received.//from  w  ww  .j  a va  2 s.  c  o  m
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, final Bundle data) {
    SessionManager session = new SessionManager(this);
    if (!session.isLoggedIn())
        return;

    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */

    try {
        final JSONArray users = new JSONArray();
        if (!data.containsKey("user"))
            return;
        final JSONObject user = new JSONObject(data.getString("user"));
        users.put(user);
        UserServerSync.cacheUser(getApplicationContext(), users, new UserArraySyncCompleted() {
            @Override
            public void syncCompletedListener(final ArrayList<User> users) {
                if (users.size() == 0) {
                    sendNotification(data, 0, false);
                    return;
                }

                final long userId = users.get(0).getUserId();
                final boolean isContact = users.get(0).isContact();

                FeedItemServerSync.performSync(getApplicationContext(), new SyncCompleted() {
                    @Override
                    public void syncCompletedListener() {
                        ContactSync.performSync(getApplicationContext(), new SyncCompleted() {
                            @Override
                            public void syncCompletedListener() {
                                if (data.containsKey("group_id")) {
                                    Realm realm = Realm.getInstance(getApplicationContext());
                                    Group group = realm.where(Group.class)
                                            .equalTo("groupId", Long.parseLong(data.getString("group_id")))
                                            .findFirst();
                                    GroupServerSync.loadGroupMembers(group);
                                    realm.close();
                                }

                                sendNotification(data, userId, isContact);
                            }
                        });
                    }
                });
            }
        });
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.wso2.mobile.mdm.api.PhoneState.java

/**
 * Generate Data Usage Report/*from w w w  .j a  va 2s . c om*/
 */
public JSONObject takeDataUsageSnapShot() {
    previous = latest;
    latest = new TrafficSnapshot(context);
    JSONObject dataObj = new JSONObject();
    JSONArray jsonArray = new JSONArray();
    String latestRX, latestTX, previousRX, previousTX, deltaRX, deltaTX;
    latestRX = String.valueOf(formatSizeMB(latest.device.rx));
    latestTX = String.valueOf(formatSizeMB(latest.device.tx));
    try {
        dataObj.put("totalupload", latestRX);
        dataObj.put("totaldownload", latestTX);

        if (previous != null) {
            previousRX = String.valueOf(previous.device.rx);
            previousTX = String.valueOf(previous.device.tx);

            deltaRX = String.valueOf(latest.device.rx - previous.device.rx);
            deltaTX = String.valueOf(latest.device.tx - previous.device.tx);
        }

        ArrayList<String> log = new ArrayList<String>();
        HashSet<Integer> intersection = new HashSet<Integer>(latest.apps.keySet());

        if (previous != null) {
            intersection.retainAll(previous.apps.keySet());
        }

        for (Integer uid : intersection) {
            TrafficRecord latest_rec = latest.apps.get(uid);
            TrafficRecord previous_rec = (previous == null ? null : previous.apps.get(uid));

            jsonArray.add(getDataUseReport(latest_rec.tag, latest_rec, previous_rec, log));
        }

        dataObj.put("appdata", jsonArray);

        Collections.sort(log);

        for (String row : log) {
            Log.d("TrafficMonitor", row);
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return dataObj;
}

From source file:com.wso2.mobile.mdm.api.PhoneState.java

private JSONObject getDataUseReport(CharSequence name, TrafficRecord latest_rec, TrafficRecord previous_rec,
        ArrayList<String> rows) {
    JSONObject jsonObj = new JSONObject();
    if (latest_rec.rx > -1 || latest_rec.tx > -1) {
        StringBuilder buf = new StringBuilder(name);
        try {//from   ww w .  j ava 2 s  . c o  m
            jsonObj.put("package", name);
            jsonObj.put("name", appList.getAppNameFromPackage(name.toString()));
            jsonObj.put("upload", formatSizeMB(latest_rec.tx));
            jsonObj.put("download", formatSizeMB(latest_rec.rx));
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        buf.append("=");
        buf.append(String.valueOf(latest_rec.rx));
        buf.append(" received");

        if (previous_rec != null) {
            buf.append(" (delta=");
            buf.append(String.valueOf(latest_rec.rx - previous_rec.rx));
            buf.append(")");
        }

        buf.append(", ");
        buf.append(String.valueOf(latest_rec.tx));
        buf.append(" sent");

        if (previous_rec != null) {
            buf.append(" (delta=");
            buf.append(String.valueOf(latest_rec.tx - previous_rec.tx));
            buf.append(")");
        }

        rows.add(buf.toString());
    }
    return jsonObj;
}

From source file:asynctasks.UpdateTicketDataAsync.java

@Override
protected void onPostExecute(JSONObject json) {
    pDialog.cancel();//from   w  w  w.j  a va2 s . co  m
    int success;
    try {
        success = json.getInt("success");
        if (success == 1) {

            SavePicker frag = (SavePicker) fm.findFragmentByTag("Save");
            frag.iCcallback.updateTicket(true);
            frag.dialog.dismiss();

            Toast.makeText(context, "Updated Woot", Toast.LENGTH_SHORT).show();

        } else {
            Toast.makeText(context, "ERROR IN SUBMISSION", Toast.LENGTH_SHORT).show();
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}