Java 类android.os.FileObserver 实例源码

项目:Android-AudioRecorder-App    文件:PlayListFragment.java   
@Override public void onEvent(int event, String file) {
  if (event == FileObserver.DELETE) {
    // user deletes a recording file out of the app

    String filePath = android.os.Environment.getExternalStorageDirectory().toString()
        + "/SoundRecorder"
        + file
        + "]";

    Log.d(LOG_TAG, "File deleted ["
        + android.os.Environment.getExternalStorageDirectory().toString()
        + "/SoundRecorder"
        + file
        + "]");

    // remove file from database and recyclerview
    mPlayListAdapter.removeOutOfApp(filePath);
  }
}
项目:phonk    文件:PFileIO.java   
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);
}
项目:Facebook-Video-Downloader    文件:FileViewerFragment.java   
@Override
public void onEvent(int event, String file) {
    if(event == FileObserver.DELETE){
        // user deletes a recording file out of the app

        String filePath = android.os.Environment.getExternalStorageDirectory().toString()
                + "/Facebook Videos" + file + "]";

        Log.d(LOG_TAG, "File deleted ["
                + android.os.Environment.getExternalStorageDirectory().toString()
                + "/Facebook Videos" + file + "]");

        // remove file from database and recyclerview
        mFileViewerAdapter.removeOutOfApp(filePath);
    }
}
项目:health    文件:FileViewerFragment.java   
@Override
public void onEvent(int event, String file) {
    if(event == FileObserver.DELETE){
        // user deletes a recording file out of the app

        String filePath = android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]";

        Log.d(LOG_TAG, "File deleted ["
                + android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]");

        // remove file from database and recyclerview
        mFileViewerAdapter.removeOutOfApp(filePath);
    }
}
项目:MediaManager    文件:AbstractBrowserFragment.java   
@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;
    }
}
项目:proofmode    文件:MediaListenerService.java   
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();


}
项目:RealRECORDER    文件:FileViewerFragment.java   
@Override
public void onEvent(int event, String file) {
    if(event == FileObserver.DELETE){
        // user deletes a recording file out of the app

        String filePath = android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]";

        Log.d(LOG_TAG, "File deleted ["
                + android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]");

        // remove file from database and recyclerview
        mFileViewerAdapter.removeOutOfApp(filePath);
    }
}
项目:MediaManager    文件:AbstractBrowserFragment.java   
@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;
    }
}
项目:sens-rec    文件:Records.java   
@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);
}
项目:RxFileObserver    文件:FileObservable.java   
@Override
public void call(final Subscriber<? super FileEvent> subscriber) {
    final FileObserver observer = new FileObserver(pathToWatch) {
        @Override
        public void onEvent(int event, String file) {
            if(subscriber.isUnsubscribed()) {
                return;
            }

            FileEvent fileEvent = FileEvent.create(event, file);
            subscriber.onNext(fileEvent);

            if(fileEvent.isDeleteSelf()) {
                subscriber.onCompleted();
            }
        }
    };
    observer.startWatching(); //START OBSERVING

    subscriber.add(Subscriptions.create(new Action0() {
        @Override
        public void call() {
            observer.stopWatching();
        }
    }));
}
项目:appcan-plugin-pdfreader-android    文件:FileSystemScanner.java   
public void stopObservers(final String path) {
    final String mpath = FileUtils.invertMountPrefix(path);
    final String ap = path + "/";
    final String mp = mpath != null ? mpath + "/" : null;

    synchronized (observers) {
        final Iterator<Entry<File, FileObserver>> iter = observers.entrySet().iterator();
        while (iter.hasNext()) {
            final Entry<File, FileObserver> next = iter.next();
            final File file = next.getKey();
            final String filePath = file.getAbsolutePath();
            final boolean eq = filePath.startsWith(ap) || filePath.equals(path) || mpath != null
                    && (filePath.startsWith(mp) || filePath.equals(mpath));
            if (eq) {
                next.getValue().stopWatching();
                iter.remove();
            }
        }
    }
}
项目:dscautorename    文件:FolderObserver.java   
/**
 * 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;
    }
}
项目:Panoramic-Screenshot    文件:ScreenshotService.java   
@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);
    }
}
项目:CIMON_Android    文件:FileAccessService.java   
@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);
}
项目:CIMON_Android    文件:FileAccessService.java   
@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();
}
项目:Open-Store-Example    文件:StoreApplication.java   
@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();
    }
}
项目:git_wowodai    文件:LockPasswordUtils.java   
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();
    }
}
项目:SoundRecorder    文件:FileViewerFragment.java   
@Override
public void onEvent(int event, String file) {
    if(event == FileObserver.DELETE){
        // user deletes a recording file out of the app

        String filePath = android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]";

        Log.d(LOG_TAG, "File deleted ["
                + android.os.Environment.getExternalStorageDirectory().toString()
                + "/SoundRecorder" + file + "]");

        // remove file from database and recyclerview
        mFileViewerAdapter.removeOutOfApp(filePath);
    }
}
项目:Pure-File-Manager    文件:Browser.java   
@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;
    }
}
项目:Pure-File-Manager    文件:BrowserBaseAdapter.java   
/**
 * {@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;
    }
}
项目:DevilTools    文件:BlnObserver.java   
@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();
    }
}
项目:SimpleExplorer    文件:AbstractBrowserFragment.java   
@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;
    }
}
项目:document-viewer    文件:FileSystemScanner.java   
public void stopObservers(final String path) {
    final String mpath = FileUtils.invertMountPrefix(path);
    final String ap = path + "/";
    final String mp = mpath != null ? mpath + "/" : null;

    synchronized (observers) {
        final Iterator<Entry<File, FileObserver>> iter = observers.entrySet().iterator();
        while (iter.hasNext()) {
            final Entry<File, FileObserver> next = iter.next();
            final File file = next.getKey();
            final String filePath = file.getAbsolutePath();
            final boolean eq = filePath.startsWith(ap) || filePath.equals(path) || mpath != null
                    && (filePath.startsWith(mp) || filePath.equals(mpath));
            if (eq) {
                next.getValue().stopWatching();
                iter.remove();
            }
        }
    }
}
项目:aos-FileCoreLibrary    文件:SambaConfigurationCache.java   
private FileObserver getObserver() {
    return new FileObserver(mFilePath, OBSERVER_FLAGS) {
        @Override
        public void onEvent(int event, String path) {
            // delete or modify invalidates the file
            mHasChanged.set(true);
            // deleting the file also invalidates the observer
            if (event == FileObserver.DELETE_SELF) {
                mObserver = null;
                // invalidate file date
                mFileDate = -1;
            }
        }
    };
}
项目:BatteryModPercentage    文件:EffEnhancer.java   
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();
}
项目:phonk    文件:PhonkServerService.java   
@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 + "]");
    }
}
项目:android_camera_experiment    文件:CameraControlPanel.java   
public void onStartVideoRecord(final File mediaFile) {
    setMediaFilePath(mediaFile);

    CircleAngleAnimation animation = new CircleAngleAnimation(circleProgressView, 360);
    animation.setDuration(10700);
    circleProgressView.startAnimation(animation);

    if (maxVideoFileSize > 0) {
        recordSizeText.setText("1Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
        recordSizeText.setVisibility(VISIBLE);
        try {
            fileObserver = new FileObserver(this.mediaFilePath) {
                private long lastUpdateSize = 0;

                @Override
                public void onEvent(int event, String path) {
                    final long fileSize = mediaFile.length() / (1024 * 1024);
                    if ((fileSize - lastUpdateSize) >= 1) {
                        lastUpdateSize = fileSize;
                        recordSizeText.post(new Runnable() {
                            @Override
                            public void run() {
                                recordSizeText.setText(fileSize + "Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
                            }
                        });
                    }
                }
            };
            fileObserver.startWatching();
        } catch (Exception e) {
            Log.e("FileObserver", "setMediaFilePath: ", e);
        }
    }
    countDownTimer.start();

}
项目:sandriosCamera    文件:CameraControlPanel.java   
public void onStartVideoRecord(final File mediaFile) {
    setMediaFilePath(mediaFile);
    if (maxVideoFileSize > 0) {
        recordSizeText.setText("1Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
        recordSizeText.setVisibility(VISIBLE);
        try {
            fileObserver = new FileObserver(this.mediaFilePath) {
                private long lastUpdateSize = 0;

                @Override
                public void onEvent(int event, String path) {
                    final long fileSize = mediaFile.length() / (1024 * 1024);
                    if ((fileSize - lastUpdateSize) >= 1) {
                        lastUpdateSize = fileSize;
                        recordSizeText.post(new Runnable() {
                            @Override
                            public void run() {
                                recordSizeText.setText(fileSize + "Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
                            }
                        });
                    }
                }
            };
            fileObserver.startWatching();
        } catch (Exception e) {
            Log.e("FileObserver", "setMediaFilePath: ", e);
        }
    }
    countDownTimer.start();
}
项目:Annca    文件:CameraControlPanel.java   
public void onStartVideoRecord(final File mediaFile) {
    setMediaFilePath(mediaFile);
    if (maxVideoFileSize > 0) {
        recordSizeText.setText("1Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
        recordSizeText.setVisibility(VISIBLE);
        try {
            fileObserver = new FileObserver(this.mediaFilePath) {
                private long lastUpdateSize = 0;

                @Override
                public void onEvent(int event, String path) {
                    final long fileSize = mediaFile.length() / (1024 * 1024);
                    if ((fileSize - lastUpdateSize) >= 1) {
                        lastUpdateSize = fileSize;
                        recordSizeText.post(new Runnable() {
                            @Override
                            public void run() {
                                recordSizeText.setText(fileSize + "Mb" + " / " + maxVideoFileSize / (1024 * 1024) + "Mb");
                            }
                        });
                    }
                }
            };
            fileObserver.startWatching();
        } catch (Exception e) {
            Log.e("FileObserver", "setMediaFilePath: ", e);
        }
    }
    countDownTimer.start();

}
项目:Cirrus    文件:FolderObserver.java   
/**
 * 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);
    }

}
项目:MediaMonkey    文件:FileUtils.java   
public static void startPathUpdateObserver(final FileObserver observer) {
    if (null == observer) {
        return;
    }

    observer.startWatching();
}
项目:MediaMonkey    文件:FileUtils.java   
public static void stopPathUpdateObserver(final FileObserver observer) {
    if (null == observer) {
        return;
    }

    observer.startWatching();
}
项目:ANRMessageCatch    文件:AnrCatchManager.java   
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;
    }
}
项目:mobile-manager-tool    文件:SDCardListener.java   
@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;
    }
}
项目:TeamCityDownloader    文件:DownloadObserver.java   
@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);
        }
    }

}
项目:appcan-plugin-pdfreader-android    文件:FileSystemScanner.java   
public FileObserver getObserver(final File dir) {
    // final String path = dir.getAbsolutePath();
    synchronized (observers) {
        // FileObserver fo = observers.get(path);
        FileObserver fo = observers.get(dir);
        if (fo == null) {
            fo = new FileObserverImpl(dir);
            observers.put(dir, fo);
        }
        return fo;
    }
}
项目:appcan-plugin-pdfreader-android    文件:FileSystemScanner.java   
public void stopObservers() {
    synchronized (observers) {
        for (final FileObserver o : observers.values()) {
            o.stopWatching();
        }
        observers.clear();
    }
}
项目:appcan-plugin-pdfreader-android    文件:FileSystemScanner.java   
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);
    }
}
项目:quickmark    文件:LockPatternUtils.java   
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();
    }
}
项目:iLocker    文件:LockPatternUtils.java   
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();
    }
}