Browse Source

Topic package minor fixes

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
4e4250093b
  1. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 32
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

1
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -185,7 +185,6 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
//Post's WebView parameters //Post's WebView parameters
holder.post.setClickable(true); holder.post.setClickable(true);
holder.post.setWebViewClient(new LinkLauncher()); holder.post.setWebViewClient(new LinkLauncher());
holder.post.getSettings().setJavaScriptEnabled(true);
//Avoids errors about layout having 0 width/height //Avoids errors about layout having 0 width/height
holder.thumbnail.setMinimumWidth(1); holder.thumbnail.setMinimumWidth(1);

32
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

@ -162,7 +162,7 @@ class TopicParser {
postRows = topic.select("form[id=quickModForm]>table>tbody>tr:matches(on)"); postRows = topic.select("form[id=quickModForm]>table>tbody>tr:matches(on)");
} }
for (Element item : postRows) { for (Element thisRow : postRows) {
//Variables for Post constructor //Variables for Post constructor
String p_userName, p_thumbnailUrl, p_subject, p_post, p_postDate, p_profileURL, p_rank, String p_userName, p_thumbnailUrl, p_subject, p_post, p_postDate, p_profileURL, p_rank,
p_specialRank, p_gender, p_personalText, p_numberOfPosts; p_specialRank, p_gender, p_personalText, p_numberOfPosts;
@ -183,20 +183,20 @@ class TopicParser {
//Language independent parsing //Language independent parsing
//Finds thumbnail url //Finds thumbnail url
Element thumbnailUrl = item.select("img.avatar").first(); Element thumbnailUrl = thisRow.select("img.avatar").first();
p_thumbnailUrl = null; //In case user doesn't have an avatar p_thumbnailUrl = null; //In case user doesn't have an avatar
if (thumbnailUrl != null) { if (thumbnailUrl != null) {
p_thumbnailUrl = thumbnailUrl.attr("abs:src"); p_thumbnailUrl = thumbnailUrl.attr("abs:src");
} }
//Finds subject //Finds subject
p_subject = item.select("div[id^=subject_]").first().select("a").first().text(); p_subject = thisRow.select("div[id^=subject_]").first().select("a").first().text();
//Finds post's text //Finds post's text
p_post = item.select("div").select(".post").first().outerHtml(); p_post = thisRow.select("div").select(".post").first().outerHtml();
{ //Fixes embedded videos { //Fixes embedded videos
Elements noembedTag = item.select("div").select(".post").first().select("noembed"); Elements noembedTag = thisRow.select("div").select(".post").first().select("noembed");
ArrayList<String> embededVideosUrls = new ArrayList<>(); ArrayList<String> embededVideosUrls = new ArrayList<>();
for (Element _noembed : noembedTag) { for (Element _noembed : noembedTag) {
@ -231,7 +231,7 @@ class TopicParser {
//Find post's index //Find post's index
//This is an int assigned by the forum used for post focusing and quotes, it is not //This is an int assigned by the forum used for post focusing and quotes, it is not
//the same as reply index. //the same as reply index.
Element postIndex = item.select("a[name^=msg]").first(); Element postIndex = thisRow.select("a[name^=msg]").first();
if (postIndex == null) if (postIndex == null)
p_postIndex = NO_INDEX; p_postIndex = NO_INDEX;
else { else {
@ -243,10 +243,10 @@ class TopicParser {
Element userName; Element userName;
if (Objects.equals(language, LANGUAGE_GREEK)) { if (Objects.equals(language, LANGUAGE_GREEK)) {
//Finds username and profile's url //Finds username and profile's url
userName = item.select("a[title^=Εμφάνιση προφίλ του μέλους]").first(); userName = thisRow.select("a[title^=Εμφάνιση προφίλ του μέλους]").first();
if (userName == null) { //Deleted profile if (userName == null) { //Deleted profile
p_isDeleted = true; p_isDeleted = true;
p_userName = item p_userName = thisRow
.select("td:has(div.smalltext:containsOwn(Επισκέπτης))[style^=overflow]") .select("td:has(div.smalltext:containsOwn(Επισκέπτης))[style^=overflow]")
.first().text(); .first().text();
p_userName = p_userName.substring(0, p_userName.indexOf(" Επισκέπτης")); p_userName = p_userName.substring(0, p_userName.indexOf(" Επισκέπτης"));
@ -257,13 +257,13 @@ class TopicParser {
} }
//Finds post's submit date //Finds post's submit date
Element postDate = item.select("div.smalltext:matches(στις:)").first(); Element postDate = thisRow.select("div.smalltext:matches(στις:)").first();
p_postDate = postDate.text(); p_postDate = postDate.text();
p_postDate = p_postDate.substring(p_postDate.indexOf("στις:") + 6 p_postDate = p_postDate.substring(p_postDate.indexOf("στις:") + 6
, p_postDate.indexOf(" »")); , p_postDate.indexOf(" »"));
//Finds post's reply index number //Finds post's reply index number
Element postNum = item.select("div.smalltext:matches(Απάντηση #)").first(); Element postNum = thisRow.select("div.smalltext:matches(Απάντηση #)").first();
if (postNum == null) { //Topic starter if (postNum == null) { //Topic starter
p_postNum = 0; p_postNum = 0;
} else { } else {
@ -273,7 +273,7 @@ class TopicParser {
//Finds attached file's urls, names and info, if present //Finds attached file's urls, names and info, if present
Elements postAttachments = item.select("div:containsOwn(έγινε λήψη):containsOwn(φορές.)"); Elements postAttachments = thisRow.select("div:containsOwn(έγινε λήψη):containsOwn(φορές.)");
if (postAttachments != null) { if (postAttachments != null) {
Elements attachedFiles = postAttachments.select("a"); Elements attachedFiles = postAttachments.select("a");
String postAttachmentsText = postAttachments.text(); String postAttachmentsText = postAttachments.text();
@ -303,10 +303,10 @@ class TopicParser {
} }
} else { } else {
//Finds username //Finds username
userName = item.select("a[title^=View the profile of]").first(); userName = thisRow.select("a[title^=View the profile of]").first();
if (userName == null) { //Deleted profile if (userName == null) { //Deleted profile
p_isDeleted = true; p_isDeleted = true;
p_userName = item p_userName = thisRow
.select("td:has(div.smalltext:containsOwn(Guest))[style^=overflow]") .select("td:has(div.smalltext:containsOwn(Guest))[style^=overflow]")
.first().text(); .first().text();
p_userName = p_userName.substring(0, p_userName.indexOf(" Guest")); p_userName = p_userName.substring(0, p_userName.indexOf(" Guest"));
@ -317,13 +317,13 @@ class TopicParser {
} }
//Finds post's submit date //Finds post's submit date
Element postDate = item.select("div.smalltext:matches(on:)").first(); Element postDate = thisRow.select("div.smalltext:matches(on:)").first();
p_postDate = postDate.text(); p_postDate = postDate.text();
p_postDate = p_postDate.substring(p_postDate.indexOf("on:") + 4 p_postDate = p_postDate.substring(p_postDate.indexOf("on:") + 4
, p_postDate.indexOf(" »")); , p_postDate.indexOf(" »"));
//Finds post's reply index number //Finds post's reply index number
Element postNum = item.select("div.smalltext:matches(Reply #)").first(); Element postNum = thisRow.select("div.smalltext:matches(Reply #)").first();
if (postNum == null) { //Topic starter if (postNum == null) { //Topic starter
p_postNum = 0; p_postNum = 0;
} else { } else {
@ -333,7 +333,7 @@ class TopicParser {
//Finds attached file's urls, names and info, if present //Finds attached file's urls, names and info, if present
Elements postAttachments = item.select("div:containsOwn(downloaded):containsOwn(times.)"); Elements postAttachments = thisRow.select("div:containsOwn(downloaded):containsOwn(times.)");
if (postAttachments != null) { if (postAttachments != null) {
Elements attachedFiles = postAttachments.select("a"); Elements attachedFiles = postAttachments.select("a");
String postAttachmentsText = postAttachments.text(); String postAttachmentsText = postAttachments.text();

Loading…
Cancel
Save