TestActivity.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.usai.apex;
  2. import android.support.v7.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. import com.usai.apex.ShipMap.ShipMap;
  5. import org.json.JSONException;
  6. import org.json.JSONObject;
  7. public class TestActivity extends AppCompatActivity {
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_test);
  12. String test = "{\n" +
  13. " \"title\":\"SH - PT. WANGSA MANUNGGAL JAYA PERKASA\",\n" +
  14. " \"icon\":\"status_vd\",\n" +
  15. " \"serial_no\":\"85625278dbaae299ffbbd10ee22cf875\",\n" +
  16. " \"hbol\":\"A1805340018\",\n" +
  17. " \"description\":\"A1805340018(1 containers)\",\n" +
  18. " \"detail\":\"Vessel Departure; IDSUB (SURABAYA, INDONESIA 2018-05-05)\",\n" +
  19. " \"date\":\"05/05/2018 - 06/02/2018\",\n" +
  20. " \"port\":\"IDSUB - USOAK\",\n" +
  21. " \"transport_stage\":\"3\",\n" +
  22. " \"locations\":{\n" +
  23. " \"por\":{\n" +
  24. " \"icon\":\"\",\n" +
  25. " \"lat\":\"-7.2000000000\",\n" +
  26. " \"lon\":\"112.7333333333\",\n" +
  27. " \"name\":\"SURABAYA\",\n" +
  28. " \"addr\":\"\"\n" +
  29. " },\n" +
  30. " \"pol\":{\n" +
  31. " \"icon\":\"\",\n" +
  32. " \"lat\":\"-7.2000000000\",\n" +
  33. " \"lon\":\"112.7333333333\",\n" +
  34. " \"name\":\"SURABAYA\",\n" +
  35. " \"addr\":\"\"\n" +
  36. " },\n" +
  37. " \"pod\":{\n" +
  38. " \"icon\":\"\",\n" +
  39. " \"lat\":\"37.7978400000\",\n" +
  40. " \"lon\":\"-122.2864000000\",\n" +
  41. " \"name\":\"OAKLAND\",\n" +
  42. " \"addr\":\"\"\n" +
  43. " }\n" +
  44. " }\n" +
  45. " }";
  46. ShipMap shipMap = findViewById(R.id.ship_map);
  47. shipMap.setShowPol(true);
  48. shipMap.setShowPod(true);
  49. shipMap.setShowPoe(true);
  50. shipMap.setShowPor(true);
  51. shipMap.setShowOrigin(true);
  52. shipMap.setShowDestination(true);
  53. shipMap.setShowCurrent(true);
  54. try {
  55. JSONObject j = new JSONObject(test);
  56. shipMap.showShipAnnotation(j.getJSONObject("locations"));
  57. } catch (JSONException e) {
  58. e.printStackTrace();
  59. }
  60. }
  61. }