Browse Source

BoardActivity improvements

pull/70/head
Ezerous 5 years ago
parent
commit
d767d27072
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 56
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  2. 22
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
  3. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  4. 9
      app/src/main/res/layout/activity_board_sub_board_row.xml

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

@ -80,12 +80,11 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish();
}
//Fixes url
{
String tmpUrlSbstr = boardUrl.replaceAll("(.+)(board=)([0-9]*)(\\.*[0-9]*).*", "$1$2$3");
if (!tmpUrlSbstr.substring(tmpUrlSbstr.indexOf("board=")).contains("."))
boardUrl = tmpUrlSbstr + ".0";
}
String tmpUrlSbstr = boardUrl.replaceAll("(.+)(board=)([0-9]*)(\\.*[0-9]*).*", "$1$2$3");
if (!tmpUrlSbstr.substring(tmpUrlSbstr.indexOf("board=")).contains("."))
boardUrl = tmpUrlSbstr + ".0";
//Initializes graphics
toolbar = findViewById(R.id.toolbar);
@ -239,8 +238,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
pLastPost = "No posts yet", pLastPostUrl = "";
Elements subBoardColumns = subBoardRow.select(">td");
for (Element subBoardCol : subBoardColumns) {
if (Objects.equals(subBoardCol.className(), "windowbg"))
if (Objects.equals(subBoardCol.className(), "windowbg")){
pStats = subBoardCol.text();
if(pStats.equals("--"))
pStats = "";
}
else if (Objects.equals(subBoardCol.className(), "smalltext")) {
pLastPost = subBoardCol.text();
if (pLastPost.contains(" in ")) {
@ -257,16 +260,15 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
"\n" +
pLastPost.substring(pLastPost.lastIndexOf(" από ") + 1);
pLastPostUrl = subBoardCol.select("a").first().attr("href");
} else {
pLastPost = "No posts yet.";
pLastPostUrl = "";
}
} else if (pLastPost.contains("redirected clicks")||pLastPost.contains("N/A"))
pLastPost = "";
else
pLastPost = "No posts yet";
} else {
pUrl = subBoardCol.select("a").first().attr("href");
pTitle = subBoardCol.select("a").first().text();
if (subBoardCol.select("div.smalltext").first() != null) {
if (subBoardCol.select("div.smalltext").first() != null)
pMods = subBoardCol.select("div.smalltext").first().text();
}
}
}
tempSubboards.add(new Board(pUrl, pTitle, pMods, pStats, pLastPost, pLastPostUrl));
@ -282,18 +284,18 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
String pTopicUrl, pSubject, pStarter, pLastUser="", pLastPostDateTime="00:00:00", pLastPost, pLastPostUrl, pStats;
boolean pLocked = false, pSticky = false, pUnread = false;
Elements topicColumns = topicRow.select(">td");
{
Element column = topicColumns.get(2);
Element tmp = column.select("span[id^=msg_] a").first();
pTopicUrl = tmp.attr("href");
pSubject = tmp.text();
if (column.select("img[id^=stickyicon]").first() != null)
pSticky = true;
if (column.select("img[id^=lockicon]").first() != null)
pLocked = true;
if (column.select("a[id^=newicon]").first() != null)
pUnread = true;
}
Element column = topicColumns.get(2);
Element tmp = column.select("span[id^=msg_] a").first();
pTopicUrl = tmp.attr("href");
pSubject = tmp.text();
if (column.select("img[id^=stickyicon]").first() != null)
pSticky = true;
if (column.select("img[id^=lockicon]").first() != null)
pLocked = true;
if (column.select("a[id^=newicon]").first() != null)
pUnread = true;
pStarter = topicColumns.get(3).text();
pStats = "Replies: " + topicColumns.get(4).text() + ", Views: " + topicColumns.get(5).text();
@ -304,8 +306,10 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
pLastPostDateTime = matcher.group(1);
pLastUser = matcher.group(3);
}
else
throw new ParseException("Parsing failed (pLastPost came with: \"" + pLastPost + "\")");
else{
Timber.e("Parsing failed (pLastPost came with: \"%s\", html was \"%s\")", pLastPost, topicColumns);
continue;
}
pLastPostUrl = topicColumns.last().select("a:has(img)").first().attr("href");
tempTopics.add(new Topic(pTopicUrl, pSubject, pStarter, pLastUser, pLastPostDateTime, pLastPostUrl,

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

@ -161,9 +161,25 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
boardExpandableVisibility.set(subBoardViewHolder.getAdapterPosition() - 1, !visible);
});
subBoardViewHolder.boardTitle.setText(subBoard.getTitle());
subBoardViewHolder.boardMods.setText(subBoard.getMods());
subBoardViewHolder.boardStats.setText(subBoard.getStats());
subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost());
String mods = subBoard.getMods();
String stats = subBoard.getStats();
String lastPost = subBoard.getLastPost();
if(!mods.isEmpty()){
subBoardViewHolder.boardMods.setText(mods);
subBoardViewHolder.boardMods.setVisibility(View.VISIBLE);
}
if(!stats.isEmpty()){
subBoardViewHolder.boardStats.setText(stats);
subBoardViewHolder.boardStats.setVisibility(View.VISIBLE);
}
if(!lastPost.isEmpty()){
subBoardViewHolder.boardLastPost.setText(lastPost);
subBoardViewHolder.boardLastPost.setVisibility(View.VISIBLE);
}
if (!Objects.equals(subBoard.getLastPostUrl(), "")) {
subBoardViewHolder.boardLastPost.setOnClickListener(view -> {
Intent intent = new Intent(context, TopicActivity.class);

1
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -982,7 +982,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
for (int i = 0; i < topicItems.size(); i++) {
if (topicItems.get(i) instanceof Post && ((Post) topicItems.get(i)).getPostIndex() == testAgainst) {
//same page
Timber.d(Integer.toString(i));
postFocusListener.onPostFocusChange(i);
return true;
}

9
app/src/main/res/layout/activity_board_sub_board_row.xml

@ -62,7 +62,8 @@
android:text="@string/child_board_mods"
android:textColor="@color/secondary_text"
android:textSize="12sp"
android:textStyle="italic" />
android:textStyle="italic"
android:visibility="gone" />
<TextView
android:id="@+id/child_board_stats"
@ -72,7 +73,8 @@
android:layout_marginBottom="1dp"
android:text="@string/child_board_stats"
android:textColor="@color/secondary_text"
android:textSize="12sp" />
android:textSize="12sp"
android:visibility="gone" />
<TextView
android:id="@+id/child_board_last_post"
@ -84,7 +86,8 @@
android:focusable="true"
android:text="@string/child_board_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp" />
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Loading…
Cancel
Save