From b3d17994c37cf70545a13ba7815a33b040939a2f Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 15 Jan 2017 18:28:57 +0200 Subject: [PATCH] Minor fixes --- .../activities/board/BoardActivity.java | 8 ++++-- .../mthmmy/activities/board/BoardAdapter.java | 27 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index 3a1c1d67..68665b52 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -218,14 +218,18 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo pLastPost.substring(pLastPost.indexOf(" in ") + 1, pLastPost.indexOf(" by ")) + "\n" + pLastPost.substring(pLastPost.lastIndexOf(" by ") + 1); - } else { + pLastPostUrl = subBoardCol.select("a").first().attr("href"); + } else if (pLastPost.contains(" σε ")) { pLastPost = pLastPost.substring(0, pLastPost.indexOf(" σε ")) + "\n" + pLastPost.substring(pLastPost.indexOf(" σε ") + 1, pLastPost.indexOf(" από ")) + "\n" + pLastPost.substring(pLastPost.lastIndexOf(" από ") + 1); + pLastPostUrl = subBoardCol.select("a").first().attr("href"); + } else { + pLastPost = "No posts yet."; + pLastPostUrl = ""; } - pLastPostUrl = subBoardCol.select("a").first().attr("href"); } else { pUrl = subBoardCol.select("a").first().attr("href"); pTitle = subBoardCol.select("a").first().text(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java index c03882c4..16d8d25b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java @@ -14,6 +14,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; +import java.util.Objects; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.topic.TopicActivity; @@ -164,18 +165,20 @@ class BoardAdapter extends RecyclerView.Adapter { subBoardViewHolder.boardMods.setText(subBoard.getMods()); subBoardViewHolder.boardStats.setText(subBoard.getStats()); subBoardViewHolder.boardLastPost.setText(subBoard.getLastPost()); - subBoardViewHolder.boardLastPost.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(context, TopicActivity.class); - Bundle extras = new Bundle(); - extras.putString(BUNDLE_TOPIC_URL, subBoard.getLastPostUrl()); - //Doesn't put an already ellipsized topic title in Bundle - intent.putExtras(extras); - intent.setFlags(FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - } - }); + if (!Objects.equals(subBoard.getLastPostUrl(), "")) { + subBoardViewHolder.boardLastPost.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(context, TopicActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_TOPIC_URL, subBoard.getLastPostUrl()); + //Doesn't put an already ellipsized topic title in Bundle + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + }); + } } else if (holder instanceof TopicViewHolder) { final Topic topic = parsedTopics.get(position - parsedSubBoards.size() - 1 - 1); final TopicViewHolder topicViewHolder = (TopicViewHolder) holder;