Browse Source

feat: add purple color to Veterans

develop
Ezerous 3 months ago
parent
commit
878bd404b5
  1. 74
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

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

@ -46,6 +46,7 @@ public class TopicParser {
private static final int USER_COLOR_BLUE = Color.parseColor("#536DFE"); private static final int USER_COLOR_BLUE = Color.parseColor("#536DFE");
static final int USER_COLOR_PINK = Color.parseColor("#FF4081"); static final int USER_COLOR_PINK = Color.parseColor("#FF4081");
static final int USER_COLOR_YELLOW = Color.parseColor("#FFEB3B"); static final int USER_COLOR_YELLOW = Color.parseColor("#FFEB3B");
static final int USER_COLOR_PURPLE = Color.parseColor("#8C7DF2");
static final int USER_COLOR_WHITE = Color.WHITE; static final int USER_COLOR_WHITE = Color.WHITE;
/** /**
@ -396,51 +397,35 @@ public class TopicParser {
Element usersExtraInfo = userName.parent().nextElementSibling(); //Get sibling "div" Element usersExtraInfo = userName.parent().nextElementSibling(); //Get sibling "div"
List<String> infoList = Arrays.asList(usersExtraInfo.html().split("<br>")); List<String> infoList = Arrays.asList(usersExtraInfo.html().split("<br>"));
if (language == ParseHelpers.Language.GREEK) { final boolean displayedLanguageGreek = language == ParseHelpers.Language.GREEK;
for (String line : infoList) { final String genderStr = displayedLanguageGreek ? "Φύλο:" : "Gender:";
if (line.contains("Μηνύματα:")) { final String altMaleStr = displayedLanguageGreek ? "alt=\"Άντρας\"" : "alt=\"Male\"";
postsLineIndex = infoList.indexOf(line); final String genderMaleStr = displayedLanguageGreek ? "Φύλο: Άντρας" : "Gender: Male";
//Remove any line breaks and spaces on the start and end final String genderFemaleStr = displayedLanguageGreek ? "Φύλο: Γυναίκα" : "Gender: Female";
p_numberOfPosts = line.replace("\n", "").replace("\r", "").trim(); final String postsStr = displayedLanguageGreek ? "Μηνύματα:" : "Posts:";
}
if (line.contains("Φύλο:")) { Document starsHtml= Jsoup.parse("");
if (line.contains("alt=\"Άντρας\""))
p_gender = "Φύλο: Άντρας"; for (String line : infoList) {
else if (line.contains(postsStr)) {
p_gender = "Φύλο: Γυναίκα"; postsLineIndex = infoList.indexOf(line);
} //Remove any line breaks and spaces on the start and end
if (line.contains("alt=\"*\"")) { p_numberOfPosts = line.replace("\n", "").replace("\r", "").trim();
starsLineIndex = infoList.indexOf(line);
Document starsHtml = Jsoup.parse(line);
p_numberOfStars = starsHtml.select("img[alt]").size();
p_userColor = colorPicker(starsHtml.select("img[alt]").first()
.attr("abs:src"));
}
} }
} if (line.contains(genderStr)) {
else { if (line.contains(altMaleStr))
for (String line : infoList) { p_gender = genderMaleStr;
if (line.contains("Posts:")) { else
postsLineIndex = infoList.indexOf(line); p_gender = genderFemaleStr;
//Remove any line breaks and spaces on the start and end }
p_numberOfPosts = line.replace("\n", "").replace("\r", "").trim(); if (line.contains("alt=\"*\"")) {
} starsLineIndex = infoList.indexOf(line);
if (line.contains("Gender:")) { starsHtml = Jsoup.parse(line);
if (line.contains("alt=\"Male\""))
p_gender = "Gender: Male";
else
p_gender = "Gender: Female";
}
if (line.contains("alt=\"*\"")) {
starsLineIndex = infoList.indexOf(line);
Document starsHtml = Jsoup.parse(line);
p_numberOfStars = starsHtml.select("img[alt]").size();
p_userColor = colorPicker(starsHtml.select("img[alt]").first()
.attr("abs:src"));
}
} }
} }
p_numberOfStars = starsHtml.select("img[alt]").size();
//If this member has no stars yet ==> New member, //If this member has no stars yet ==> New member,
//or is just a member //or is just a member
if (starsLineIndex == -1 || starsLineIndex == 1) { if (starsLineIndex == -1 || starsLineIndex == 1) {
@ -451,6 +436,9 @@ public class TopicParser {
p_specialRank = infoList.get(0).trim(); //First line has the special rank p_specialRank = infoList.get(0).trim(); //First line has the special rank
p_rank = infoList.get(1).trim(); //Second line has the rank p_rank = infoList.get(1).trim(); //Second line has the rank
} }
p_userColor = colorPicker(starsHtml.select("img[alt]").first().attr("abs:src"), p_specialRank);
for (int i = postsLineIndex + 1; i < infoList.size() - 1; ++i) { for (int i = postsLineIndex + 1; i < infoList.size() - 1; ++i) {
//Searches under "Posts:" //Searches under "Posts:"
//and above "Personal Message", "View Profile" etc buttons //and above "Personal Message", "View Profile" etc buttons
@ -586,7 +574,9 @@ public class TopicParser {
* @param starsUrl String containing the URL of a user's stars * @param starsUrl String containing the URL of a user's stars
* @return an int corresponding to the right color * @return an int corresponding to the right color
*/ */
private static int colorPicker(String starsUrl) { private static int colorPicker(String starsUrl, String specialRank) {
if(Objects.equals(specialRank, "Veteran"))
return USER_COLOR_PURPLE;
if (starsUrl.contains("/star.gif")) if (starsUrl.contains("/star.gif"))
return USER_COLOR_YELLOW; return USER_COLOR_YELLOW;
else if (starsUrl.contains("/starmod.gif")) else if (starsUrl.contains("/starmod.gif"))

Loading…
Cancel
Save