當前位置: 首頁>>代碼示例>>Java>>正文


Java FileObserver.MODIFY屬性代碼示例

本文整理匯總了Java中android.os.FileObserver.MODIFY屬性的典型用法代碼示例。如果您正苦於以下問題:Java FileObserver.MODIFY屬性的具體用法?Java FileObserver.MODIFY怎麽用?Java FileObserver.MODIFY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.os.FileObserver的用法示例。


在下文中一共展示了FileObserver.MODIFY屬性的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);
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:21,代碼來源:PFileIO.java

示例2: 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);
}
 
開發者ID:mrwojtek,項目名稱:sens-rec,代碼行數:25,代碼來源:Records.java

示例3: 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;
	}
}
 
開發者ID:ciubex,項目名稱:dscautorename,代碼行數:23,代碼來源:FolderObserver.java

示例4: 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);
}
 
開發者ID:Sean1988,項目名稱:CIMON_Android,代碼行數:22,代碼來源:FileAccessService.java

示例5: 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();
}
 
開發者ID:Sean1988,項目名稱:CIMON_Android,代碼行數:18,代碼來源:FileAccessService.java

示例6: onEvent

/**
 * 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);
    }
    
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:40,代碼來源:FolderObserver.java

示例7: 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);
    }
}
 
開發者ID:Git-tl,項目名稱:appcan-plugin-pdfreader-android,代碼行數:30,代碼來源:FileSystemScanner.java

示例8: onEvent

@Override
public void onEvent(int event, String path) {
	if(event == FileObserver.CREATE || event == FileObserver.MODIFY) {
		final File createdFile = new File(directoryPath, path);
		addContractFromFile(createdFile);
	}
}
 
開發者ID:vuisis-ammo,項目名稱:ammo-core,代碼行數:7,代碼來源:ContractStore.java

示例9: FileLogReader

public FileLogReader(Context context, Handler handler, File file,
		int spreadLimit) throws IOException, FileNotFoundException {
	mReader = new ScrollingFileReader(file, spreadLimit);
	mContext = context;
	mHandler = handler;
	mObserver = new MyFileObserver(file.getAbsolutePath(), FileObserver.MODIFY);
}
 
開發者ID:vuisis-ammo,項目名稱:ammo-core,代碼行數:7,代碼來源:FileLogReader.java

示例10: onStartCommand

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    try{
        //Make this service a foreground service (take directly from SDK docs)
        Notification notification = new Notification(R.drawable.ic_launcher, getText(R.string.notification_short), System.currentTimeMillis());
        notification.flags|=Notification.FLAG_NO_CLEAR;
        Intent notificationIntent = new Intent(this, FileMonitorActivity.class);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        notification.setLatestEventInfo(this, getText(R.string.notification_short),getText(R.string.notification_long), pendingIntent);
        startForeground(mNotifyId, notification);

        //Instantiate the log & the observer tree
        mLog = new ArrayList<String[]>();
        mTreeNodes = new ArrayList<FileObserverNode>();

        //Pluck the data from the intent
        Bundle b = intent.getExtras();
        mSaveExt = b != null ? b.getBoolean(FileMonitorActivity.mExtraExtern) : false;
        mWatchDir = b != null ? b.getString(FileMonitorActivity.mExtraWatch) : "/";

        //Attach & activate monitors
        int observerFlags = FileObserver.OPEN | FileObserver.MODIFY; //These flags define what activities we are looking for
        attachNode(mWatchDir, observerFlags, mLog);
        startWatchingTree();
    }catch(Exception e){
        Toast.makeText(this, getText(R.string.toast_service_error_starting) + e.getMessage(), Toast.LENGTH_SHORT).show();
    }

    Toast.makeText(this, getText(R.string.toast_service_started) + String.valueOf(mTreeNodes.size()), Toast.LENGTH_SHORT).show();
    return super.onStartCommand(intent, flags, startId);
}
 
開發者ID:jarabek,項目名稱:android_file_monitor_utility,代碼行數:32,代碼來源:FileMonitorService.java

示例11: onEvent

@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;
	}
}
 
開發者ID:concentricsky,項目名稱:android-viewer-for-khan-academy,代碼行數:34,代碼來源:OfflineVideoManager.java

示例12: onEvent

@Override
public void onEvent(final int event, final String path) {
    Intent localIntent = new Intent(INTENT_EBOOK_MODIFIED);
    localIntent.putExtra(INTENT_EBOOK_MODIFIED_PATH, path);
    switch (event) {
        case FileObserver.ACCESS:
            BookLibApplication.d(LOG_TAG + "onEvent() ACCESS: " + path);
            break;
        case FileObserver.ATTRIB:
            BookLibApplication.d(LOG_TAG + "onEvent() ATTRIB: " + path);
            break;
        case FileObserver.CLOSE_NOWRITE:
            BookLibApplication.d(LOG_TAG + "onEvent() CLOSE_NOWRITE: " + path);
            break;
        case FileObserver.CLOSE_WRITE:
            BookLibApplication.d(LOG_TAG + "onEvent() CLOSE_WRITE: " + path);
            break;
        case FileObserver.CREATE:
            BookLibApplication.d(LOG_TAG + "onEvent() CREATE: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.DELETE:
            BookLibApplication.d(LOG_TAG + "onEvent() DELETE: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.DELETE_SELF:
            BookLibApplication.d(LOG_TAG + "onEvent() DELETE_SELF: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.MODIFY:
            BookLibApplication.d(LOG_TAG + "onEvent() MODIFY: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.MOVE_SELF:
            BookLibApplication.d(LOG_TAG + "onEvent() MOVE_SELF: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.MOVED_FROM:
            BookLibApplication.d(LOG_TAG + "onEvent() MOVED_FROM: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.MOVED_TO:
            BookLibApplication.d(LOG_TAG + "onEvent() MOVED_TO: " + path);
            BookLibApplication.getInstance().sendBroadcast(localIntent);
            break;
        case FileObserver.OPEN:
            BookLibApplication.d(LOG_TAG + "onEvent() OPEN: " + path);
            break;
        default:
            //BookLibApplication.d(LOG_TAG + "onEvent() DEFAULT(" + event + "): " + path);
            break;
    }
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:53,代碼來源:RecursiveFileObserver.java

示例13: RecordsObserver

public RecordsObserver(String path) {
    super(path, FileObserver.MODIFY | FileObserver.CREATE | FileObserver.MOVED_TO |
            FileObserver.DELETE | FileObserver.MOVED_FROM);
    lastUpdateTime = SystemClock.elapsedRealtime() - MODIFICATION_INTERVAL;
}
 
開發者ID:mrwojtek,項目名稱:sens-rec,代碼行數:5,代碼來源:Records.java

示例14: onEvent

private void onEvent(int i, String s) {
    if (i != FileObserver.MODIFY) {
        return;
    }
    write();
}
 
開發者ID:luv,項目名稱:mockgeofix,代碼行數:6,代碼來源:OomAdjOverrider.java

示例15: onEvent

@Override
public void onEvent(int event, String path) {
    switch (event) {
        case FileObserver.ACCESS:
            Log.i(TAG, "ACCESS");
            break;
        case FileObserver.ATTRIB:
            Log.i(TAG, "ATTRIB");
            break;
        case FileObserver.CLOSE_NOWRITE:
            Log.i(TAG, "CLOSE_NOWRITE");
            break;
        case FileObserver.CLOSE_WRITE:
            Log.i(TAG, "CLOSE_WRITE");
            break;
        case FileObserver.CREATE:
            Log.i(TAG, "CREATE");
            break;
        case FileObserver.DELETE:
            Log.i(TAG, "DELETE");
            break;
        case FileObserver.DELETE_SELF:
            Log.i(TAG, "DELETE_SELF");
            break;
        case FileObserver.MODIFY:
            Log.i(TAG, "MODIFY");
            break;
        case FileObserver.MOVE_SELF:
            Log.i(TAG, "MOVE_SELF");
            break;
        case FileObserver.MOVED_FROM:
            Log.i(TAG, "MOVED_FROM");
            break;
        case FileObserver.MOVED_TO:
            Log.i(TAG, "MOVED_TO");
            break;
        case FileObserver.OPEN:
            Log.i(TAG, "OPEN");
            break;
        case FileObserver.ALL_EVENTS:
            Log.i(TAG, "ALL_EVENTS");
            break;
        default:
            Log.i(TAG, "default, event=" + event + ", path=" + path);
            break;
    }

}
 
開發者ID:cheyiliu,項目名稱:test4android,代碼行數:48,代碼來源:MainActivity.java


注:本文中的android.os.FileObserver.MODIFY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。