Package com.mku.android.file
Class AndroidSharedFileObserver
java.lang.Object
FileObserver
com.mku.android.file.AndroidSharedFileObserver
public class AndroidSharedFileObserver
extends FileObserver
Implementation of a file observer that detects when a share file has been edited
by external apps. Use this to get notified to re-import the file into the drive.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clear all file observers.static AndroidSharedFileObserver
createFileObserver
(File cacheFile, SalmonFile salmonFile, Consumer<AndroidSharedFileObserver> onFileContentsChanged) Create a file observer that will detect if the file contents of a shared salmon file have changedReturns the encrypted salmon file that is associated with the shared filevoid
When a file event happens.static void
removeFileObserver
(File cacheFile) Remove the shared filed associated with this observer.void
setSalmonFile
(SalmonFile salmonFile) Set the salmon file associated with the shared file to observer.
-
Method Details
-
createFileObserver
public static AndroidSharedFileObserver createFileObserver(File cacheFile, SalmonFile salmonFile, Consumer<AndroidSharedFileObserver> onFileContentsChanged) Create a file observer that will detect if the file contents of a shared salmon file have changed- Parameters:
cacheFile
- The temporary private decrypted cached filesalmonFile
- The encrypted file that is associated with the shared fileonFileContentsChanged
- Action notifier when file contents change- Returns:
- The shared file observer
-
removeFileObserver
Remove the shared filed associated with this observer.- Parameters:
cacheFile
- The cache file.
-
clearFileObservers
public static void clearFileObservers()Clear all file observers. Call this to release any observes you no longer need. -
onEvent
When a file event happens.- Parameters:
e
- The type of event which happenedpath
- The path, relative to the main monitored file or directory, of the file or directory which triggered the event. This value can benull
for certain events, such as#MOVE_SELF
.
-
getSalmonFile
Returns the encrypted salmon file that is associated with the shared file- Returns:
- The file
-
setSalmonFile
Set the salmon file associated with the shared file to observer.- Parameters:
salmonFile
- The file
-