Skip to content

Commit

Permalink
Add "longContent" to show the full content from the .docx
Browse files Browse the repository at this point in the history
Fix initializing when user navigates back to the list
  • Loading branch information
centic9 committed Jul 25, 2017
1 parent 4d3998d commit daa58c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

// Show the dummy content as text in a TextView.
if (mItem != null) {
((TextView) rootView.findViewById(R.id.document_detail)).setText(mItem.content);
((TextView) rootView.findViewById(R.id.document_detail)).setText(mItem.longContent);
}

return rootView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ protected void onCreate(Bundle savedInstanceState) {
InputStream input = openFileInput("test.xlsx");
wb = WorkbookFactory.create(input);

// refresh the content as we re-enter here if the user navigates back from the detail view
DummyContent.initialize();

// replace the dummy-content to show that we could write and read the cell-values
int i = 0;
row = wb.getSheetAt(0).getRow(0);
Expand All @@ -103,7 +106,7 @@ protected void onCreate(Bundle savedInstanceState) {
XWPFDocument doc = new XWPFDocument(docFile);
try {
for(XWPFParagraph paragraph : doc.getParagraphs()) {
DummyContent.addItem(new DummyContent.DummyItem(Integer.toString(i), StringUtils.abbreviate(paragraph.getText(), 10)));
DummyContent.addItem(new DummyContent.DummyItem(Integer.toString(i), StringUtils.abbreviate(paragraph.getText(), 20), paragraph.getText()));
i++;
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ public class DummyContent {
/**
* A map of sample (dummy) items, by ID.
*/
public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
public static Map<String, DummyItem> ITEM_MAP = new HashMap<>();

static {
initialize();
}

public static void initialize() {
DummyContent.ITEM_MAP.clear();
DummyContent.ITEMS.clear();

// Add 3 sample items.
addItem(new DummyItem("1", "Item 1"));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 3"));
addItem(new DummyItem("1", "Item 1", "Long Item 1"));
addItem(new DummyItem("2", "Item 2", "Long Item 1"));
addItem(new DummyItem("3", "Item 3", "Long Item 1"));
}

public static void addItem(DummyItem item) {
Expand All @@ -41,10 +48,12 @@ public static void addItem(DummyItem item) {
public static class DummyItem {
public String id;
public String content;
public String longContent;

public DummyItem(String id, String content) {
public DummyItem(String id, String content, String longContent) {
this.id = id;
this.content = content;
this.longContent = longContent;
}

@Override
Expand Down

0 comments on commit daa58c7

Please sign in to comment.