本文整理汇总了Java中android.os.FileObserver.CREATE属性的典型用法代码示例。如果您正苦于以下问题:Java FileObserver.CREATE属性的具体用法?Java FileObserver.CREATE怎么用?Java FileObserver.CREATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.os.FileObserver
的用法示例。
在下文中一共展示了FileObserver.CREATE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PFileObserver
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);
}
示例2: onEvent
@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((MyBrowserActivity) getActivity(), path));
break;
}
}
示例3: onEvent
@Override
public synchronized void onEvent(int event, String path) {
if (path.equals(tabuPath)) {
return;
}
long delay = 0;
switch (event) {
case FileObserver.MODIFY:
delay = Math.max(0,
lastUpdateTime + MODIFICATION_INTERVAL - SystemClock.elapsedRealtime());
modified.add(path);
break;
case FileObserver.CREATE:
case FileObserver.MOVED_TO:
added.add(path);
break;
case FileObserver.DELETE:
case FileObserver.MOVED_FROM:
deleted.add(path);
break;
}
schedule(delay);
}
示例4: onEvent
/**
* This method is invoked when a registered event occur.
*
* @param event The type of event which happened
* @param path The path, relative to the main monitored file or directory,
* of the file or directory which triggered the event
*/
@Override
public void onEvent(int event, String path) {
switch (event & FileObserver.ALL_EVENTS) {
case FileObserver.CREATE:
checkAutoRenameTask(path);
break;
case FileObserver.DELETE:
case FileObserver.DELETE_SELF:
case FileObserver.MODIFY:
case FileObserver.MOVED_FROM:
case FileObserver.MOVED_TO:
case FileObserver.MOVE_SELF:
checkForFolder(path);
break;
}
}
示例5: onEvent
@Override
public void onEvent(int event, String path) {
if (event != FileObserver.CREATE) return;
if (path.endsWith(".png")) {
String file = mScreenshotDir + "/" + path;
mFiles.add(file);
if (DEBUG) {
Log.d(TAG, "Adding " + file);
}
//mIntent.putExtra(EXTRA_PATHS, mFiles.toArray(new String[mFiles.size()]));
PendingIntent i = mFiles.size() >= 2 ? PendingIntent.getActivity(ScreenshotService.this, 0, mIntent, 0) : null;
rebuildNotification(i, String.format(getString(R.string.notifi_count), mFiles.size() + 1), getString(R.string.notifi_tip));
mNotificationManager.notify(R.drawable.ic_launcher, mNotification);
}
}
示例6: onEvent
@Override
public void onEvent(int event, String path) {
if (DebugLog.DEBUG) Log.d(TAG, "FileAccessService.AccessObserver.onEvent - access triggered");
switch (event) {
case FileObserver.ACCESS:
values[READS] = Long.valueOf(values[READS].longValue() + 1);
break;
case FileObserver.MODIFY:
values[WRITES] = Long.valueOf(values[WRITES].longValue() + 1);
break;
case FileObserver.CREATE:
values[CREATES] = Long.valueOf(values[CREATES].longValue() + 1);
break;
case FileObserver.DELETE:
values[DELETES] = Long.valueOf(values[DELETES].longValue() + 1);
break;
default:
return;
}
updateMetric = new UpdateMetric(); // is this needed (nothing static)?
metricHandler.post(updateMetric);
}
示例7: performUpdates
@Override
protected void performUpdates() {
long nextUpdate = updateValueNodes();
if (nextUpdate < 0) {
if (accessObserver != null) {
accessObserver.stopWatching();
accessObserver = null;
}
}
else {
if (accessObserver == null) {
accessObserver = new AccessObserver(Environment.getExternalStorageDirectory().getPath(),
FileObserver.ACCESS | FileObserver.MODIFY | FileObserver.CREATE | FileObserver.DELETE);
accessObserver.startWatching();
}
}
updateObservable();
}
示例8: LockPasswordUtils
public LockPasswordUtils(Context context) {
mSharedPreferences = context.getSharedPreferences(
LOCK_PASSWORD_SALT_FILE, Context.MODE_PRIVATE);
mEditor = mSharedPreferences.edit();
if (sLockPasswordFilename == null) {
String dataSystemDirectory = context.getCacheDir()
.getAbsolutePath();
sLockPasswordFilename = new File(dataSystemDirectory,
LOCK_PASSWORD_FILE);
sHaveNonZeroPasswordFile.set(sLockPasswordFilename.length() > 0);
int fileObserverMask = FileObserver.CLOSE_WRITE
| FileObserver.DELETE | FileObserver.MOVED_TO
| FileObserver.CREATE;
sPasswordObserver = new PasswordFileObserver(dataSystemDirectory,
fileObserverMask);
sPasswordObserver.startWatching();
}
}
示例9: onEvent
@Override
public void onEvent(int event, String pathString) {
switch (event & FileObserver.ALL_EVENTS) {
case FileObserver.MOVE_SELF:
case FileObserver.DELETE_SELF:
sHandler.removeCallbacks(mLastRunnable);
final GenericFile parent = resolveExistingParent(mCurrentPath);
sHandler.post(mLastRunnable = new NavigateRunnable(
Browser.this, parent, true));
break;
case FileObserver.CREATE:
case FileObserver.MOVED_TO:
sHandler.removeCallbacks(mLastRunnable);
sHandler.post(mLastRunnable = new InvalidateRunnable(this));
break;
}
}
示例10: onEventUIThread
/**
* {@link android.os.FileObserver} event that should be ran only on UI thread
*
* @param event The type of event which happened
* @param file The modified file, relative to the main monitored file or directory,
* of the file or directory which triggered the event
*/
void onEventUIThread(final int event,
@NonNull final GenericFile file) {
switch (event & FileObserver.ALL_EVENTS) {
case FileObserver.CREATE:
//Do nothing. The event is handled in Browser
break;
case FileObserver.DELETE:
case FileObserver.DELETE_SELF:
case FileObserver.MOVED_FROM:
onFileDeleted(file);
break;
default:
onFileModified(file);
break;
}
}
示例11: onEvent
@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;
}
}
示例12: onEvent
@Override
public void onEvent(int event, String file) {
if ((FileObserver.CREATE & event) != 0) {
MLog.d(TAG, "File created [" + PhonkSettings.getBaseDir() + "/" + file + "]");
} else if ((FileObserver.DELETE & event) != 0) {
MLog.d(TAG, "File deleted [" + PhonkSettings.getBaseDir() + "/" + file + "]");
}
}
示例13: onEvent
@Override
public void onEvent(int event, String path) {
switch(event) {
case FileObserver.ALL_EVENTS:
Log.d("all", "path:"+ path);
break;
case FileObserver.CREATE:
Log.d("Create", "path:"+ path);
break;
}
}
示例14: onEvent
@Override
public void onEvent(int event, String path) {
Debug.Log(tag, String.format("onEvent(%d, %s)", event, path));
if (path != null) {
if ((FileObserver.CREATE & event)!=0) {
listener.onFileCreated(path);
}
if ((FileObserver.CLOSE_WRITE & event)!=0) {
listener.onFileClosed(path);
}
}
}
示例15: toString
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);
}
}