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


Java FileObserver.CLOSE_WRITE屬性代碼示例

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


在下文中一共展示了FileObserver.CLOSE_WRITE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startWatching

private void startWatching() {
    final String pathToWatch = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();

    observer = new RecursiveFileObserver(pathToWatch, FileObserver.CLOSE_WRITE| FileObserver.MOVED_TO) { // set up a file observer to watch this directory on sd card
        @Override
        public void onEvent(int event, final String mediaPath) {
            if (mediaPath != null && (!mediaPath.equals(".probe"))) { // check that it's not equal to .probe because thats created every time camera is launched

                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {

                        if (mediaPath.endsWith(".mp4"))
                            handleNewVideo(mediaPath);
                    }
                });
            }
        }
    };
    observer.startWatching();


}
 
開發者ID:guardianproject,項目名稱:proofmode,代碼行數:23,代碼來源:MediaListenerService.java

示例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;
    }
}
 
開發者ID:wade-fs,項目名稱:MediaManager,代碼行數:19,代碼來源:AbstractBrowserFragment.java

示例3: onCreate

@Override
public void onCreate() {
    super.onCreate();

    copyConfigFromAssets(GOOGLE_CONFIG_FILE);
    copyConfigFromAssets(AMAZON_CONFIG_FILE);
    copyConfigFromAssets(ONEPF_CONFIG_FILE);

    if (createDbFromConfig()) {
        _configObserver = new FileObserver(getConfigDir()) {
            @Override
            public void onEvent(int event, String file) {
                switch (event) {
                    case FileObserver.CLOSE_WRITE:
                        createDbFromConfig();
                        break;
                }
            }
        };
        _configObserver.startWatching();
    }
}
 
開發者ID:onepf,項目名稱:Open-Store-Example,代碼行數:22,代碼來源:StoreApplication.java

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

示例5: onEvent

@Override
public void onEvent(int event, String path) {
	if(event == FileObserver.CLOSE_WRITE) {
		WakeLock.acquire(context);
		int blnTimeout = getBlnTimeout();
		if(blnTimeout > 0) {
			// recalculate timeout from seconds to miliseconds
			blnTimeout = blnTimeout * 1000;
			SysCommand sc = SysCommand.getInstance();
			int n = sc.readSysfs("/sys/class/misc/backlightnotification/notification_led");
			if(n > 0 && sc.getLastResult(0).equals("1")) { // BLN on
				Log.d(LOG_TAG, "set alarm to shutdown BLN in " + blnTimeout + " ms");
				// get alarm manager
				AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
				
				// set alarm to turn off BLN
				PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 1, new Intent("mobi.cyann.deviltools.SHUTDOWN_BLN"), PendingIntent.FLAG_CANCEL_CURRENT);
				alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + blnTimeout, pendingIntent);
			}
		}
		WakeLock.release();
	}
}
 
開發者ID:DerTeufel,項目名稱:DevilTools,代碼行數:23,代碼來源:BlnObserver.java

示例6: 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;
    }
}
 
開發者ID:DF1E,項目名稱:SimpleExplorer,代碼行數:19,代碼來源:AbstractBrowserFragment.java

示例7: registerFileObserver

private void registerFileObserver() {
    mFileObserver = new FileObserver(context.getDataDir() + "/shared_prefs",
            FileObserver.ATTRIB | FileObserver.CLOSE_WRITE) {
        @Override
        public void onEvent(int event, String path) {
            for (FileObserverListener l : mFileObserverListeners) {
                if ((event & FileObserver.ATTRIB) != 0)
                    l.onFileAttributesChanged(path);
                if ((event & FileObserver.CLOSE_WRITE) != 0)
                    l.onFileUpdated(path);
            }
        }
    };
    mFileObserver.startWatching();
}
 
開發者ID:erfanoabdi,項目名稱:BatteryModPercentage,代碼行數:15,代碼來源:EffEnhancer.java

示例8: 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

示例9: startFileObserver

private boolean startFileObserver() {
	if (mFileObserver == null) {
		mFileObserver = new TraceFileObserver(mObserverPath, FileObserver.CLOSE_WRITE);
	}
	mFileObserver.setHandler(mTHandler);
	try {
		mFileObserver.startWatching();
		return true;
	} catch(Exception e) {
		return false;
	}
}
 
開發者ID:rooneyGG,項目名稱:ANRMessageCatch,代碼行數:12,代碼來源:AnrCatchManager.java

示例10: 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);
        }
    }

}
 
開發者ID:nullpointerexceptionapps,項目名稱:TeamCityDownloader,代碼行數:15,代碼來源:DownloadObserver.java

示例11: 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

示例12: LockPatternUtils

public LockPatternUtils(Context context) {
	if (sLockPatternFilename == null) {
		String dataSystemDirectory = context.getFilesDir()
				.getAbsolutePath();
		sLockPatternFilename = new File(dataSystemDirectory
				, LOCK_PATTERN_FILE);
		sHaveNonZeroPatternFile.set(sLockPatternFilename.length() > 0);
		int fileObserverMask = FileObserver.CLOSE_WRITE
				| FileObserver.DELETE | FileObserver.MOVED_TO
				| FileObserver.CREATE;
		sPasswordObserver = new LockPatternFileObserver(
				dataSystemDirectory, fileObserverMask);
		sPasswordObserver.startWatching();
	}
}
 
開發者ID:linmp4,項目名稱:quickmark,代碼行數:15,代碼來源:LockPatternUtils.java

示例13: onEvent

@Override
public void onEvent(int event, String path) {
    Log.i(TAG, "Event:" + event + "\t" + path);

    if (path == null || event != FileObserver.CLOSE_WRITE)
        Log.i(TAG, "Not important");
    else if (mLastTakenPath != null && path.equalsIgnoreCase(mLastTakenPath))
        Log.i(TAG, "This event has been observed before.");
    else {
        mLastTakenPath = path;
        File file = new File(PATH + path);

        if (deleteScreenshot) {
            if (file != null)
                file.delete();

            /*
            * A null uri is returned to listener once screenshot
            * has been deleted.
            * */
            if (mListener != null)
                mListener.onScreenshotTaken(null);

        } else {

            if (mListener != null)
                mListener.onScreenshotTaken(Uri.fromFile(file));
        }
    }
}
 
開發者ID:jd-alexander,項目名稱:Snapper,代碼行數:30,代碼來源:Snapper.java

示例14: LockPatternUtils

public LockPatternUtils(Context context) {
	if (sLockPatternFilename == null) {
		String dataSystemDirectory = context.getFilesDir()
				.getAbsolutePath();
		sLockPatternFilename = new File(dataSystemDirectory,
				LOCK_PATTERN_FILE);
		sHaveNonZeroPatternFile.set(sLockPatternFilename.length() > 0);
		int fileObserverMask = FileObserver.CLOSE_WRITE
				| FileObserver.DELETE | FileObserver.MOVED_TO
				| FileObserver.CREATE;
		sPasswordObserver = new LockPatternFileObserver(
				dataSystemDirectory, fileObserverMask);
		sPasswordObserver.startWatching();
	}
}
 
開發者ID:971758118,項目名稱:git_wowodai,代碼行數:15,代碼來源:LockPatternUtils.java

示例15: onEvent

@Override
public void onEvent( int event, String file ) {
	final int mask = FileObserver.CLOSE_NOWRITE | FileObserver.CLOSE_WRITE;
	if( ( event & mask ) != 0 ) {
		sendBroadcast( Action.SYSTEM_NET_CHANGE.intent() );
	}
}
 
開發者ID:SilentCircle,項目名稱:silent-text-android,代碼行數:7,代碼來源:SysNetObserverService.java


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