Browse Source

fix board load more function

pull/61/merge
Thodoris1999 6 years ago
parent
commit
b6ad92120b
  1. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

13
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -104,7 +104,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
else { else {
newTopicFAB.setOnClickListener(view -> { newTopicFAB.setOnClickListener(view -> {
if (sessionManager.isLoggedIn()) { if (sessionManager.isLoggedIn()) {
//TODO create topic
if (newTopicUrl != null) { if (newTopicUrl != null) {
Intent intent = new Intent(this, CreateContentActivity.class); Intent intent = new Intent(this, CreateContentActivity.class);
intent.putExtra(CreateContentActivity.EXTRA_NEW_TOPIC_URL, newTopicUrl); intent.putExtra(CreateContentActivity.EXTRA_NEW_TOPIC_URL, newTopicUrl);
@ -195,6 +194,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override //TODO should throw ParseException @Override //TODO should throw ParseException
public void parse(Document boardPage) throws ParseException { public void parse(Document boardPage) throws ParseException {
tempSubboards.addAll(parsedSubBoards);
tempTopics.addAll(parsedTopics);
//Removes loading item
if (isLoadingMore) {
if (tempTopics.size() > 0) tempTopics.remove(tempTopics.size() - 1);
}
parsedTitle = boardPage.select("div.nav a.nav").last().text(); parsedTitle = boardPage.select("div.nav a.nav").last().text();
//Finds number of pages //Finds number of pages
@ -308,7 +313,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override @Override
protected void postExecution(ResultCode result) { protected void postExecution(ResultCode result) {
//TODO if (result == ResultCode.SUCCESS)...
if (result == ResultCode.SUCCESS) { if (result == ResultCode.SUCCESS) {
if (boardTitle == null || Objects.equals(boardTitle, "") if (boardTitle == null || Objects.equals(boardTitle, "")
|| !Objects.equals(boardTitle, parsedTitle)) { || !Objects.equals(boardTitle, parsedTitle)) {
@ -317,10 +321,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), false); thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), false);
} }
//Removes loading item Timber.d("topix " + tempTopics);
if (isLoadingMore) {
if (parsedTopics.size() > 0) parsedTopics.remove(parsedTopics.size() - 1);
}
parsedTopics.clear(); parsedTopics.clear();
parsedSubBoards.clear(); parsedSubBoards.clear();

Loading…
Cancel
Save