- return null;
- }
-
- @Override
- protected void onProgressUpdate(StringWriter... values) {
- super.onProgressUpdate(values);
- //Using a ListView allows to show large text without the UI freeze that happens
- //when calling TextView#setText() with a large CharSequence
- ((TextLineAdapter) mTextPreviewList.getAdapter()).add(values[0].toString());
- }
-
- @Override
- protected void onPostExecute(Void aVoid) {
- super.onPostExecute(aVoid);
- mProgressBar.setVisibility(View.GONE);
- mTextPreviewList.setVisibility(View.VISIBLE);
- }
- }
-
- private class TextLineAdapter extends BaseAdapter {
- private static final int LIST_ITEM_LAYOUT = R.layout.text_file_preview_list_item;
- private final List<String> items = new ArrayList<String>();
-
- private void add(String line) {
- items.add(line);
- notifyDataSetChanged();
- }
-
- private void clear() {
- items.clear();
- notifyDataSetChanged();