Source:
public void showText(){ switch (getIntent().getIntExtra(TYPE, 0)) { case TYPE_JSON: try { File entryFile = Measurement.getEntryFile(this, measurement.id, measurement.test_name); String json = FileUtils.readFileToString(entryFile, Charset.forName("UTF-8")); json = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(new JsonParser().parse(json)); text = json; textView.setText(json); } catch (Exception e) { e.printStackTrace(); if (ReachabilityManager.getNetworkType(this).equals(ReachabilityManager.NO_INTERNET)) { new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error)) .withMessage(getString(R.string.Modal_Error_RawDataNoInternet)) .build().show(getSupportFragmentManager(), null); return; } getApiClient().getMeasurement(measurement.report_id, null).enqueue(new GetMeasurementsCallback() { @Override public void onSuccess(ApiMeasurement.Result result) { getOkHttpClient().newCall(new Request.Builder().url(result.measurement_url).build()).enqueue(new GetMeasurementJsonCallback() { @Override public void onSuccess(String json) { text = json; textView.setText(json); } @Override public void onError(String msg) { new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error)) .withMessage(msg) .build().show(getSupportFragmentManager(), null); } }); } @Override public void onError(String msg) { new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error)) .withMessage(msg) .build().show(getSupportFragmentManager(), null); } }); } break; case TYPE_LOG: try { File logFile = Measurement.getLogFile(this, measurement.result.id, measurement.test_name); String log = FileUtils.readFileToString(logFile, Charset.forName("UTF-8")); text = log; textView.setText(log); } catch (Exception e) { e.printStackTrace(); new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error_LogNotFound)) .build().show(getSupportFragmentManager(), null); } break; } }

Target:
public void showText(){ switch (getIntent().getIntExtra(TYPE, 0)) { case TYPE_JSON: try { File entryFile = Measurement.getEntryFile(this, measurement.id, measurement.test_name); String json = FileUtils.readFileToString(entryFile, Charset.forName("UTF-8")); text = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(new JsonParser().parse(json)); textView.setText(text); } catch (Exception e) { e.printStackTrace(); if (ReachabilityManager.getNetworkType(this).equals(ReachabilityManager.NO_INTERNET)) { new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error)) .withMessage(getString(R.string.Modal_Error_RawDataNoInternet)) .build().show(getSupportFragmentManager(), null); return; } getApiClient().getMeasurement(measurement.report_id, null).enqueue(new GetMeasurementsCallback() { @Override public void onSuccess(ApiMeasurement.Result result) { getOkHttpClient().newCall(new Request.Builder().url(result.measurement_url).build()).enqueue(new GetMeasurementJsonCallback() { @Override public void onSuccess(String json) { text = json; textView.setText(json); } @Override public void onError(String msg) { showError(msg); } }); } @Override public void onError(String msg) { showError(msg); } }); } break; case TYPE_LOG: try { File logFile = Measurement.getLogFile(this, measurement.result.id, measurement.test_name); String log = FileUtils.readFileToString(logFile, Charset.forName("UTF-8")); text = log; textView.setText(log); } catch (Exception e) { new MessageDialogFragment.Builder() .withTitle(getString(R.string.Modal_Error_LogNotFound)) .build().show(getSupportFragmentManager(), null); } break; } }