@ -46,6 +46,7 @@ public class TopicParser {
private static final int USER_COLOR_BLUE = Color . parseColor ( "#536DFE" ) ;
static final int USER_COLOR_PINK = Color . parseColor ( "#FF4081" ) ;
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 ;
/ * *
@ -177,7 +178,7 @@ public class TopicParser {
p_specialRank , p_gender , p_personalText , p_numberOfPosts , p_postLastEditDate ,
p_postURL , p_deletePostURL , p_editPostURL ;
int p_postNum , p_postIndex , p_numberOfStars , p_userColor ;
boolean p_isDeleted = false , p_isUserMentionedInPost = false ;
boolean p_isDeleted = false , p_isUserMentionedInPost = false , p_isUserOnline = false ;
ArrayList < ThmmyFile > p_attachedFiles ;
//Initialize variables
@ -396,51 +397,38 @@ public class TopicParser {
Element usersExtraInfo = userName . parent ( ) . nextElementSibling ( ) ; //Get sibling "div"
List < String > infoList = Arrays . asList ( usersExtraInfo . html ( ) . split ( "<br>" ) ) ;
if ( language = = ParseHelpers . Language . GREEK ) {
for ( String line : infoList ) {
if ( line . contains ( "Μηνύματα:" ) ) {
postsLineIndex = infoList . indexOf ( line ) ;
//Remove any line breaks and spaces on the start and end
p_numberOfPosts = line . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) ;
}
if ( line . contains ( "Φύλο:" ) ) {
if ( line . contains ( "alt=\"Άντρας\"" ) )
p_gender = "Φύλο: Άντρας" ;
else
p_gender = "Φύλο: Γυναίκα" ;
}
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" ) ) ;
}
final boolean displayedLanguageGreek = language = = ParseHelpers . Language . GREEK ;
final String genderStr = displayedLanguageGreek ? "Φύλο:" : "Gender:" ;
final String altMaleStr = displayedLanguageGreek ? "alt=\"Άντρας\"" : "alt=\"Male\"" ;
final String genderMaleStr = displayedLanguageGreek ? "Φύλο: Άντρας" : "Gender: Male" ;
final String genderFemaleStr = displayedLanguageGreek ? "Φύλο: Γυναίκα" : "Gender: Female" ;
final String postsStr = displayedLanguageGreek ? "Μηνύματα:" : "Posts:" ;
final String pmTitleWithOnlineStatusStr = displayedLanguageGreek ? "title=\"Προσωπικό μήνυμα (Σε σύνδεση)\"" : "title=\"Personal Message (Online)\"" ;
Document starsHtml = Jsoup . parse ( "" ) ;
for ( String line : infoList ) {
if ( line . contains ( postsStr ) ) {
postsLineIndex = infoList . indexOf ( line ) ;
//Remove any line breaks and spaces on the start and end
p_numberOfPosts = line . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) ;
}
}
else {
for ( String line : infoList ) {
if ( line . contains ( "Posts:" ) ) {
postsLineIndex = infoList . indexOf ( line ) ;
//Remove any line breaks and spaces on the start and end
p_numberOfPosts = line . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) ;
}
if ( line . contains ( "Gender:" ) ) {
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" ) ) ;
}
if ( line . contains ( genderStr ) ) {
if ( line . contains ( altMaleStr ) )
p_gender = genderMaleStr ;
else
p_gender = genderFemaleStr ;
}
if ( line . contains ( "alt=\"*\"" ) ) {
starsLineIndex = infoList . indexOf ( line ) ;
starsHtml = Jsoup . parse ( line ) ;
}
if ( line . contains ( pmTitleWithOnlineStatusStr ) )
p_isUserOnline = true ;
}
p_numberOfStars = starsHtml . select ( "img[alt]" ) . size ( ) ;
//If this member has no stars yet ==> New member,
//or is just a member
if ( starsLineIndex = = - 1 | | starsLineIndex = = 1 ) {
@ -451,6 +439,12 @@ public class TopicParser {
p_specialRank = infoList . get ( 0 ) . trim ( ) ; //First line has the special rank
p_rank = infoList . get ( 1 ) . trim ( ) ; //Second line has the rank
}
Element starsHtmlEl = starsHtml . select ( "img[alt]" ) . first ( ) ;
if ( p_numberOfStars > 0 & & starsHtmlEl ! = null )
p_userColor = colorPicker ( starsHtmlEl . attr ( "abs:src" ) , p_specialRank ) ;
for ( int i = postsLineIndex + 1 ; i < infoList . size ( ) - 1 ; + + i ) {
//Searches under "Posts:"
//and above "Personal Message", "View Profile" etc buttons
@ -475,7 +469,7 @@ public class TopicParser {
, p_postNum , p_postDate , p_profileURL , p_rank , p_specialRank , p_gender
, p_numberOfPosts , p_personalText , p_numberOfStars , p_userColor
, p_attachedFiles , p_postLastEditDate , p_postURL , p_deletePostURL , p_editPostURL
, p_isUserMentionedInPost , Post . TYPE_POST ) ) ;
, p_isUserOnline , p_isUser MentionedInPost , Post . TYPE_POST ) ) ;
}
else { //Deleted user
@ -586,7 +580,9 @@ public class TopicParser {
* @param starsUrl String containing the URL of a user ' s stars
* @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" ) )
return USER_COLOR_YELLOW ;
else if ( starsUrl . contains ( "/starmod.gif" ) )