Java Code Examples for android.os.FileObserver#MODIFY
The following examples show how to use
android.os.FileObserver#MODIFY .
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: PFileIO.java From PHONK with GNU General Public License v3.0 | 6 votes |
PFileObserver(AppRunner appRunner, String path) { fileObserver = new FileObserver(appRunner.getProject().getFullPathForFile(path), FileObserver.CREATE | FileObserver.MODIFY | FileObserver.DELETE) { @Override public void onEvent(int event, String file) { ReturnObject ret = new ReturnObject(); if ((FileObserver.CREATE & event) != 0) { ret.put("action", "created"); } else if ((FileObserver.DELETE & event) != 0) { ret.put("action", "deleted"); } else if ((FileObserver.MODIFY & event) != 0) { ret.put("action", "modified"); } ret.put("file", file); if (callback != null) callback.event(ret); } }; fileObserver.startWatching(); getAppRunner().whatIsRunning.add(this); }
Example 2
Source File: logcat_activity.java From dingtalk-sms with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onEvent(int event, String path) { if (event == FileObserver.MODIFY) { runOnUiThread(() -> logcat.setText(public_func.read_log(context))); } }
Example 3
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 4
Source File: FolderObserver.java From Cirrus_depricated with GNU General Public License v2.0 | 5 votes |
/** * Receives and processes events about updates of the monitor folder and its children files. * * @param event Kind of event occurred. * @param path Relative path of the file referred by the event. */ @Override public void onEvent(int event, String path) { Log_OC.d(TAG, "Got event " + event + " on FOLDER " + mPath + " about " + ((path != null) ? path : "")); boolean shouldSynchronize = false; synchronized(mObservedChildren) { if (path != null && path.length() > 0 && mObservedChildren.containsKey(path)) { if ( ((event & FileObserver.MODIFY) != 0) || ((event & FileObserver.ATTRIB) != 0) || ((event & FileObserver.MOVED_TO) != 0) ) { if (!mObservedChildren.get(path)) { mObservedChildren.put(path, Boolean.valueOf(true)); } } if ((event & FileObserver.CLOSE_WRITE) != 0 && mObservedChildren.get(path)) { mObservedChildren.put(path, Boolean.valueOf(false)); shouldSynchronize = true; } } } if (shouldSynchronize) { startSyncOperation(path); } if ((event & IN_IGNORE) != 0 && (path == null || path.length() == 0)) { Log_OC.d(TAG, "Stopping the observance on " + mPath); } }
Example 5
Source File: SettingsProvider.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
public SettingsFileObserver(int userHandle, String path) { super(path, FileObserver.CLOSE_WRITE | FileObserver.CREATE | FileObserver.DELETE | FileObserver.MOVED_TO | FileObserver.MODIFY); mUserHandle = userHandle; mPath = path; }
Example 6
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 7
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; } }
Example 8
Source File: logcat_activity.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onEvent(int event, String path) { if (event == FileObserver.MODIFY && path.contains("error.log")) { runOnUiThread(() -> logcat.setText(public_func.read_log(context, line))); } }
Example 9
Source File: OomAdjOverrider.java From mockgeofix with Apache License 2.0 | 4 votes |
private void onEvent(int i, String s) { if (i != FileObserver.MODIFY) { return; } write(); }
Example 10
Source File: DeviceSucker.java From CameraV with GNU General Public License v3.0 | 4 votes |
@Override public void onEvent(int event, String path) { String parse = null; switch(event) { case FileObserver.CREATE: parse = "file created"; break; case FileObserver.MODIFY: parse = "file modified"; break; case FileObserver.CLOSE_WRITE: parse = "file closed/writen"; break; case FileObserver.ACCESS: //parse = "file accessed"; break; case FileObserver.DELETE: parse = "file deleted"; break; case FileObserver.OPEN: //parse = "file opened"; break; case FileObserver.CLOSE_NOWRITE: //parse = "file closed/not writen"; break; case FileObserver.ATTRIB: parse = "file attribs changed"; break; } if(parse != null) { Logger.d(LOG, String.format("EVENT %d ON %s: %s", event, path, parse)); //lsof_r1(path); ILogPack logPack = new ILogPack(); logPack.put(Keys.FILE_EFFECTED, path); logPack.put(Keys.ACCESS_TYPE, parse); logPack.put(Keys.ACCESS_CODE, event); DeviceSucker.this.sendToBuffer(logPack); } }