Example usage for android.provider DocumentsContract EXTRA_ERROR

List of usage examples for android.provider DocumentsContract EXTRA_ERROR

Introduction

In this page you can find the example usage for android.provider DocumentsContract EXTRA_ERROR.

Prototype

String EXTRA_ERROR

To view the source code for android.provider DocumentsContract EXTRA_ERROR.

Click Source Link

Document

Optional string included in a directory Cursor#getExtras() providing an error message that should be shown to a user.

Usage

From source file:io.v.android.apps.syncslides.DeckChooserFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_IMPORT_DECK:
        if (resultCode != Activity.RESULT_OK) {
            String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR)
                    ? data.getStringExtra(DocumentsContract.EXTRA_ERROR)
                    : "";
            toast("Error selecting deck to import " + errorStr);
            break;
        }//from w  ww.ja v a  2 s .c om
        Uri uri = data.getData();
        importDeck(DocumentFile.fromTreeUri(getContext(), uri));
        break;
    }
}

From source file:io.v.syncslides.DeckChooserFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_IMPORT_DECK:
        if (resultCode != Activity.RESULT_OK) {
            String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR)
                    ? data.getStringExtra(DocumentsContract.EXTRA_ERROR)
                    : "";
            toast("Error selecting deck to import " + errorStr);
            break;
        }/*from   w  ww.java 2s.  c om*/
        Uri uri = data.getData();
        DeckImporter importer = new DeckImporter(getActivity().getContentResolver(), DB.Singleton.get());
        ListenableFuture<Void> future = importer.importDeck(DocumentFile.fromTreeUri(getContext(), uri));
        Futures.addCallback(future, new FutureCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                toast("Import complete");
            }

            @Override
            public void onFailure(Throwable t) {
                toast("Import failed: " + t.getMessage());
            }
        });
        break;
    }
}

From source file:com.seafile.seadroid2.provider.SeafileProvider.java

/**
 * Create a MatrixCursor with the option to enable the extraLoading flag.
 *
 * @param netProjection column list/*from   ww  w. j  av  a 2  s  . com*/
 * @param extraLoading if true, the client will expect that more entries will arrive shortly.
 * @return the Cursor object
 */
private static MatrixCursor createCursor(String[] netProjection, final boolean extraLoading,
        final boolean isReachable) {
    return new MatrixCursor(netProjection) {
        @Override
        public Bundle getExtras() {
            Bundle b = new Bundle();
            b.putBoolean(DocumentsContract.EXTRA_LOADING, extraLoading);
            if (!extraLoading && !isReachable) {
                b.putString(DocumentsContract.EXTRA_ERROR, "Could not connect with server");
            }
            return b;
        }
    };
}