From 56297beaa7efb8a32e2cf15f89ae51b0685d0371 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Tue, 25 Jul 2017 18:04:57 +0300 Subject: [PATCH] Minor board and topic fixes --- .../thmmy/mthmmy/activities/board/BoardActivity.java | 8 ++++++-- app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java | 10 ++++++---- 2 files changed, 12 insertions(+), 6 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 9ffc55c5..742a73b3 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 @@ -7,7 +7,6 @@ import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.View; import android.widget.ImageButton; import android.widget.ProgressBar; @@ -73,6 +72,12 @@ 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"; + } //Initializes graphics toolbar = findViewById(R.id.toolbar); @@ -164,7 +169,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo @Override public void onResume() { super.onResume(); - Log.d("Boardaa", "onResume called!"); refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark)); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java index 3ca324ed..8962f2b9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java @@ -162,7 +162,7 @@ public class ThmmyPage { || Objects.equals(uriString, "https://www.thmmy.gr") || Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php")) return PageCategory.INDEX; - Timber.v("Unknown thmmy link found, link: %s" , uriString); + Timber.v("Unknown thmmy link found, link: %s", uriString); return PageCategory.UNKNOWN_THMMY; } return PageCategory.NOT_THMMY; @@ -172,7 +172,7 @@ public class ThmmyPage { if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) { String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6); if (returnString.contains(".")) - returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf(".")); + returnString = returnString.substring(0, returnString.indexOf(".")); return returnString; } return null; @@ -180,8 +180,10 @@ public class ThmmyPage { public static String getTopicId(String topicUrl) { if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) { - String tmp = topicUrl.substring(topicUrl.indexOf("topic=") + 6); - return tmp.substring(0, tmp.indexOf(".")); + String returnString = topicUrl.substring(topicUrl.indexOf("topic=") + 6); + if (returnString.contains(".")) + returnString = returnString.substring(0, returnString.indexOf(".")); + return returnString; } return null; }