Example usage for android.os FileObserver MOVED_FROM

List of usage examples for android.os FileObserver MOVED_FROM

Introduction

In this page you can find the example usage for android.os FileObserver MOVED_FROM.

Prototype

int MOVED_FROM

To view the source code for android.os FileObserver MOVED_FROM.

Click Source Link

Document

Event type: A file or subdirectory was moved from the monitored directory

Usage

From source file:com.dnielfe.manager.Browser.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(mCurrentPath));
        break;//ww w. j a  v  a  2  s  . c om
    }
}

From source file:com.alexlionne.apps.avatars.Utils.DirectoryChooserFragment.java

/**
 * Sets up a FileObserver to watch the current directory.
 *///  ww  w.j  a  v  a2s.c o  m
private FileObserver createFileObserver(String path) {
    return new FileObserver(path,
            FileObserver.CREATE | FileObserver.DELETE | FileObserver.MOVED_FROM | FileObserver.MOVED_TO) {

        @Override
        public void onEvent(int event, String path) {
            debug("FileObserver received event %d", event);
            final Activity activity = getActivity();

            if (activity != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        refreshDirectory();
                    }
                });
            }
        }
    };
}

From source file:com.andrada.sitracker.ui.fragment.DirectoryChooserFragment.java

/**
 * Sets up a FileObserver to watch the current directory.
 *///from   w  w  w  .ja v  a  2 s .c  om
@NotNull
private FileObserver createFileObserver(String path) {
    return new FileObserver(path,
            FileObserver.CREATE | FileObserver.DELETE | FileObserver.MOVED_FROM | FileObserver.MOVED_TO) {

        @Override
        public void onEvent(int event, String path) {
            debug("FileObserver received event %d", event);
            final Activity activity = getActivity();

            if (activity != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        refreshDirectory();
                    }
                });
            }
        }
    };
}