Browse Source

Board fixes

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
cd2160a4f3
  1. 25
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  2. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java

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

@ -29,7 +29,7 @@ import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMoreListener{ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMoreListener {
/** /**
* Debug Tag for logging debug output to LogCat * Debug Tag for logging debug output to LogCat
*/ */
@ -144,7 +144,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override @Override
protected Boolean doInBackground(String... boardUrl) { protected Boolean doInBackground(String... boardUrl) {
Log.d(TAG, boardUrl[0]);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(boardUrl[0]) .url(boardUrl[0])
.build(); .build();
@ -179,17 +178,20 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
if (isLoadingMore) { if (isLoadingMore) {
parsedTopics.remove(parsedTopics.size() - 1); parsedTopics.remove(parsedTopics.size() - 1);
} }
//Finds number of pages //Finds number of pages
if (numberOfPages == -1) { if (numberOfPages == -1) {
Elements pages = boardPage.select("table.tborder td.catbg[height=30]").first()
.select("a.navPages");
numberOfPages = 1; numberOfPages = 1;
if (pages != null && !pages.isEmpty()) { try {
for (Element page : pages) { Elements pages = boardPage.select("table.tborder td.catbg[height=30]").first()
if (Integer.parseInt(page.text()) > numberOfPages) .select("a.navPages");
numberOfPages = Integer.parseInt(page.text()); if (pages != null && !pages.isEmpty()) {
for (Element page : pages) {
if (Integer.parseInt(page.text()) > numberOfPages)
numberOfPages = Integer.parseInt(page.text());
}
} }
} catch (NullPointerException nullP) {
//It just means this board has only one page of topics.
} }
} }
{ //Finds sub boards { //Finds sub boards
@ -197,7 +199,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
if (subBoardRows != null && !subBoardRows.isEmpty()) { if (subBoardRows != null && !subBoardRows.isEmpty()) {
for (Element subBoardRow : subBoardRows) { for (Element subBoardRow : subBoardRows) {
if (!Objects.equals(subBoardRow.className(), "titlebg")) { if (!Objects.equals(subBoardRow.className(), "titlebg")) {
String pUrl = "", pTitle = "", pMods = "", pStats = "", pLastPost = ""; String pUrl = "", pTitle = "", pMods = "", pStats = "",
pLastPost = "No posts yet";
Elements subBoardColumns = subBoardRow.select(">td"); Elements subBoardColumns = subBoardRow.select(">td");
for (Element subBoardCol : subBoardColumns) { for (Element subBoardCol : subBoardColumns) {
if (Objects.equals(subBoardCol.className(), "windowbg")) if (Objects.equals(subBoardCol.className(), "windowbg"))
@ -223,7 +226,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
String pTopicUrl, pSubject, pStartedBy, pLastPost, pStats; String pTopicUrl, pSubject, pStartedBy, pLastPost, pStats;
boolean pLocked = false, pSticky = false; boolean pLocked = false, pSticky = false;
Elements topicColumns = topicRow.select(">td"); Elements topicColumns = topicRow.select(">td");
if (topicColumns.size() != 7) return false; //if (topicColumns.size() != 7) return false;
{ {
Element column = topicColumns.get(2); Element column = topicColumns.get(2);
Element tmp = column.select("span[id^=msg_] a").first(); Element tmp = column.select("span[id^=msg_] a").first();

4
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java

@ -108,9 +108,9 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Intent intent = new Intent(context, TopicActivity.class); Intent intent = new Intent(context, TopicActivity.class);
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString(BUNDLE_TOPIC_URL, parsedTopics.get(holder. extras.putString(BUNDLE_TOPIC_URL, parsedTopics.get(holder.
getAdapterPosition()).getUrl()); getAdapterPosition() - parsedSubBoards.size()).getUrl());
extras.putString(BUNDLE_TOPIC_TITLE, parsedTopics.get(holder. extras.putString(BUNDLE_TOPIC_TITLE, parsedTopics.get(holder.
getAdapterPosition()).getSubject()); getAdapterPosition() - parsedSubBoards.size()).getSubject());
intent.putExtras(extras); intent.putExtras(extras);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK); intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); context.startActivity(intent);

Loading…
Cancel
Save