Repository for the HealthTool which enables Apple users to analyse their health data from the Apple health app and prepares the data for contributing it for future studies on wearable data.
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.

97 lines
2.2 KiB

3 years ago
  1. package application.helpers;
  2. import application.UICoordinator;
  3. import application.enums.NavState;
  4. import application.helpers.wrappers.WrappedException;
  5. /**
  6. * Callback for the communication between the thread
  7. * {@link WorkWhileProgressThread} and the {@link UICoordinator}
  8. *
  9. * @author Bianca
  10. *
  11. */
  12. public class ChangeViewCallback
  13. {
  14. /**
  15. * Coordinator for accessing
  16. */
  17. private UICoordinator coord;
  18. public ChangeViewCallback(UICoordinator coord)
  19. {
  20. this.coord = coord;
  21. }
  22. /**
  23. * Calls the {@code fillDataList} method of the {@link UICoordinator}. Reads in
  24. * the health data.
  25. *
  26. * @throws WrappedException if there was an error reading the file
  27. */
  28. public void callFillDataList() throws WrappedException
  29. {
  30. this.coord.fillDataList();
  31. }
  32. /**
  33. * Calls the {@code createTempFiles} method of the {@link UICoordinator}.
  34. * Creates the temp files.
  35. *
  36. * @throws WrappedException If there was an error creating or writing to the
  37. * files
  38. */
  39. public void callCreateTempFiles() throws WrappedException
  40. {
  41. this.coord.createTempFiles();
  42. }
  43. /**
  44. * Changes to the overview view
  45. */
  46. public void callOverview()
  47. {
  48. this.coord.changeView(this.coord.getOverviewView());
  49. this.coord.updateNav(NavState.SELECT_DATA);
  50. }
  51. /**
  52. * In case an error occurred while the health data was read, the
  53. * {@link UICoordinator} will be informed.
  54. *
  55. * @param text The user readable information about the error.
  56. */
  57. public void callErrorReadingFile(String text)
  58. {
  59. this.coord.setErrorReadingFile(text);
  60. }
  61. /**
  62. * In case an error occurred while the files were written, the
  63. * {@link UICoordinator} will be informed.
  64. *
  65. * @param text The user readable information about the error.
  66. */
  67. public void callErrorWritingTemFiles(String text)
  68. {
  69. this.coord.setErrorWritingTempFiles(text);
  70. }
  71. /**
  72. * Changes to the inspect view
  73. */
  74. public void callInspect()
  75. {
  76. this.coord.changeView(this.coord.getInspectView());
  77. this.coord.updateNav(NavState.INSPECT);
  78. }
  79. /**
  80. * Changes to the inspect view after an error occurred.
  81. */
  82. public void callInspectWithError()
  83. {
  84. this.coord.changeView(this.coord.getInspectView());
  85. this.coord.updateNav(NavState.INSPECT_WITH_ERROR);
  86. }
  87. }