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