The initial commit of the calibration view code needed a large refactor. A lot of the problem was caused by not having an Observable directory. I found out the Java 7 introduced an API for this, so I went about creating an rxjava wrapper for the utility. I also ended up learning how to use the Observable#create method the safe way, which is by creating an OnSubscribe class to handle back-pressure. The outcome was the DirectoryUtil class which has a static method for turning a directory into an Observable. I have this observable emit the Path of a file when it is newly created or is destroyed (We have no need to modify a file in place, so I left that out, however, it wouldn't be to hard to create).
In this PR I change the way that the controllers learn about changes in the gallery model, ie) the files in a directory. I'm now using an ObservableList in the model that will hold the new GalleryImageView objects (a way to display a thumbnail and load a fullscreen image). Deleting an image file from the CameraCalibrationViewController code now creates a logical reaction in the rest of the controllers. The DirectoryUtilObservable detects the deleted file and notifies the GalleryViewController. This controller deletes the image from the list in the GalleryViewObservableList which notifies the CameraCalibrationViewController that the file is removed. This allows the CameraCalibrationViewController to safely unsubscribe from events related to that image even when the file is deleted by an external program, ie) if the user deletes the files using the file explorer.
The initial commit of the calibration view code needed a large refactor. A lot of the problem was caused by not having an
Observable
directory. I found out the Java 7 introduced an API for this, so I went about creating anrxjava
wrapper for the utility. I also ended up learning how to use theObservable#create
method the safe way, which is by creating anOnSubscribe
class to handle back-pressure. The outcome was theDirectoryUtil
class which has a static method for turning a directory into anObservable
. I have this observable emit thePath
of a file when it is newly created or is destroyed (We have no need to modify a file in place, so I left that out, however, it wouldn't be to hard to create).In this PR I change the way that the controllers learn about changes in the gallery model, ie) the files in a directory. I'm now using an
ObservableList
in the model that will hold the newGalleryImageView
objects (a way to display a thumbnail and load a fullscreen image). Deleting an image file from theCameraCalibrationViewController
code now creates a logical reaction in the rest of the controllers. TheDirectoryUtil
Observable
detects the deleted file and notifies theGalleryViewController
. This controller deletes the image from the list in theGalleryView
ObservableList
which notifies theCameraCalibrationViewController
that the file is removed. This allows theCameraCalibrationViewController
to safely unsubscribe from events related to that image even when the file is deleted by an external program, ie) if the user deletes the files using the file explorer.