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.example.android.popularmoviesist2.data.FetchDetailMovieTask.java

private String[] getMoviesDataFromJson(String moviesJsonStr) throws JSONException {

    final String JSON_LIST = "results";
    final String JSON_AUTHOR = "author";
    final String JSON_CONTENT = "content";

    final String[] result = new String[2];

    try {/*from   ww w  .j  a v a 2s  .  c  om*/
        JSONObject moviesJson = new JSONObject(moviesJsonStr);
        JSONArray moviesArray = moviesJson.getJSONArray(JSON_LIST);

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

            JSONObject movie = moviesArray.getJSONObject(i);
            String author = movie.getString(JSON_AUTHOR);
            String content = movie.getString(JSON_CONTENT);

            result[0] = author;
            result[1] = content;

        }
        return result;
    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
        return null;
    }

}

From source file:com.example.android.popularmoviesist2.data.FetchDetailMovieTask.java

@Override
protected String[] doInBackground(String... params) {

    HttpURLConnection urlConnection = null;
    BufferedReader reader = null;
    movieId = params[0];//from  w ww  .  j  ava 2s.  c  om

    String moviesJsonStr = null;

    final String MOVIE_REVIEW_URL = "http://api.themoviedb.org/3/movie/" + movieId + "/reviews";

    final String APIKEY_PARAM = "api_key";

    try {
        Uri builtUri = Uri.parse(MOVIE_REVIEW_URL).buildUpon()
                .appendQueryParameter(APIKEY_PARAM, BuildConfig.OPEN_TMDB_MAP_API_KEY).build();

        URL url = new URL(builtUri.toString());

        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.connect();

        // Read the input stream into a String
        InputStream inputStream = urlConnection.getInputStream();
        StringBuffer buffer = new StringBuffer();
        if (inputStream == null) {
            return null;
        }

        reader = new BufferedReader(new InputStreamReader(inputStream));

        String line;
        while ((line = reader.readLine()) != null) {
            buffer.append(line + "\n");
        }

        if (buffer.length() == 0) {
            return null;
        }

        moviesJsonStr = buffer.toString();

        //Log.v(LOG_TAG, "Movies string: " + moviesJsonStr);
        return getMoviesDataFromJson(moviesJsonStr);

    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    } catch (IOException e) {
        Log.e(LOG_TAG, "Error ", e);
        return null;
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, "Error closing stream", e);
            }
        }
    }

    return null;
}

From source file:com.example.cuisoap.agrimac.machineRegister.driverInfoFragment.java

private void getDriverData() {
    if (drive_type.getCheckedRadioButtonId() == R.id.machine_drivetype_1) {
        if (driver_name.getText().toString().equals("")) {
            Toast.makeText(context, "??", Toast.LENGTH_SHORT).show();
        } else if (driver_age.getText().toString().equals("")) {
            Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
        }//w  w  w  . j av  a 2s.c  om

        else if (license_path == null) {
            Toast.makeText(context, "?", Toast.LENGTH_SHORT).show();
        } else if (license_type.getText().toString().equals("")) {
            Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
        } else {
            data = new JSONObject();
            try {
                data.put("drive_type", "1");
                data.put("driver_name", driver_name.getText().toString());
                data.put("driver_age", driver_age.getText().toString());
                if (driver_gender.getCheckedRadioButtonId() == R.id.driver_male)
                    data.put("driver_gender", "1");
                else
                    data.put("driver_gender", "2");
                data.put("license_path", license_path);
                data.put("license_type", license_type.getText().toString());
                mListener.onButtonClicked(data, 1);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    } else {
        data = new JSONObject();
        try {
            data.put("drive_type", "2");
            mListener.onButtonClicked(data, 1);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.mmclass.libsiren.Util.java

public static float[] getFloatArray(SharedPreferences pref, String key) {
    float[] array = null;
    String s = pref.getString(key, null);
    if (s != null) {
        try {/*from  w  w  w.  j  a v  a 2s  .  c  o m*/
            JSONArray json = new JSONArray(s);
            array = new float[json.length()];
            for (int i = 0; i < array.length; i++)
                array[i] = (float) json.getDouble(i);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return array;
}

From source file:com.mmclass.libsiren.Util.java

public static void putFloatArray(Editor editor, String key, float[] array) {
    try {/*from w w w .j a v  a  2  s .  c o  m*/
        JSONArray json = new JSONArray();
        for (float f : array)
            json.put(f);
        editor.putString("equalizer_values", json.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:ru.jkff.antro.ProfileListener.java

public void dumpReport(Report report, String reportFilename) {
    try {/*from  w  ww .j a  v a 2  s  .  co  m*/
        JSONArray res = new JSONArray();

        for (String file : report.getUsedBuildFiles()) {
            AnnotatedFile f = report.getAnnotatedFile(file);

            JSONArray annotatedFile = new JSONArray();
            for (int i = 0; i < f.getLineCount(); ++i) {
                String line = f.getLine(i);
                Stat stat = f.getStat(i);
                annotatedFile.put(annotateLine(line, i, stat));
            }

            JSONObject fileObj = new JSONObject();
            fileObj.put("name", file);
            fileObj.put("stat", annotatedFile);

            res.put(fileObj);
        }

        if (!dontWriteFile) {
            FileWriter w = new FileWriter(reportFilename);
            JSONArray data = new JSONArray();
            data.put(res);
            data.put(toJSON(report.getTrace()));
            w.write(data.toString(2));
            w.close();
        }
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:info.aamulumi.tomate.RequestSender.java

/**
 * Send HTTP Request with params (x-url-encoded)
 *
 * @param requestURL     - URL of the request
 * @param method         - HTTP method (GET, POST, PUT, DELETE, ...)
 * @param urlParameters  - parameters send in URL
 * @param bodyParameters - parameters send in body (encoded)
 * @return JSONObject returned by the server
 *///from w  w  w  .  j av a  2s  .com
public JSONObject makeHttpRequest(String requestURL, String method, HashMap<String, String> urlParameters,
        HashMap<String, String> bodyParameters) {
    HttpURLConnection connection = null;
    URL url;
    JSONObject jObj = null;

    try {
        // Check if we must add parameters in URL
        if (urlParameters != null) {
            String stringUrlParams = getFormattedParameters(urlParameters);
            url = new URL(requestURL + "?" + stringUrlParams);
        } else
            url = new URL(requestURL);

        // Create connection
        connection = (HttpURLConnection) url.openConnection();

        // Add cookies to request
        if (mCookieManager.getCookieStore().getCookies().size() > 0)
            connection.setRequestProperty("Cookie",
                    TextUtils.join(";", mCookieManager.getCookieStore().getCookies()));

        // Set request parameters
        connection.setReadTimeout(5000);
        connection.setConnectTimeout(5000);
        connection.setRequestMethod(method);
        connection.setDoInput(true);

        // Check if we must add parameters in body
        if (bodyParameters != null) {
            // Create a string with parameters
            String stringBodyParameters = getFormattedParameters(bodyParameters);

            // Set output request parameters
            connection.setDoOutput(true);
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            connection.setRequestProperty("Content-Length",
                    "" + Integer.toString(stringBodyParameters.getBytes().length));
            connection.setRequestProperty("Content-Language", "fr-FR");

            // Send body's request
            OutputStream os = connection.getOutputStream();
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
            writer.write(stringBodyParameters);

            writer.flush();
            writer.close();
            os.close();
        }

        // Get response code
        int responseCode = connection.getResponseCode();

        // If response is 200 (OK)
        if (responseCode == HttpsURLConnection.HTTP_OK) {
            // Keep new cookies in the manager
            List<String> cookiesHeader = connection.getHeaderFields().get(COOKIES_HEADER);
            if (cookiesHeader != null) {
                for (String cookie : cookiesHeader)
                    mCookieManager.getCookieStore().add(null, HttpCookie.parse(cookie).get(0));
            }

            // Read the response
            String line;
            BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            StringBuilder sb = new StringBuilder();

            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }

            // Parse the response to a JSON Object
            try {
                jObj = new JSONObject(sb.toString());
            } catch (JSONException e) {
                Log.d("JSON Parser", "Error parsing data " + e.toString());
                Log.d("JSON Parser", "Setting value of jObj to null");
                jObj = null;
            }
        } else {
            Log.w("HttpUrlConnection", "Error : server sent code : " + responseCode);
        }
    } catch (MalformedURLException e) {
        Log.e("Network", "Error in URL");
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        // Close connection
        if (connection != null)
            connection.disconnect();
    }

    return jObj;
}

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

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

    // load title from strings.xml
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    // load icons from strings.xml
    navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
    set(navMenuTitles, navMenuIcons);/*from w ww.jav a2s .  c  o  m*/

    // Find the SharedPreferences Firstname
    SharedPreferences FirstName = getSharedPreferences("LoginData", Context.MODE_PRIVATE);
    String FirName = FirstName.getString("FIRSETNAME", "");
    TextView welcome = (TextView) findViewById(R.id.textView_welcome);
    welcome.setText("Welcome " + FirName);

    // 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);

    details_btn = (Button) findViewById(R.id.button_LoanDetails);
    purchaser_btn = (Button) findViewById(R.id.button_LoanPurchaser);
    vendor_btn = (Button) findViewById(R.id.button_LoanVendor);
    property_btn = (Button) findViewById(R.id.button_LoanProperty);
    loan_subsidary_btn = (Button) findViewById(R.id.button_LoanLoanSubsidiary);
    process_btn = (Button) findViewById(R.id.button_LoanProcess);
    confirm_btn = (Button) findViewById(R.id.button_LoanConfirm);
    walkin = (Button) findViewById(R.id.button_LoanWalkin);

    details_btn.setOnClickListener(this);
    purchaser_btn.setOnClickListener(this);
    vendor_btn.setOnClickListener(this);
    property_btn.setOnClickListener(this);
    loan_subsidary_btn.setOnClickListener(this);
    process_btn.setOnClickListener(this);
    confirm_btn.setOnClickListener(this);
    walkin.setOnClickListener(this);

    //Edittext
    case_type = (EditText) findViewById(R.id.editText_LoanCaseType);
    case_file_no = (EditText) findViewById(R.id.editText_LoanCaseFileNo);
    file_open_date = (EditText) findViewById(R.id.editText_LoanFileOpenDate);
    req_for_redemption = (EditText) findViewById(R.id.editText_ProcessCase1LA);
    red_state_date = (EditText) findViewById(R.id.editText_LoanRedemptionStatementDate);
    red_payment_date = (EditText) findViewById(R.id.editText_LoanRedemptionPaymentDate);
    loan_case_no = (EditText) findViewById(R.id.editText_LoanCaseNo);
    project = (EditText) findViewById(R.id.editText_LoanProject);
    spinnerpropertyLSTCHG_BANKNAME = (Spinner) findViewById(R.id.banksp);
    branch_name = (EditText) findViewById(R.id.editText_LoanBranchName);
    addr = (EditText) findViewById(R.id.editText_LoanAdddress);
    pa_name = (EditText) findViewById(R.id.editText_LoanPAName);
    bank_ref = (EditText) findViewById(R.id.editText_LoanBankRef);
    bank_instr_date = (EditText) findViewById(R.id.editText_LoanBankInstructionDate);
    letter_offer_date = (EditText) findViewById(R.id.editText_LoanLetterOfOfferDate);
    bank_solicitor = (EditText) findViewById(R.id.editText_LoanBankRefSolicitor);
    solicitor_loc = (EditText) findViewById(R.id.editText_LoanSolicitorLoc);
    solicitor_ref = (EditText) findViewById(R.id.editText_LoanSolicitor);
    type_facility = (EditText) findViewById(R.id.editText_LoanTypeOfFacility);
    facility_amt = (EditText) findViewById(R.id.editText_FacilityAmount);
    repayment = (EditText) findViewById(R.id.editText_LoanRepayment);
    interest_rate = (EditText) findViewById(R.id.editText_LoanInterestRate);
    monthly_installment = (EditText) findViewById(R.id.editText_LoanMonthlyinstallment);
    term_loanamt = (EditText) findViewById(R.id.editText_LoanTermLoanAmount);
    interest = (EditText) findViewById(R.id.editText_LoanBankInsterest);
    od_loan = (EditText) findViewById(R.id.editText_ODLoan);
    mrta = (EditText) findViewById(R.id.editText_LoanMRTA);
    bank_guarantee = (EditText) findViewById(R.id.editText_LoanBankGuarantee);
    letter_credit = (EditText) findViewById(R.id.editText_LetterOfCredit);
    trust_receipt = (EditText) findViewById(R.id.editText_LoanTrustReciept);
    others = (EditText) findViewById(R.id.editText_LoanOthers);
    rep_firm = (CheckBox) findViewById(R.id.LoanFrim);

    LoanDet1 = (EditText) findViewById(R.id.editText_LoanDet1);
    LoanDet2 = (EditText) findViewById(R.id.editText_LoanDet2);
    LoanDet3 = (EditText) findViewById(R.id.editText_LoanDet3);
    LoanDet4 = (EditText) findViewById(R.id.editText_LoanDet4);
    LoanDet5 = (EditText) findViewById(R.id.editText_LoanDet5);

    req_for_redemption.setOnClickListener(this);
    bank_instr_date.setOnClickListener(this);
    red_state_date.setOnClickListener(this);
    red_payment_date.setOnClickListener(this);
    letter_offer_date.setOnClickListener(this);

    try {

        setvaluestoUI();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    // spinners initialization
    spinner_case_status = (Spinner) findViewById(R.id.case_status);
    spinner_kiv = (Spinner) findViewById(R.id.spinner_ProcessCase1KIV);
    spinner_LoanTypeOfLoans = (Spinner) findViewById(R.id.spinner_LoanTypeOfLoan);
    // Spinner click listener
    spinner_case_status.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            caseValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            titleValue = TEXT.getText().toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    // Spinner click listener
    spinner_kiv.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            casetype = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            casetype_value = TEXT.getText().toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    // Spinner click listener
    spinnerpropertyLSTCHG_BANKNAME.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            bankValue_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            bankValue = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinner_LoanTypeOfLoans.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            casetype = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            TypeofLoan_value = TEXT.getText().toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    disableHeaderfields();
}

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

@Override
public void onClick(View view) {
    if (view == details_btn) {
        Intent to_purchaser = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseDetails.class);
        startActivity(to_purchaser);/*from ww  w  .  j a v  a  2 s .  com*/
    }
    if (view == purchaser_btn) {
        Intent to_purchaser = new Intent(ProcessCaseLoanPrincipal.this, ProcessCasePurchaser.class);
        startActivity(to_purchaser);
    }
    if (view == vendor_btn) {
        Intent to_vendor = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseVendor.class);
        startActivity(to_vendor);
    }
    if (view == property_btn) {
        Intent to_loan_pricipal = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseProperty.class);
        startActivity(to_loan_pricipal);
    }

    if (view == loan_subsidary_btn) {
        Intent to_loan_subsidiary = new Intent(ProcessCaseLoanPrincipal.this, ProcesscaseLoanSubsidiary.class);
        startActivity(to_loan_subsidiary);
    }
    if (view == process_btn) {
        Intent to_loan_subsidiary = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseProcessTab.class);
        startActivity(to_loan_subsidiary);
    }
    if (view == walkin) {
        Intent i = new Intent(ProcessCaseLoanPrincipal.this, WalkInActivity.class);
        startActivity(i);
    }

    if (view == req_for_redemption) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, req_for_redemption1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == bank_instr_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, bank_instr_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == red_state_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, red_state_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == red_payment_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, red_payment_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == letter_offer_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, letter_offer_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == confirm_btn) {
        try {
            confirm_allvalues_btn();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

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

private void confirm_allvalues_btn() throws JSONException {
    // TODO Auto-generated method stub

    String json_element = "[{\"Case\":" + "\"" + jsonResponseconfirm.get("Case").toString() + "\",\"CaseType\":"
            + "\"" + jsonResponseconfirm.get("CaseType").toString()
            + "\",\"CaseStatus\":\"OPEN\",\"FileOpenDate\":\"10/10/2015 12:00:00 AM\",\"CaseFileNo\":\"JJ/1500000001/\",\"KIV\":\"\",\"TabId\":\"5\",\"Details\":{\"LA\":\"\",\"MANAGER\":\"\",\"InCharge\":\"\",\"CustomerService\":\"\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"FileLocation\":\"\",\"FileClosedDate\":\"\",\"VendAcqDt\":\"\",\"CompanyBuisnessSearch\":\"\",\"BankWindingSearch\":\"\"},\"Purchaser\":{\"PurRepresentedByFirm\":\"N\",\"PurlawyerRepresented\":\"N\",\"PurSPADate\":\"1/1/1900 12:00:00 AM\",\"PurEntryOfPrivateCaveat\":\"Chase\",\"PurWithOfPrivateCaveat\":\"Rane\",\"PurFirstName\":\"Name1\",\"PurFirstID\":\"Id1\",\"PurFirstTaxNo\":\"Tax1\",\"PurFirstContactNo\":\"9784561233\",\"PurFirstType\":\"CORPORATE\",\"PurSecName\":\"Name2\",\"PurSecID\":\"Id2\",\"PurSecTaxNo\":\"Tax2\",\"PurSecContactNo\":\"9784561234\",\"PurSecType\":\"INDIVIDUAL\",\"PurThirdName\":\"Name3\",\"PurThirdID\":\"Id3\",\"PurThirdTaxNo\":\"Tax3\",\"PurThirdContactNo\":\"9784561234\",\"PurThirdType\":\"INDIVIDUAL\",\"PurFourthName\":\"Name4\",\"PurFourthID\":\"Id4\",\"PurFourthTaxNo\":\"Tax4\",\"PurFourthContactNo\":\"9784561235\",\"PurFourthType\":\"INDIVIDUAL\"},\"Vendor\":{\"VndrRepresentedByFirm\":\"N\",\"VndrlawyerRepresented\":\"Y\",\"VndrReqDevConsent\":\"Name\",\"VndrReceiveDevConsent\":\"Sam\",\"VndrFirstName\":\"Name1\",\"VndrFirstID\":\"Id1\",\"VndrFirstTaxNo\":\"Tax1\",\"VndrFirstContactNo\":\"9784561233\",\"VndrFirstType\":\"CORPORATE\",\"VndrSecName\":\"Name2\",\"VndrSecID\":\"Id2\",\"VndrSecTaxNo\":\"Tax2\",\"VndrSecContactNo\":\"9784561234\",\"VndrSecType\":\"INDIVIDUAL\",\"VndrThirdName\":\"Name3\",\"VndrThirdID\":\"Id3\",\"VndrThirdTaxNo\":\"Tax3\",\"VndrThirdContactNo\":\"9784561234\",\"VndrThirdType\":\"INDIVIDUAL\",\"VndrFourthName\":\"Name4\",\"VndrFourthID\":\"Id4\",\"VndrFourthTaxNo\":\"Tax4\",\"VndrFourthContactNo\":\"9784561235\",\"VndrFourthType\":\"INDIVIDUAL\"},\"Property\":{\"TitleType\":\"KEKAL\",\"CertifiedPlanNo\":\"\",\"LotNo\":\"\",\"PreviouslyKnownAs\":\"\",\"State\":\"\",\"Area\":\"\",\"BPM\":\"\",\"GovSurvyPlan\":\"\",\"LotArea\":\"12345\",\"Developer\":\"\",\"Project\":\"\",\"DevLicenseNo\":\"\",\"DevSolicitor\":\"\",\"DevSoliLoc\":\"\",\"TitleSearchDate\":\"\",\"DSCTransfer\":\"\",\"DRCTransfer\":\"\",\"FourteenADate\":\"\",\"DRTLRegistry\":\"\",\"PropertyCharged\":\"\",\"BankName\":\"\",\"Branch\":\"\",\"PAName\":\"\",\"PresentationNo\":\"\",\"ExistChargeRef\":\"\",\"ReceiptType\":\"\",\"ReceiptNo\":\"\",\"ReceiptDate\":\"\",\"PurchasePrice\":\"1452\",\"AdjValue\":\"\",\"VndrPrevSPAValue\":\"\",\"Deposit\":\"\",\"BalPurPrice\":\"\",\"LoanAmount\":\"\",\"LoanCaseNo\":\"1234\",\"DiffSum\":\"\",\"RedAmt\":\"\",\"RedDate\":\"\",\"DefRdmptSum\":\"\"},\"LoanPrinciple\":{\""
            + "ReqRedStatement" + "\":" + "\"" + req_for_redemption.getText().toString() + "\",\""
            + "RedStmtDate" + "\":" + "\"" + red_state_date.getText().toString() + "\",\"" + "RedPayDate"
            + "\":" + "\"" + red_payment_date.getText().toString() + "\",\"RepByFirm\":" + "\""
            + rep_firm.isChecked() + "\",\"" + "LoanCaseNo" + "\":" + "\"" + loan_case_no.getText().toString()
            + "\",\"" + "Project" + "\":" + "\"" + project.getText().toString() + "\",\"" + "MasterBankName"
            + "\":" + "\"" + bankValue + "\",\"" + "BranchName" + "\":" + "\""
            + branch_name.getText().toString() + "\",\"" + "Address" + "\":" + "\"" + addr.getText().toString()
            + "\",\"" + "PAName" + "\":" + "\"" + pa_name.getText().toString() + "\",\"" + "BankRef" + "\":"
            + "\"" + bank_ref.getText().toString() + "\",\"" + "BankInsDate" + "\":" + "\""
            + bank_instr_date.getText().toString() + "\",\"" + "LOFDate" + "\":" + "\""
            + letter_offer_date.getText().toString() + "\",\"" + "BankSolicitor" + "\":" + "\""
            + bank_solicitor.getText().toString() + "\",\"" + "SoliLoc" + "\":" + "\""
            + solicitor_loc.getText().toString() + "\",\"" + "SoliRef" + "\":" + "\""
            + solicitor_ref.getText().toString() + "\",\"TypeofLoan\":" + "\"" + TypeofLoan_value + "\",\""
            + "TypeofFacility" + "\":" + "\"" + type_facility.getText().toString() + "\",\"" + "FacilityAmt"
            + "\":" + "\"" + facility_amt.getText().toString() + "\",\"" + "Repaymt" + "\":" + "\""
            + repayment.getText().toString() + "\",\"" + "IntrstRate" + "\":" + "\""
            + interest_rate.getText().toString() + "\",\"" + "MonthlyInstmt" + "\":" + "\""
            + monthly_installment.getText().toString() + "\",\"" + "TermLoanAmt" + "\":" + "\""
            + term_loanamt.getText().toString() + "\",\"" + "Interest" + "\":" + "\""
            + interest.getText().toString() + "\",\"" + "ODLoan" + "\":" + "\"" + od_loan.getText().toString()
            + "\",\"" + "MRTA" + "\":" + "\"" + mrta.getText().toString() + "\",\"" + "BankGuarantee" + "\":"
            + "\"" + bank_guarantee.getText().toString() + "\",\"" + "LetterofCredit" + "\":" + "\""
            + letter_credit.getText().toString() + "\",\"" + "TrustReceipt" + "\":" + "\""
            + trust_receipt.getText().toString() + "\",\"" + "Others" + "\":" + "\""
            + others.getText().toString() + "\",\"LoanDet1\":" + "\"" + LoanDet1.getText().toString()
            + "\",\"LoanDet2\":" + "\"" + LoanDet2.getText().toString() + "\",\"LoanDet3\":" + "\""
            + LoanDet3.getText().toString() + "\",\"LoanDet4\":" + "\"" + LoanDet4.getText().toString()
            + "\",\"LoanDet5\":" + "\"" + LoanDet5.getText().toString()
            + "\"},\"LoanSubsidary\":{\"LoanDocForBankExe\":\"Exe 1\",\"FaciAgreeDate\":\"\",\"LoanDocRetFromBank\":\"\",\"DischargeofCharge\":\"\",\"FirstTypeofFacility\":\"\",\"FirstFacilityAmt\":\"\",\"FirstRepaymt\":\"\",\"FirstIntrstRate\":\"\",\"FirstMonthlyInstmt\":\"1500\",\"FirstTermLoanAmt\":\"\",\"FirstInterest\":\"\",\"FirstODLoan\":\"\",\"FirstMRTA\":\"\",\"FirstBankGuarantee\":\"\",\"FirstLetterofCredit\":\"\",\"FirstTrustReceipt\":\"\",\"FirstOthers\":\"Sample\",\"SecTypeofFacility\":\"\",\"SecFacilityAmt\":\"\",\"SecRepaymt\":\"\",\"SecIntrstRate\":\"12%\",\"SecMonthlyInstmt\":\"\",\"SecTermLoanAmt\":\"\",\"SecInterest\":\"\",\"SecODLoan\":\"\",\"SecMRTA\":\"\",\"SecBankGuarantee\":\"\",\"SecLetterofCredit\":\"\",\"SecTrustReceipt\":\"45A\",\"SecOthers\":\"\",\"ThirdTypeofFacility\":\"Sample_Data\",\"ThirdFacilityAmt\":\"\",\"ThirdRepaymt\":\"\",\"ThirdIntrstRate\":\"\",\"ThirdMonthlyInstmt\":\"\",\"ThirdTermLoanAmt\":\"587.15\",\"ThirdInterest\":\"\",\"ThirdODLoan\":\"\",\"ThirdMRTA\":\"\",\"ThirdBankGuarantee\":\"\",\"ThirdLetterofCredit\":\"\",\"ThirdTrustReceipt\":\"\",\"ThirdOthers\":\"\",\"FourthTypeofFacility\":\"Sample4\",\"FourthFacilityAmt\":\"\",\"FourthRepaymt\":\"15\",\"FourthIntrstRate\":\"\",\"FourthMonthlyInstmt\":\"\",\"FourthTermLoanAmt\":\"\",\"FourthInterest\":\"21\",\"FourthODLoan\":\"\",\"FourthMRTA\":\"\",\"FourthBankGuarantee\":\"\",\"FourthLetterofCredit\":\"\",\"FourthTrustReceipt\":\"\",\"FourthOthers\":\"\",\"FifthTypeofFacility\":\"Sample 5\",\"FifthFacilityAmt\":\"\",\"FifthRepaymt\":\"\",\"FifthIntrstRate\":\"\",\"FifthMonthlyInstmt\":\"\",\"FifthTermLoanAmt\":\"\",\"FifthInterest\":\"10\",\"FifthODLoan\":\"\",\"FifthMRTA\":\"\",\"FifthBankGuarantee\":\"\",\"FifthLetterofCredit\":\"\",\"FifthTrustReceipt\":\"Test\",\"FifthOthers\":\"\"}}]";
    Log.e("pur_string", json_element);

    JSONObject valuesObject = null;//from   ww w . j a v  a2  s .  c o  m
    JSONArray list = null;
    try {
        list = new JSONArray(json_element);
        valuesObject = list.getJSONObject(0);

        /*valuesObject.put("PurSPADate",spa_date.getText().toString());
        valuesObject.put("PurEntryOfPrivateCaveat", entry_private_caveat.getText().toString());
        valuesObject.put("PurWithOfPrivateCaveat", withdrawal_private_caveat.getText().toString());
        valuesObject.put("PurFirstName", name1.getText().toString());
        valuesObject.put("PurFirstID", brn_no1.getText().toString());
        valuesObject.put("PurFirstTaxNo", tax_no1.getText().toString());
        valuesObject.put("PurFirstContactNo", contact_no1.getText().toString());*/

        //list.put(valuesObject);

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

    RequestParams params = new RequestParams();
    params.put("sJsonInput", list.toString());
    System.out.println("params");

    RestService.post(CONFIRM_BTN_REQUEST, 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 process case purchaser");
        }

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

            // Find status Response
            try {
                StatusResult = jsonResponse.getString("Result").toString();
                messageDisplay = jsonResponse.getString("DisplayMessage").toString();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (StatusResult.equals("SUCCESS")) {
                Intent iAddBack = new Intent(ProcessCaseLoanPrincipal.this, ProcesscaseLoanSubsidiary.class);
                startActivity(iAddBack);
                Toast.makeText(ProcessCaseLoanPrincipal.this, messageDisplay, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(ProcessCaseLoanPrincipal.this, messageDisplay, Toast.LENGTH_SHORT).show();

            }
        }

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

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

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