Search in sources :

Example 1 with ReadTextFileTask

use of com.odysee.app.tasks.ReadTextFileTask in project odysee-android by OdyseeTeam.

the class FileViewFragment method loadMarkdownFromFile.

private void loadMarkdownFromFile(String filePath) {
    ReadTextFileTask task = new ReadTextFileTask(filePath, new ReadTextFileTask.ReadTextFileHandler() {

        @Override
        public void onSuccess(String text) {
            if (webView != null) {
                String html = buildMarkdownHtml(text);
                webView.loadData(Base64.encodeToString(html.getBytes(), Base64.NO_PADDING), "text/html", "base64");
            }
        }

        @Override
        public void onError(Exception error) {
            showError(error.getMessage());
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ReadTextFileTask(com.odysee.app.tasks.ReadTextFileTask) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException)

Aggregations

TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)1 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 ReadTextFileTask (com.odysee.app.tasks.ReadTextFileTask)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 JSONException (org.json.JSONException)1