Search in sources :

Example 1 with EXTRA_GIST_FILE

use of com.github.pockethub.android.Intents.EXTRA_GIST_FILE in project PocketHub by pockethub.

the class GistFileFragment method loadSource.

private void loadSource() {
    store.refreshGist(gistId).map(gist -> {
        Map<String, GistFile> files = gist.files();
        if (files == null) {
            throw new IOException();
        }
        GistFile loadedFile = files.get(file.filename());
        if (loadedFile == null) {
            throw new IOException();
        }
        return loadedFile;
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(loadedFile -> {
        file = loadedFile;
        getArguments().putParcelable(EXTRA_GIST_FILE, file);
        if (file.content() != null) {
            showSource();
        }
    }, e -> ToastUtils.show(getActivity(), R.string.error_gist_file_load));
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) BaseFragment(com.github.pockethub.android.ui.base.BaseFragment) PreferenceUtils(com.github.pockethub.android.util.PreferenceUtils) OnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener) NonNull(android.support.annotation.NonNull) EXTRA_GIST_FILE(com.github.pockethub.android.Intents.EXTRA_GIST_FILE) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) BindView(butterknife.BindView) Inject(javax.inject.Inject) SuppressLint(android.annotation.SuppressLint) GistStore(com.github.pockethub.android.core.gist.GistStore) MenuInflater(android.view.MenuInflater) Gist(com.meisolsson.githubsdk.model.Gist) Map(java.util.Map) Menu(android.view.Menu) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) ToastUtils(com.github.pockethub.android.util.ToastUtils) WebView(android.webkit.WebView) SourceEditor(com.github.pockethub.android.util.SourceEditor) GistFile(com.meisolsson.githubsdk.model.GistFile) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) WRAP(com.github.pockethub.android.util.PreferenceUtils.WRAP) ViewGroup(android.view.ViewGroup) EXTRA_GIST_ID(com.github.pockethub.android.Intents.EXTRA_GIST_ID) SharedPreferences(android.content.SharedPreferences) R(com.github.pockethub.android.R) IOException(java.io.IOException) GistFile(com.meisolsson.githubsdk.model.GistFile) Map(java.util.Map)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 OnSharedPreferenceChangeListener (android.content.SharedPreferences.OnSharedPreferenceChangeListener)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 WebView (android.webkit.WebView)1 BindView (butterknife.BindView)1 EXTRA_GIST_FILE (com.github.pockethub.android.Intents.EXTRA_GIST_FILE)1 EXTRA_GIST_ID (com.github.pockethub.android.Intents.EXTRA_GIST_ID)1 R (com.github.pockethub.android.R)1 GistStore (com.github.pockethub.android.core.gist.GistStore)1 BaseFragment (com.github.pockethub.android.ui.base.BaseFragment)1 PreferenceUtils (com.github.pockethub.android.util.PreferenceUtils)1