|
@ -56,6 +56,7 @@ public class StatsFragment extends Fragment { |
|
|
private MaterialProgressBar progressBar; |
|
|
private MaterialProgressBar progressBar; |
|
|
private boolean haveParsed = false; |
|
|
private boolean haveParsed = false; |
|
|
|
|
|
|
|
|
|
|
|
private boolean userHasPosts = true; |
|
|
private String generalStatisticsTitle = "", generalStatistics = "", postingActivityByTimeTitle = "", mostPopularBoardsByPostsTitle = "", mostPopularBoardsByActivityTitle = ""; |
|
|
private String generalStatisticsTitle = "", generalStatistics = "", postingActivityByTimeTitle = "", mostPopularBoardsByPostsTitle = "", mostPopularBoardsByActivityTitle = ""; |
|
|
final private List<Entry> postingActivityByTime = new ArrayList<>(); |
|
|
final private List<Entry> postingActivityByTime = new ArrayList<>(); |
|
|
final private List<BarEntry> mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); |
|
|
final private List<BarEntry> mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); |
|
@ -123,6 +124,7 @@ public class StatsFragment extends Fragment { |
|
|
* as String parameter!</p> |
|
|
* as String parameter!</p> |
|
|
*/ |
|
|
*/ |
|
|
private class ProfileStatsTask extends AsyncTask<String, Void, Boolean> { |
|
|
private class ProfileStatsTask extends AsyncTask<String, Void, Boolean> { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onPreExecute() { |
|
|
protected void onPreExecute() { |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
@ -160,15 +162,24 @@ public class StatsFragment extends Fragment { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean parseStats(Document statsPage) { |
|
|
private boolean parseStats(Document statsPage) { |
|
|
|
|
|
//Doesn't go through all the parsing if this user has no posts
|
|
|
|
|
|
if (!statsPage.select("td:contains(No posts to speak of!)").isEmpty()) { |
|
|
|
|
|
userHasPosts = false; |
|
|
|
|
|
} |
|
|
|
|
|
if (!statsPage.select("td:contains(Δεν υπάρχει καμία αποστολή μηνύματος!)").isEmpty()) { |
|
|
|
|
|
userHasPosts = false; |
|
|
|
|
|
} |
|
|
if (statsPage.select("table.bordercolor[align]>tbody>tr").size() != 6) |
|
|
if (statsPage.select("table.bordercolor[align]>tbody>tr").size() != 6) |
|
|
return false; |
|
|
return false; |
|
|
{ |
|
|
{ |
|
|
Elements titleRows = statsPage.select("table.bordercolor[align]>tbody>tr.titlebg"); |
|
|
Elements titleRows = statsPage.select("table.bordercolor[align]>tbody>tr.titlebg"); |
|
|
generalStatisticsTitle = titleRows.first().text(); |
|
|
generalStatisticsTitle = titleRows.first().text(); |
|
|
|
|
|
if (userHasPosts) { |
|
|
postingActivityByTimeTitle = titleRows.get(1).text(); |
|
|
postingActivityByTimeTitle = titleRows.get(1).text(); |
|
|
mostPopularBoardsByPostsTitle = titleRows.last().select("td").first().text(); |
|
|
mostPopularBoardsByPostsTitle = titleRows.last().select("td").first().text(); |
|
|
mostPopularBoardsByActivityTitle = titleRows.last().select("td").last().text(); |
|
|
mostPopularBoardsByActivityTitle = titleRows.last().select("td").last().text(); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
{ |
|
|
{ |
|
|
Elements statsRows = statsPage.select("table.bordercolor[align]>tbody>tr:not(.titlebg)"); |
|
|
Elements statsRows = statsPage.select("table.bordercolor[align]>tbody>tr:not(.titlebg)"); |
|
|
{ |
|
|
{ |
|
@ -177,6 +188,7 @@ public class StatsFragment extends Fragment { |
|
|
generalStatistics += generalStatisticsRow.text() + "\n"; |
|
|
generalStatistics += generalStatisticsRow.text() + "\n"; |
|
|
generalStatistics = generalStatistics.trim(); |
|
|
generalStatistics = generalStatistics.trim(); |
|
|
} |
|
|
} |
|
|
|
|
|
if (userHasPosts) { |
|
|
{ |
|
|
{ |
|
|
Elements postingActivityByTimeCols = statsRows.get(1).select(">td").last() |
|
|
Elements postingActivityByTimeCols = statsRows.get(1).select(">td").last() |
|
|
.select("tr").first().select("td[width=4%]"); |
|
|
.select("tr").first().select("td[width=4%]"); |
|
@ -212,6 +224,7 @@ public class StatsFragment extends Fragment { |
|
|
Collections.reverse(mostPopularBoardsByActivityLabels); |
|
|
Collections.reverse(mostPopularBoardsByActivityLabels); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -221,6 +234,13 @@ public class StatsFragment extends Fragment { |
|
|
.setText(generalStatisticsTitle); |
|
|
.setText(generalStatisticsTitle); |
|
|
((TextView) mainContent.findViewById(R.id.general_statistics)) |
|
|
((TextView) mainContent.findViewById(R.id.general_statistics)) |
|
|
.setText(generalStatistics); |
|
|
.setText(generalStatistics); |
|
|
|
|
|
|
|
|
|
|
|
if (!userHasPosts) { |
|
|
|
|
|
mainContent.removeViews(2, mainContent.getChildCount() - 2); |
|
|
|
|
|
//mainContent.removeViews(2, 6);
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
((TextView) mainContent.findViewById(R.id.posting_activity_by_time_title)) |
|
|
((TextView) mainContent.findViewById(R.id.posting_activity_by_time_title)) |
|
|
.setText(postingActivityByTimeTitle); |
|
|
.setText(postingActivityByTimeTitle); |
|
|
|
|
|
|
|
|