Java Code Examples for android.os.FileObserver#MOVED_FROM
The following examples show how to use
android.os.FileObserver#MOVED_FROM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ControlObserver.java From ClashForMagisk with GNU General Public License v3.0 | 6 votes |
private void restart() { //noinspection ResultOfMethodCallIgnored dataDir.mkdirs(); fileObserver = new FileObserver(dataDir.getAbsolutePath(), FileObserver.CREATE | FileObserver.DELETE_SELF | FileObserver.MOVED_FROM | FileObserver.MOVED_TO) { @Override public void onEvent(int event, String file) { Log.d(Constants.TAG, "Control Directory Changed " + file); if ((event & FileObserver.DELETE_SELF) != 0) { restart(); } else { file = file.toUpperCase(); switch (file) { case "STOP": case "START": case "RESTART": callback.onUserControl(file); } } } }; fileObserver.startWatching(); }
Example 2
Source File: PhonkServerService.java From PHONK with GNU General Public License v3.0 | 6 votes |
@Override public void onEvent(int event, String file) { MLog.d(TAG, "qq -> " + event); MLog.d(TAG, "qq2 -> " + file); if ((FileObserver.CREATE & event) != 0) { MLog.d(TAG, "File created [" + PhonkSettings.getBaseDir() + file + "]"); EventBus.getDefault().postSticky(new Events.ProjectEvent(Events.PROJECT_REFRESH_LIST, null)); } else if ((FileObserver.DELETE & event) != 0) { MLog.d(TAG, "File deleted [" + PhonkSettings.getBaseDir() + file + "]"); EventBus.getDefault().postSticky(new Events.ProjectEvent(Events.PROJECT_REFRESH_LIST, null)); } else if ((FileObserver.MOVED_FROM & event) != 0) { MLog.d(TAG, "File moved from [" + PhonkSettings.getBaseDir() + file + "]"); EventBus.getDefault().postSticky(new Events.ProjectEvent(Events.PROJECT_REFRESH_LIST, null)); } else if ((FileObserver.MOVED_TO & event) != 0) { MLog.d(TAG, "File moved to [" + PhonkSettings.getBaseDir() + file + "]"); EventBus.getDefault().postSticky(new Events.ProjectEvent(Events.PROJECT_REFRESH_LIST, null)); } }
Example 3
Source File: AbstractBrowserFragment.java From SimpleExplorer with GNU General Public License v3.0 | 6 votes |
@Override public void onEvent(int event, String path) { // this will automatically update the directory when an action like this // will be performed switch (event & FileObserver.ALL_EVENTS) { case FileObserver.CREATE: case FileObserver.CLOSE_WRITE: case FileObserver.MOVE_SELF: case FileObserver.MOVED_TO: case FileObserver.MOVED_FROM: case FileObserver.ATTRIB: case FileObserver.DELETE: case FileObserver.DELETE_SELF: sHandler.removeCallbacks(mLastRunnable); sHandler.post(mLastRunnable = new NavigateRunnable((AbstractBrowserActivity) getActivity(), path)); break; } }
Example 4
Source File: Enhancement.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
private static List<String> getModulesList(final int user) { final int index = modulesList.indexOfKey(user); if (index >= 0) { return modulesList.valueAt(index); } final String filename = String.format("/data/user_de/%s/%s/conf/enabled_modules.list", user, APPLICATION_ID); final FileObserver observer = new FileObserver(filename) { @Override public void onEvent(int event, @Nullable String path) { switch (event) { case FileObserver.MODIFY: modulesList.put(user, readModulesList(filename)); break; case FileObserver.MOVED_FROM: case FileObserver.MOVED_TO: case FileObserver.MOVE_SELF: case FileObserver.DELETE: case FileObserver.DELETE_SELF: modulesList.remove(user); modulesListObservers.remove(user); break; } } }; modulesListObservers.put(user, observer); final List<String> list = readModulesList(filename); modulesList.put(user, list); observer.startWatching(); return list; }
Example 5
Source File: FileSystemScanner.java From document-viewer with GNU General Public License v3.0 | 5 votes |
public static String toString(final int event) { switch (event) { case FileObserver.ACCESS: return "ACCESS"; case FileObserver.MODIFY: return "MODIFY"; case FileObserver.ATTRIB: return "ATTRIB"; case FileObserver.CLOSE_WRITE: return "CLOSE_WRITE"; case FileObserver.CLOSE_NOWRITE: return "CLOSE_NOWRITE"; case FileObserver.OPEN: return "OPEN"; case FileObserver.MOVED_FROM: return "MOVED_FROM"; case FileObserver.MOVED_TO: return "MOVED_TO"; case FileObserver.CREATE: return "CREATE"; case FileObserver.DELETE: return "DELETE"; case FileObserver.DELETE_SELF: return "DELETE_SELF"; case FileObserver.MOVE_SELF: return "MOVE_SELF"; default: return "0x" + Integer.toHexString(event); } }
Example 6
Source File: OfflineVideoManager.java From android-viewer-for-khan-academy with GNU General Public License v3.0 | 5 votes |
@Override public void onEvent(int event, final String path) { if (path == null) { return; } switch (event & FileObserver.ALL_EVENTS) { case FileObserver.CLOSE_WRITE: // Download complete, or paused when wifi is disconnected. Possibly reported more than once in a row. // Useful for noticing when a download has been paused. For completions, register a receiver for // DownloadManager.ACTION_DOWNLOAD_COMPLETE. break; case FileObserver.OPEN: // Called for both read and write modes. // Useful for noticing a download has been started or resumed. break; case FileObserver.DELETE: case FileObserver.MOVED_FROM: // This video is lost never to return. Remove it. handler.post(new Runnable() { @Override public void run() { DatabaseHelper helper = dataService.getHelper(); helper.removeDownloadFromDownloadManager(helper.getVideoForFilename(path)); } }); break; case FileObserver.MODIFY: // Called very frequently while a download is ongoing (~1 per ms). // This could be used to trigger a progress update, but that should probably be done less often than this. shouldPoll = true; break; } }