List of usage examples for org.json JSONArray toString
public String toString()
From source file:org.nuxeo.html.utils.operations.HTMLGetLinksOp.java
@OperationMethod public String run(String inHTML) throws IOException, JSONException { JSONArray array = new JSONArray(); if (inHTML != null) { HTMLParser hp = new HTMLParser(inHTML); ArrayList<LinkInfo> links = hp.getLinks(); array = buildJsonString(links);//from w ww. jav a 2 s . c om } return array.toString(); }
From source file:mp.teardrop.SongTimeline.java
/** * Writes the current songs and state to the given SharedPreferences. *///from ww w . j ava 2s . co m public void writeState(SharedPreferences prefs) throws JSONException { // Must update PlaybackService.STATE_VERSION when changing behavior here. synchronized (this) { ArrayList<Song> songs = mSongs; JSONArray jsonBourneArray = new JSONArray(); for (Song song : songs) { if (song != null) { jsonBourneArray.put(song.toJsonObject()); } } SharedPreferences.Editor editor = prefs.edit(); editor.putString(PlaybackService.PREFS_SAVED_SONGS, jsonBourneArray.toString()); editor.commit(); } }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
private void genMsgReceiveBroadcastReceiver() { if (null == mMsgReceiveBroadcaseReceiver) { mMsgReceiveBroadcaseReceiver = new BroadcastReceiver() { @Override/* ww w. j a v a 2 s . c om*/ public void onReceive(Context context, Intent intent) { if (INTENT_ACTION.equals(intent.getAction())) { Bundle bundle = intent.getExtras(); if (null != bundle) { // pdus?? Object[] pdus = (Object[]) bundle.get("pdus"); // SmsMessage[] msgs = new SmsMessage[pdus.length]; for (int i = 0; i < pdus.length; i++) { // ???pdu?,? msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); } JSONArray receivedMsgs = buildSmsList(msgs); XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString()); ((XFaceMainActivity) mContext).getEventCenter().sendEventAsync(evt); } } } }; } }
From source file:com.keylesspalace.tusky.util.NotificationManager.java
/** * Takes a given Mastodon notification and either creates a new Android notification or updates * the state of the existing notification to reflect the new interaction. * * @param context to access application preferences and services * @param notifyId an arbitrary number to reference this notification for any future action * @param body a new Mastodon notification *///from w w w . j a va 2 s .com public static void make(final Context context, final int notifyId, Notification body) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences notificationPreferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE); if (!filterNotification(preferences, body)) { return; } createNotificationChannels(context); String rawCurrentNotifications = notificationPreferences.getString("current", "[]"); JSONArray currentNotifications; try { currentNotifications = new JSONArray(rawCurrentNotifications); } catch (JSONException e) { currentNotifications = new JSONArray(); } boolean alreadyContains = false; for (int i = 0; i < currentNotifications.length(); i++) { try { if (currentNotifications.getString(i).equals(body.account.getDisplayName())) { alreadyContains = true; } } catch (JSONException e) { Log.d(TAG, Log.getStackTraceString(e)); } } if (!alreadyContains) { currentNotifications.put(body.account.getDisplayName()); } notificationPreferences.edit().putString("current", currentNotifications.toString()).apply(); Intent resultIntent = new Intent(context, MainActivity.class); resultIntent.putExtra("tab_position", 1); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); Intent deleteIntent = new Intent(context, NotificationClearBroadcastReceiver.class); PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0, deleteIntent, PendingIntent.FLAG_CANCEL_CURRENT); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getChannelId(body)) .setSmallIcon(R.drawable.ic_notify).setContentIntent(resultPendingIntent) .setDeleteIntent(deletePendingIntent).setColor(ContextCompat.getColor(context, (R.color.primary))) .setDefaults(0); // So it doesn't ring twice, notify only in Target callback setupPreferences(preferences, builder); if (currentNotifications.length() == 1) { builder.setContentTitle(titleForType(context, body)) .setContentText(truncateWithEllipses(bodyForType(body), 40)); //load the avatar synchronously Bitmap accountAvatar; try { accountAvatar = Picasso.with(context).load(body.account.avatar) .transform(new RoundedTransformation(7, 0)).get(); } catch (IOException e) { Log.d(TAG, "error loading account avatar", e); accountAvatar = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar_default); } builder.setLargeIcon(accountAvatar); } else { try { String format = context.getString(R.string.notification_title_summary); String title = String.format(format, currentNotifications.length()); String text = truncateWithEllipses(joinNames(context, currentNotifications), 40); builder.setContentTitle(title).setContentText(text); } catch (JSONException e) { Log.d(TAG, Log.getStackTraceString(e)); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setVisibility(android.app.Notification.VISIBILITY_PRIVATE); builder.setCategory(android.app.Notification.CATEGORY_SOCIAL); } android.app.NotificationManager notificationManager = (android.app.NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); //noinspection ConstantConditions notificationManager.notify(notifyId, builder.build()); }
From source file:com.abeo.tia.noordin.ProcessCasePurchaser.java
private void confirm_allvalues_btn() throws JSONException { // TODO Auto-generated method stub String spinnertype1 = getSelectedItem( ((Spinner) findViewById(R.id.spinner_PurchaserType)).getSelectedItem().toString()); String spinnertype2 = getSelectedItem( ((Spinner) findViewById(R.id.spinner_PurchaserType2)).getSelectedItem().toString()); String spinnertype3 = getSelectedItem( ((Spinner) findViewById(R.id.spinner_PurchaserType3)).getSelectedItem().toString()); String spinnertype4 = getSelectedItem( ((Spinner) findViewById(R.id.spinner_PurchaserType4)).getSelectedItem().toString()); if (rep_firm.isChecked()) { f_yes = "Y"; } else if (!rep_firm.isChecked()) { f_yes = "N"; }/*from w w w . j av a2 s.co m*/ if (lawer_rep.isChecked()) { l_yes = "Y"; } else if (!lawer_rep.isChecked()) { l_yes = "N"; } // String json_element = "[{\"Case\":\"1500000001\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"CaseStatus\":\"OPEN\",\"FileOpenDate\":\"10/10/2015 12:00:00 AM\",\"CaseFileNo\":\"JJ/1500000001/\",\"KIV\":\"\",\"TabId\":\"2\",\"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\":\"\",\"RedStmtDate\":\"\",\"RedPayDate\":\"\",\"RepByFirm\":\"\",\"LoanCaseNo\":\"1234\",\"Project\":\"\",\"MasterBankName\":\"\",\"BranchName\":\"\",\"Address\":\"\",\"PAName\":\"\",\"BankRef\":\"\",\"BankInsDate\":\"2015/10/11\",\"LOFDate\":\"\",\"BankSolicitor\":\"\",\"SoliLoc\":\"\",\"SoliRef\":\"\",\"TypeofLoan\":\"\",\"TypeofFacility\":\"\",\"FacilityAmt\":\"\",\"Repaymt\":\"\",\"IntrstRate\":\"\",\"MonthlyInstmt\":\"\",\"TermLoanAmt\":\"\",\"Interest\":\"\",\"ODLoan\":\"\",\"MRTA\":\"\",\"BankGuarantee\":\"\",\"LetterofCredit\":\"\",\"TrustReceipt\":\"\",\"Others\":\"\",\"LoanDet1\":\"\",\"LoanDet2\":\"\",\"LoanDet3\":\"\",\"LoanDet4\":\"\",\"LoanDet5\":\"\"},\"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\":\"\"}}]"; 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\":\"2\",\"Details\":{\"LA\":\"\",\"MANAGER\":\"\",\"InCharge\":\"\",\"CustomerService\":\"\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"FileLocation\":\"\",\"FileClosedDate\":\"\",\"VendAcqDt\":\"\",\"CompanyBuisnessSearch\":\"\",\"BankWindingSearch\":\"\"},\"Purchaser\":{\"" + "PurRepresentedByFirm" + "\":" + "\"" + f_yes + "\",\"" + "PurlawyerRepresented" + "\":" + "\"" + l_yes + "\",\"" + "PurSPADate" + "\":" + "\"" + spa_date.getText().toString() + "\", \"" + "PurEntryOfPrivateCaveat" + "\":" + "\"" + entry_private_caveat.getText().toString() + "\", \"" + "PurWithOfPrivateCaveat" + "\":" + "\"" + withdrawal_private_caveat.getText().toString() + "\" ,\"" + "PurFirstName" + "\":" + "\"" + name1.getText().toString() + "\",\"" + "PurFirstID" + "\":" + "\"" + brn_no1.getText().toString() + "\",\"" + "PurFirstTaxNo" + "\":" + "\"" + tax_no1.getText().toString() + "\",\"" + "PurFirstContactNo" + "\":" + "\"" + contact_no1.getText().toString() + "\",\"" + "PurFirstType" + "\":" + "\"" + spinnertype1 + "\",\"" + "PurSecName" + "\":" + "\"" + name2.getText().toString() + "\",\"" + "PurSecID" + "\":" + "\"" + brn_no2.getText().toString() + "\",\"" + "PurSecTaxNo" + "\":" + "\"" + tax_no2.getText().toString() + "\",\"" + "PurSecContactNo" + "\":" + "\"" + contact_no2.getText().toString() + "\",\"" + "PurSecType" + "\":" + "\"" + spinnertype2 + "\",\"" + "PurThirdName" + "\":" + "\"" + name3.getText().toString() + "\",\"" + "PurThirdID" + "\":" + "\"" + brn_no3.getText().toString() + "\",\"" + "PurThirdTaxNo" + "\":" + "\"" + tax_no3.getText().toString() + "\",\"" + "PurThirdContactNo" + "\":" + "\"" + contact_no3.getText().toString() + "\",\"" + "PurThirdType" + "\":" + "\"" + spinnertype3 + "\",\"" + "PurFourthName" + "\":" + "\"" + name4.getText().toString() + "\",\"" + "PurFourthID" + "\":" + "\"" + brn_no4.getText().toString() + "\",\"" + "PurFourthTaxNo" + "\":" + "\"" + tax_no4.getText().toString() + "\",\"" + "PurFourthContactNo" + "\":" + "\"" + contact_no4.getText().toString() + "\",\"" + "PurFourthType" + "\":" + "\"" + spinnertype4 + "\"},\"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\":\"\",\"RedStmtDate\":\"\",\"RedPayDate\":\"\",\"RepByFirm\":\"\",\"LoanCaseNo\":\"1234\",\"Project\":\"\",\"MasterBankName\":\"\",\"BranchName\":\"\",\"Address\":\"\",\"PAName\":\"\",\"BankRef\":\"\",\"BankInsDate\":\"2015/10/11\",\"LOFDate\":\"\",\"BankSolicitor\":\"\",\"SoliLoc\":\"\",\"SoliRef\":\"\",\"TypeofLoan\":\"\",\"TypeofFacility\":\"\",\"FacilityAmt\":\"\",\"Repaymt\":\"\",\"IntrstRate\":\"\",\"MonthlyInstmt\":\"\",\"TermLoanAmt\":\"\",\"Interest\":\"\",\"ODLoan\":\"\",\"MRTA\":\"\",\"BankGuarantee\":\"\",\"LetterofCredit\":\"\",\"TrustReceipt\":\"\",\"Others\":\"\",\"LoanDet1\":\"\",\"LoanDet2\":\"\",\"LoanDet3\":\"\",\"LoanDet4\":\"\",\"LoanDet5\":\"\"},\"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; 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(); } Log.v("texttt", list.toString()); 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(ProcessCasePurchaser.this, ProcessCaseVendor.class); startActivity(iAddBack); Toast.makeText(ProcessCasePurchaser.this, messageDisplay, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(ProcessCasePurchaser.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; } }); }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
private void getActiveNotifications(Context context, Intent intent) { String[] keys = intent.getStringArrayExtra("data"); if (keys.length > 0) { JSONArray notifications = new JSONArray(); for (StatusBarNotification statusBarNotification : notificationHub.getActiveNotifications(keys)) { notifications.put(NotificationDataHelper.getStatusBarNotificationDataAsJSON(statusBarNotification)); }/*from ww w . ja va 2 s .c o m*/ Intent dataIntent = new Intent(NotificationHubConfig.NOTIFICATION_HUB_DATA_RECIEVER_INTENT); dataIntent.putExtra("command", "get-all"); dataIntent.putExtra("data", " " + notifications.toString() + "\n"); context.getApplicationContext().sendBroadcast(dataIntent); } }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
private void getAllActiveNotifications(Context context) { JSONArray notifications = new JSONArray(); for (StatusBarNotification statusBarNotification : notificationHub.getActiveNotifications()) { notifications.put(NotificationDataHelper.getStatusBarNotificationDataAsJSON(statusBarNotification)); }//from w w w.j a v a 2s . co m if (notifications.length() > 0) { Intent dataIntent = new Intent(NotificationHubConfig.NOTIFICATION_HUB_DATA_RECIEVER_INTENT); dataIntent.putExtra("command", "get-all"); dataIntent.putExtra("data", " " + notifications.toString() + "\n"); context.getApplicationContext().sendBroadcast(dataIntent); } }
From source file:com.redip.servlet.GetDistinctValueFromNonconformitiesAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS); String id = policy.sanitize(request.getParameter("parameter")); String parameter = ParameterParserUtil.parseStringParam(id, ""); ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); IQualityNonconformitiesActionService nqcService = appContext .getBean(IQualityNonconformitiesActionService.class); try {//www .java 2 s .c o m JSONArray valueList = new JSONArray(); try { for (String value : nqcService.findDistinctValueFromParameter(parameter)) { valueList.put(value); } } catch (Exception ex) { response.setContentType("text/html"); response.getWriter().print(ex); } response.setContentType("application/json"); response.getWriter().print(valueList.toString()); } catch (Exception e) { Logger.log(GetInvariantList.class.getName(), Level.FATAL, "" + e); response.setContentType("text/html"); response.getWriter().print(e.getMessage()); } }
From source file:com.android.quicksearchbox.ShortcutRepositoryTest.java
public void testExtraDataStringWithDodgyChars() { assertExtra("String extra with newlines", "extra_string", "line\nline\nline\n"); JSONArray a = new JSONArray(); a.put(true);// ww w . j a v a2 s .c o m a.put(42); a.put("hello"); a.put("hello \"again\""); assertExtra("String extra with JSON", "extra_string", a.toString()); assertExtra("String extra with control chars", "extra_string", "\0\b\t\f\r"); }
From source file:br.unicamp.cst.learning.glas.LearnerCodelet.java
public LearnerCodelet(int nStimuli, int nActions, RawMemory rawMemory, WorkingStorage ws) { this.nStimuli = nStimuli; this.nActions = nActions; this.rawMemory = rawMemory; //this.setTimeStep(0); // No waiting between reruns? if (rawMemory != null) this.SOLUTION_TREE_MO = rawMemory.createMemoryObject("SOLUTION_TREE", ""); this.addOutput(this.SOLUTION_TREE_MO); if (ws != null) ws.putMemoryObject(this.SOLUTION_TREE_MO); GlasOptProblem gop = new GlasOptProblem(nNodes, nStimuli, nActions); //TODO Which is better here, getting a random initial solution or a fixed standard one? // Such as: [0,1,1,1,1,1,1,0,1,2,3,4,5,6,0,1,1,1,1,1,1] // IntegerGenotype random_tree_gen = gop.getGlasGenotype(); // int[] random_tree_gen_fixed = {1,1,1,1,1,1,1,2,3,4,5,6,1,1,1,1,1,1}; int[] initial_solution_tree_int = { 0, 1, 0, 1, 0, 1 }; JSONArray initial_solution_tree_json = new JSONArray(); for (int i = 0; i < initial_solution_tree_int.length; i++) { initial_solution_tree_json.put(initial_solution_tree_int[i]); }//from ww w .j ava2 s . c o m this.SOLUTION_TREE_MO.updateI(initial_solution_tree_json.toString()); // [0,1,1,2,3,4,5,0,1,2,3,4,5,6,0,1,1,1,1,2,2] if (ws != null) ws.registerCodelet(this, "EVENTS_SEQUENCE", 0); }