@Override public void call(String type) { switch (type) { case Type.Request: launchAlarm(); try { Request request = getRequest(); saveRequest(request); publishRequestUpdate(request); launchActivityWithRequest(MainActivity.class, MainActivity.EXTRA_REQUEST, request); } catch (Exception e) { e.printStackTrace(); } break; case Type.Incoming: case Type.Quoting: case Type.QuoteAccepted: case Type.Working: case Type.Rating: case Type.Finished: case Type.Cancelled: case Type.Rejected: case Type.Failed: try { Job job = getJob(); saveJob(job); publishJobUpdate(job); launchActivityWithJob(MainActivity.class, MainActivity.EXTRA_JOB, job); } catch (Exception e) { e.printStackTrace(); } break; case Type.Location: try { Job job = mLab.getJob(); job.setLastLocation(getLocation()); saveJob(job); } catch (Exception e) { e.printStackTrace(); } break; case Type.Request_Cancelled: stopAlarm(); deleteRequest(); publishRequestUpdate(null); break; } }
protected void saveRequest(Request request) { mLab.setRequest(request).saveRequest(); }
protected void deleteRequest() { mLab.deleteRequest(); }
protected void saveJob(Job job) { mLab.setJob(job).saveJob(); }