diff --git a/app/src/main/java/uk/org/openseizuredetector/EditEventActivity.java b/app/src/main/java/uk/org/openseizuredetector/EditEventActivity.java index 15f7627..180a05c 100644 --- a/app/src/main/java/uk/org/openseizuredetector/EditEventActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/EditEventActivity.java @@ -52,17 +52,29 @@ public class EditEventActivity extends AppCompatActivity Log.v(TAG, "onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_event); + + mWac = new WebApiConnection(this, this, this, this); + mLm = new LogManager(this); + + Bundle extras = getIntent().getExtras(); if (extras != null) { Long eventId = extras.getLong("eventId"); - Log.v(TAG, "onCreate - eventId=" + eventId); mEventId = eventId; - mWac.getEvent(mEventId, (JSONObject eventObj) -> { - mEventObj = eventObj; - updateUi(); - // FIXME: modify updateUi to use mEventObj - } - ); + Log.v(TAG, "onCreate - mEventId=" + mEventId); + try { + mWac.getEvent(mEventId, (JSONObject eventObj) -> { + Log.v(TAG,"onCreate.getEvent"); + mEventObj = eventObj; + Log.v(TAG, "onCreate.getEvent: eventObj=" + eventObj.toString()); + updateUi(); + // FIXME: modify updateUi to use mEventObj + } + ); + } catch (Exception e) { + Log.e(TAG,"ERROR:"+e.getMessage()); + e.printStackTrace(); + } } mUtil = new OsdUtil(this, serverStatusHandler); @@ -77,8 +89,6 @@ public class EditEventActivity extends AppCompatActivity mEventSubTypeRg = findViewById(R.id.eventSubTypeRg); mEventSubTypeRg.setOnCheckedChangeListener(onEventSubTypeChange); - mWac = new WebApiConnection(this, this, this, this); - mLm = new LogManager(this); // Retrieve the JSONObject containing the standard event types. // Note this obscure syntax is to avoid having to create another interface, so it is worth it :) diff --git a/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java b/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java index 31d93e8..7d42e08 100644 --- a/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java +++ b/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java @@ -219,6 +219,7 @@ public class WebApiConnection { } public boolean getEvent(Long eventId, Consumer callback) { + //Long eventId=Long.valueOf(285); Log.v(TAG, "getEvent()"); String urlStr = mUrlBase + "/api/events/"+eventId; Log.v(TAG, "getEvent(): urlStr=" + urlStr);