Example usage for android.app Application getContentResolver

List of usage examples for android.app Application getContentResolver

Introduction

In this page you can find the example usage for android.app Application getContentResolver.

Prototype

@Override
    public ContentResolver getContentResolver() 

Source Link

Usage

From source file:com.commonsware.android.diceware.PassphraseFragment.java

private void loadWords(boolean forceReload, boolean regenPassphrase) {
    if (wordsObservable == null || forceReload) {
        final Application app = getActivity().getApplication();

        wordsObservable = Observable
                .defer(() -> (Observable.just(PreferenceManager.getDefaultSharedPreferences(app))))
                .subscribeOn(Schedulers.io()).map(sharedPreferences -> {
                    PassphraseFragment.this.prefs = sharedPreferences;

                    return (sharedPreferences.getString(PREF_URI, ""));
                }).map(s -> {//w  ww .  ja  v a  2 s .c  o  m
                    InputStream in;

                    if (s.length() == 0) {
                        in = app.getAssets().open(ASSET_FILENAME);
                    } else {
                        in = app.getContentResolver().openInputStream(Uri.parse(s));
                    }

                    return (readWords(in));
                }).cache().observeOn(AndroidSchedulers.mainThread());
    }

    unsubWords();

    if (regenPassphrase) {
        wordsSub = wordsObservable.subscribe(this::rollDemBones, error -> {
            Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_LONG).show();
            Log.e(getClass().getSimpleName(), "Exception processing request", error);
        });
    }
}