You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StopsDbo.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package com.rthoni.stssaguenay.dbo;
  2. import android.util.Pair;
  3. import com.luticate.utils.dbo.LuDbo;
  4. import com.luticate.utils.dbo.LuPaginatedDbo;
  5. import org.json.JSONArray;
  6. import org.json.JSONException;
  7. import org.json.JSONObject;
  8. import java.util.HashMap;
  9. import java.util.List;
  10. import java.util.Vector;
  11. /**
  12. * Created by robin on 9/29/16.
  13. */
  14. public class StopsDbo extends LuDbo {
  15. public static class PaginatedStopsDbo extends LuPaginatedDbo<StopsDbo>
  16. {
  17. }
  18. @Override
  19. public void fromJson(JSONObject json) throws JSONException {
  20. _name = json.getString("name");
  21. _routes = new Vector<>();
  22. JSONArray routes = json.getJSONArray("routes");
  23. for (int i = 0; i < routes.length(); ++i) {
  24. _routes.add(routes.getString(i));
  25. }
  26. _id = json.getString("id");
  27. _posX = json.getDouble("posX");
  28. _posY = json.getDouble("posY");
  29. }
  30. @Override
  31. public HashMap<String, Object> toArray() {
  32. HashMap<String, Object> map = new HashMap<>();
  33. map.put("name", _name);
  34. map.put("routes", _routes);
  35. map.put("id", _id);
  36. map.put("posX", _posX);
  37. map.put("posY", _posY);
  38. return map;
  39. }
  40. protected String _name;
  41. protected List<String> _routes;
  42. protected String _id;
  43. protected double _posX;
  44. protected double _posY;
  45. public String getFullName()
  46. {
  47. return String.format("%s - %s", _id, _name);
  48. }
  49. public String getName() {
  50. return _name;
  51. }
  52. public void setName(String name) {
  53. _name = name;
  54. }
  55. public List<String> getRoutes() {
  56. return _routes;
  57. }
  58. public void setRoutes(List<String> routes) {
  59. _routes = routes;
  60. }
  61. public String getId() {
  62. return _id;
  63. }
  64. public void setId(String id) {
  65. _id = id;
  66. }
  67. public double getPosX() {
  68. return _posX;
  69. }
  70. public void setPosX(double posX) {
  71. _posX = posX;
  72. }
  73. public double getPosY() {
  74. return _posY;
  75. }
  76. public void setPosY(double posY) {
  77. _posY = posY;
  78. }
  79. }