diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 9c0f73ea..ad8ecb28 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -150,7 +150,7 @@ class TopicAdapter extends RecyclerView.Adapter { return new EditMessageViewHolder(view); } else if (viewType == Poll.TYPE_POLL) { View view = LayoutInflater.from(parent.getContext()). - inflate(R.layout.activity_topic_edit_row, parent, false); + inflate(R.layout.activity_topic_poll, parent, false); return new PollViewHolder(view); } else { throw new IllegalArgumentException("Unknown view type"); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java index a23825c3..ecef6034 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java @@ -153,9 +153,12 @@ public class TopicParser { //Method's variables final int NO_INDEX = -1; + ArrayList parsedPostsList = new ArrayList<>(); + Poll poll = findPoll(topic); + if (poll != null) + parsedPostsList.add(poll); - ArrayList parsedPostsList = new ArrayList<>(); Elements postRows; //Each row is a post @@ -491,7 +494,7 @@ public class TopicParser { Element secondRow = tables.get(i).select("tr[class=windowbg]").first(); Element secondColumn = secondRow.child(1); String columnString = secondColumn.outerHtml(); - question = columnString.substring(columnString.indexOf('>'), columnString.indexOf('<', 2)).trim(); + question = columnString.substring(columnString.indexOf('>') + 1, columnString.indexOf('<', 2)).trim(); Element form = secondColumn.select("form").first(); if (form != null) { @@ -518,11 +521,12 @@ public class TopicParser { } } else { // english poll in results mode - Elements optionRows = secondColumn.child(0).select("table").first().children(); + Elements optionRows = secondColumn.child(0).child(0).select("table").first().child(0).children(); for (int j = 0; j < optionRows.size(); j++) { - String optionName = optionRows.get(i).child(0).text(); - String voteCountDescription = optionRows.get(i).child(1).text(); + String optionName = optionRows.get(j).child(0).text(); + String voteCountDescription = optionRows.get(j).child(1).text(); Matcher integerMatcher = integerPattern.matcher(voteCountDescription); + integerMatcher.find(); int voteCount = Integer.parseInt(voteCountDescription.substring(integerMatcher.start(), integerMatcher.end())); entries.add(new Poll.Entry(optionName, voteCount)); diff --git a/app/src/main/res/layout/activity_topic_poll.xml b/app/src/main/res/layout/activity_topic_poll.xml index 2803d653..9953846f 100644 --- a/app/src/main/res/layout/activity_topic_poll.xml +++ b/app/src/main/res/layout/activity_topic_poll.xml @@ -4,7 +4,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="wrap_content"> + android:layout_width="match_parent" + android:layout_height="250dp" />