List of usage examples for com.google.gson JsonObject addProperty
public void addProperty(String property, Character value)
From source file:com.aliyun.odps.udf.utils.CounterUtils.java
License:Apache License
private static JsonObject toJson(Counter counter) { JsonObject js = new JsonObject(); js.addProperty("name", counter.getName()); js.addProperty("value", counter.getValue()); return js;//w w w . j a v a 2 s . c o m }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public long registerUser(String nickname) throws IOException { boolean ok;//from w ww. j av a2 s . c o m String res; JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); jsonParam.addProperty("devicename", "devicename"); jsonParam.addProperty("pushtoken", "pushtoken"); res = sendJsonPostRequest(REGISTER_USER, jsonParam.toString()); if (res == null) { throw new IOException("Unable to register"); } return Long.parseLong(res); }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean unregisterUser(String nickname) throws IOException { String res;/* www .j a v a 2 s .c o m*/ JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); res = sendJsonPostRequest(UNREGISTER_USER, jsonParam.toString()); if (res == null) { throw new IOException("Unable to register"); } return true; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean postComment(String nickname, String comment) throws IOException { String res;/*from w ww. j av a2 s .c om*/ JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); jsonParam.addProperty("comment", comment); res = sendJsonPostRequest(POST_COMMENT, jsonParam.toString()); if (res == null) { throw new IOException("Unable to post comment"); } if (res.equals("true")) return true; else return false; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean waitAtStop(String stopId, String nickname) throws IOException { String res;/* w w w .j a v a2 s.c o m*/ JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); jsonParam.addProperty("stopId", stopId); jsonParam.addProperty("agencyKey", agencyKey); res = sendJsonPostRequest(WAIT_AT_STOP, jsonParam.toString()); if (res == null) { throw new IOException("Unable to wait at stop"); } if (res.equals("true")) return true; else return false; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean leaveStop(String nickname) throws IOException { String res;/*w w w .j a v a 2 s . com*/ JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); res = sendJsonPostRequest(LEAVE_STOP, jsonParam.toString()); if (res == null) { throw new IOException("Unable to leave stop"); } if (res.equals("true")) return true; else return false; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean enterShuttle(String nickname, String shuttleId) throws IOException { String res;/*from w w w .jav a 2 s.c o m*/ JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); jsonParam.addProperty("shuttleId", shuttleId); jsonParam.addProperty("agencyKey", agencyKey); res = sendJsonPostRequest(ENTER_SHUTTLE, jsonParam.toString()); if (res == null) { throw new IOException("Unable to leave stop"); } if (res.equals("true")) return true; else return false; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean leaveShuttle(String nickname) throws IOException { String res;// www . j a va 2s . c om JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); res = sendJsonPostRequest(LEAVE_SHUTTLE, jsonParam.toString()); if (res == null) { throw new IOException("Unable to leave stop"); } if (res.equals("true")) return true; else return false; }
From source file:com.ambientic.shuttler.ShuttlerServiceImpl.java
License:Open Source License
@Override public boolean updatePosition(String nickname, PositionInfo position) throws IOException { String res;//from w ww . ja v a2 s. c om JsonObject jsonParam = new JsonObject(); jsonParam.addProperty("nickname", nickname); jsonParam.addProperty("position", gson.toJson(position)); res = sendJsonPostRequest(UPDATE_POSITION, jsonParam.toString()); if (res == null) { throw new IOException("Unable to leave stop"); } if (res.equals("true")) return true; else return false; }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.adapters.NotitiesAdapter.java
License:Mozilla Public License
/** * * @param view// w ww .j av a 2 s .c om * @param context * @param cursor */ @Override public void bindView(View view, final Context context, Cursor cursor) { // get the viewholder layout containing the view items ViewHolder viewHolder = (ViewHolder) view.getTag(); // bericht final String bericht = cursor.getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Notitie.COL_BERICHT)); viewHolder.berichtText.setText(bericht); // aangemaakt String aangemaakt = cursor .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Notitie.COL_AANGEMAAKT_DATUMTIJD)); try { Date aangemaaktDate = new SimpleDateFormat(context.getString(R.string.date_format_datumtijd), Locale.getDefault()).parse(aangemaakt); SimpleDateFormat sdf = new SimpleDateFormat(context.getString(R.string.date_format_tijd)); String aangemaaktTijd = sdf.format(aangemaaktDate); viewHolder.aangemaaktText.setText(aangemaaktTijd); } catch (java.text.ParseException e) { viewHolder.aangemaaktText.setText(""); } // afgevinkt int afgevinkt = cursor.getInt(cursor.getColumnIndex(MakkelijkeMarktProvider.Notitie.COL_AFGEVINKT)); if (afgevinkt > 0) { viewHolder.afgevinktCheck.setChecked(true); viewHolder.berichtText.setTextColor(ContextCompat.getColor(context, R.color.primary)); } else { viewHolder.afgevinktCheck.setChecked(false); viewHolder.berichtText.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); } // onclick afgevinkt final int id = cursor.getInt(cursor.getColumnIndex(MakkelijkeMarktProvider.Notitie.COL_ID)); viewHolder.afgevinktCheck.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean afgevinkt = ((CheckBox) v).isChecked(); // event to inform subscribers that we are starting to update the notitie EventBus.getDefault().post(new OnUpdateEvent(id, null)); // create json object from checked state, id, and bericht JsonObject notitiePayload = new JsonObject(); notitiePayload.addProperty(context.getString(R.string.makkelijkemarkt_api_notitie_payload_bericht), bericht); notitiePayload.addProperty( context.getString(R.string.makkelijkemarkt_api_notitie_payload_afgevinkt), afgevinkt); // send ApiPutNotitie and let the call update the database with the resulting object from the api call ApiPutNotitie apiPutNotitie = new ApiPutNotitie(context); apiPutNotitie.setId(id); apiPutNotitie.setPayload(notitiePayload); apiPutNotitie.enqueue(); } }); }