Search in sources :

Example 1 with FilesProvider

use of us.koller.cameraroll.data.provider.FilesProvider in project Camera-Roll-Android-App by kollerlukas.

the class ExcludePathsActivity method loadDirectory.

public void loadDirectory(final String path) {
    final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), getString(R.string.loading), Snackbar.LENGTH_INDEFINITE);
    Util.showSnackbar(snackbar);
    filesProvider = new FilesProvider(this);
    final FilesProvider.Callback callback = new FilesProvider.Callback() {

        @Override
        public void onDirLoaded(final File_POJO dir) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    filesProvider.onDestroy();
                    snackbar.dismiss();
                    if (dir == null) {
                        return;
                    }
                    File_POJO currentDir = removeFiles(dir);
                    if (currentDir == null) {
                        return;
                    }
                    ExcludePathsActivity.this.currentDir = currentDir;
                    if (recyclerViewAdapter != null) {
                        recyclerViewAdapter.setFiles(currentDir);
                        recyclerViewAdapter.notifyDataSetChanged();
                        onPathChanged();
                    }
                }
            });
        }

        @Override
        public void timeout() {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    finish();
                }
            });
        }

        @Override
        public void needPermission() {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    finish();
                }
            });
        }
    };
    filesProvider.loadDir(this, path, callback);
}
Also used : FilesProvider(us.koller.cameraroll.data.provider.FilesProvider) File_POJO(us.koller.cameraroll.data.models.File_POJO) Snackbar(android.support.design.widget.Snackbar)

Example 2 with FilesProvider

use of us.koller.cameraroll.data.provider.FilesProvider in project Camera-Roll-Android-App by kollerlukas.

the class FileExplorerActivity method loadDirectory.

public void loadDirectory(final String path) {
    Log.d("FileExplorerActivity", "loadDirectory(): " + path);
    final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), getString(R.string.loading), Snackbar.LENGTH_INDEFINITE);
    Util.showSnackbar(snackbar);
    final FilesProvider.Callback callback = new FilesProvider.Callback() {

        @Override
        public void onDirLoaded(final File_POJO dir) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    filesProvider.onDestroy();
                    filesProvider = null;
                    if (dir != null) {
                        FileExplorerActivity.this.currentDir = dir;
                        if (recyclerViewAdapter != null) {
                            recyclerViewAdapter.setFiles(currentDir);
                            recyclerViewAdapter.notifyDataSetChanged();
                            onDataChanged();
                        }
                    }
                    snackbar.dismiss();
                }
            });
        }

        @Override
        public void timeout() {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    snackbar.dismiss();
                    final Snackbar snackbar = Snackbar.make(findViewById(R.id.root_view), R.string.loading_failed, Snackbar.LENGTH_INDEFINITE);
                    snackbar.setAction(getString(R.string.retry), new View.OnClickListener() {

                        @Override
                        public void onClick(View view) {
                            loadDirectory(path);
                        }
                    });
                    Util.showSnackbar(snackbar);
                }
            });
        }

        @Override
        public void needPermission() {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    snackbar.dismiss();
                }
            });
        }
    };
    filesProvider = new FilesProvider(this);
    filesProvider.loadDir(this, path, callback);
}
Also used : FilesProvider(us.koller.cameraroll.data.provider.FilesProvider) File_POJO(us.koller.cameraroll.data.models.File_POJO) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Snackbar(android.support.design.widget.Snackbar)

Aggregations

Snackbar (android.support.design.widget.Snackbar)2 File_POJO (us.koller.cameraroll.data.models.File_POJO)2 FilesProvider (us.koller.cameraroll.data.provider.FilesProvider)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1