@ -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 ;
/ * *
/ * *
@ -177,7 +178,7 @@ public class TopicParser {
p_specialRank , p_gender , p_personalText , p_numberOfPosts , p_postLastEditDate ,
p_specialRank , p_gender , p_personalText , p_numberOfPosts , p_postLastEditDate ,
p_postURL , p_deletePostURL , p_editPostURL ;
p_postURL , p_deletePostURL , p_editPostURL ;
int p_postNum , p_postIndex , p_numberOfStars , p_userColor ;
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 ;
ArrayList < ThmmyFile > p_attachedFiles ;
//Initialize variables
//Initialize variables
@ -396,50 +397,37 @@ 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 ;
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 ) {
for ( String line : infoList ) {
if ( line . contains ( "Μηνύματα:" ) ) {
if ( line . contains ( postsStr ) ) {
postsLineIndex = infoList . indexOf ( line ) ;
postsLineIndex = infoList . indexOf ( line ) ;
//Remove any line breaks and spaces on the start and end
//Remove any line breaks and spaces on the start and end
p_numberOfPosts = line . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) ;
p_numberOfPosts = line . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) ;
}
}
if ( line . contains ( "Φύλο:" ) ) {
if ( line . contains ( genderStr ) ) {
if ( line . contains ( "alt=\"Άντρας\"" ) )
if ( line . contains ( altMaleStr ) )
p_gender = "Φύλο: Άντρας" ;
p_gender = genderMaleStr ;
else
else
p_gender = "Φύλο: Γυναίκα" ;
p_gender = genderFemaleStr ;
}
}
if ( line . contains ( "alt=\"*\"" ) ) {
if ( line . contains ( "alt=\"*\"" ) ) {
starsLineIndex = infoList . indexOf ( line ) ;
starsLineIndex = infoList . indexOf ( line ) ;
Document starsHtml = Jsoup . parse ( line ) ;
starsHtml = Jsoup . parse ( line ) ;
p_numberOfStars = starsHtml . select ( "img[alt]" ) . size ( ) ;
p_userColor = colorPicker ( starsHtml . select ( "img[alt]" ) . first ( )
. attr ( "abs:src" ) ) ;
}
}
}
}
else {
if ( line . contains ( pmTitleWithOnlineStatusStr ) )
for ( String line : infoList ) {
p_isUserOnline = true ;
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_numberOfStars = starsHtml . select ( "img[alt]" ) . size ( ) ;
p_userColor = colorPicker ( starsHtml . select ( "img[alt]" ) . first ( )
. attr ( "abs:src" ) ) ;
}
}
}
//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
@ -451,6 +439,12 @@ 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
}
}
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 ) {
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
@ -475,7 +469,7 @@ public class TopicParser {
, p_postNum , p_postDate , p_profileURL , p_rank , p_specialRank , p_gender
, p_postNum , p_postDate , p_profileURL , p_rank , p_specialRank , p_gender
, p_numberOfPosts , p_personalText , p_numberOfStars , p_userColor
, p_numberOfPosts , p_personalText , p_numberOfStars , p_userColor
, p_attachedFiles , p_postLastEditDate , p_postURL , p_deletePostURL , p_editPostURL
, 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
else { //Deleted user
@ -586,7 +580,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" ) )