|
|
@ -140,16 +140,18 @@ public class RecentFragment extends BaseFragment { |
|
|
|
|
|
|
|
//---------------------------------------ASYNC TASK-----------------------------------
|
|
|
|
private class RecentTask extends ParseTask { |
|
|
|
private List<TopicSummary> fetchedRecent; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
fetchedRecent = new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void parse(Document document) throws ParseException { |
|
|
|
Elements recent = document.select("#block8 :first-child div"); |
|
|
|
if (!recent.isEmpty()) { |
|
|
|
topicSummaries.clear(); |
|
|
|
for (int i = 0; i < recent.size(); i += 3) { |
|
|
|
String link = recent.get(i).child(0).attr("href"); |
|
|
|
String title = recent.get(i).child(0).attr("title"); |
|
|
@ -180,7 +182,7 @@ public class RecentFragment extends BaseFragment { |
|
|
|
} else |
|
|
|
throw new ParseException("Parsing failed (dateTime)"); |
|
|
|
|
|
|
|
topicSummaries.add(new TopicSummary(link, title, lastUser, dateTime)); |
|
|
|
fetchedRecent.add(new TopicSummary(link, title, lastUser, dateTime)); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
@ -190,7 +192,11 @@ public class RecentFragment extends BaseFragment { |
|
|
|
@Override |
|
|
|
protected void postParsing(ParseTask.ResultCode result) { |
|
|
|
if (result == ResultCode.SUCCESS) |
|
|
|
{ |
|
|
|
topicSummaries.clear(); |
|
|
|
topicSummaries.addAll(fetchedRecent); |
|
|
|
recentAdapter.notifyDataSetChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
progressBar.setVisibility(ProgressBar.INVISIBLE); |
|
|
|
swipeRefreshLayout.setRefreshing(false); |
|
|
|