From a8762d66298e6c8d52235ab230a3b78c01e8e7cd Mon Sep 17 00:00:00 2001 From: oogee Date: Thu, 15 Nov 2018 11:17:42 +0200 Subject: [PATCH] cleanup --- .../mthmmy/activities/topic/TopicParser.java | 12 ++++---- .../gr/thmmy/mthmmy/utils/CrashReporter.java | 5 +++- .../mthmmy/utils/parsing/ParseHelpers.java | 28 +------------------ 3 files changed, 11 insertions(+), 34 deletions(-) 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 c2cdee07..f383793e 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 @@ -59,7 +59,7 @@ public class TopicParser { * @see org.jsoup.Jsoup Jsoup */ public static String parseUsersViewingThisTopic(Document topic, ParseHelpers.Language language) { - if (language.is(ParseHelpers.Language.GREEK)) + if (language == ParseHelpers.Language.GREEK) return topic.select("td:containsOwn(διαβάζουν αυτό το θέμα)").first().html(); return topic.select("td:containsOwn(are viewing this topic)").first().html(); } @@ -77,7 +77,7 @@ public class TopicParser { public static int parseCurrentPageIndex(Document topic, ParseHelpers.Language language) { int parsedPage = 1; - if (language.is(ParseHelpers.Language.GREEK)) { + if (language == ParseHelpers.Language.GREEK) { Elements findCurrentPage = topic.select("td:contains(Σελίδες:)>b"); for (Element item : findCurrentPage) { @@ -115,7 +115,7 @@ public class TopicParser { public static int parseTopicNumberOfPages(Document topic, int currentPage, ParseHelpers.Language language) { int returnPages = 1; - if (language.is(ParseHelpers.Language.GREEK)) { + if (language == ParseHelpers.Language.GREEK) { Elements pages = topic.select("td:contains(Σελίδες:)>a.navPages"); if (pages.size() != 0) { @@ -163,7 +163,7 @@ public class TopicParser { Elements postRows; //Each row is a post - if (language.is(ParseHelpers.Language.GREEK)) + if (language == ParseHelpers.Language.GREEK) postRows = topic.select("form[id=quickModForm]>table>tbody>tr:matches(στις)"); else { postRows = topic.select("form[id=quickModForm]>table>tbody>tr:matches(on)"); @@ -236,7 +236,7 @@ public class TopicParser { //Language dependent parsing Element userName; - if (language.is(ParseHelpers.Language.GREEK)) { + if (language == ParseHelpers.Language.GREEK) { //Finds username and profile's url userName = thisRow.select("a[title^=Εμφάνιση προφίλ του μέλους]").first(); if (userName == null) { //Deleted profile @@ -388,7 +388,7 @@ public class TopicParser { Element usersExtraInfo = userName.parent().nextElementSibling(); //Get sibling "div" List infoList = Arrays.asList(usersExtraInfo.html().split("
")); - if (language.is(ParseHelpers.Language.GREEK)) { + if (language == ParseHelpers.Language.GREEK) { for (String line : infoList) { if (line.contains("Μηνύματα:")) { postsLineIndex = infoList.indexOf(line); diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReporter.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReporter.java index 8f16fdc4..b9907e93 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReporter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReporter.java @@ -6,6 +6,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; +import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; public class CrashReporter { @@ -43,8 +44,10 @@ public class CrashReporter { languageValue = "English"; break; } + Crashlytics.setString(themeKey, themeValue); Crashlytics.setString(languageKey, languageValue); + Crashlytics.setBool("isLoggedIn", BaseApplication.getInstance().getSessionManager().isLoggedIn()); } public static void reportDocument(Document document, String key) { @@ -52,7 +55,7 @@ public class CrashReporter { ParseHelpers.Language language = ParseHelpers.Language.getLanguage(document); Elements postRows; - if (language.is(ParseHelpers.Language.GREEK)) + if (language == ParseHelpers.Language.GREEK) postRows = document.select("form[id=quickModForm]>table>tbody>tr:matches(στις)"); else postRows = document.select("form[id=quickModForm]>table>tbody>tr:matches(on)"); diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java index 3d694da6..976ff387 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java @@ -18,18 +18,12 @@ import timber.log.Timber; * and obfuscated emails. */ public class ParseHelpers { - /** - * Debug Tag for logging debug output to LogCat - */ - @SuppressWarnings("unused") - private static final String TAG = "ParseHelpers"; /** * An enum describing a forum page's language by defining the types: */ @@ -42,10 +36,6 @@ public class ParseHelpers { * Page language is english. */ ENGLISH, - /** - * Page language is english and the user is guest. - */ - ENGLISH_GUEST, /** * Page is incomplete. Data are not enough to determine the language. */ @@ -67,29 +57,13 @@ public class ParseHelpers { if (welcoming == null) { Element welcomingGuest = page.select("div[id=myuser]").first(); if (welcomingGuest != null) { - if (welcomingGuest.text().contains("Welcome")) return ENGLISH_GUEST; + if (welcomingGuest.text().contains("Welcome")) return ENGLISH; } return PAGE_INCOMPLETE; } else if (welcoming.text().contains("Καλώς ορίσατε")) return GREEK; else if (welcoming.text().contains("Hey")) return ENGLISH; else return UNDEFINED_LANGUAGE; } - - /** - * This method defines a custom equality check for {@link Language} enums. - *

Method returns true if parameter's Target is the same as the object and in the specific - * cases described below, false otherwise.