Browse Source

Minor board and topic fixes

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
56297beaa7
  1. 8
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  2. 10
      app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java

8
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.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ProgressBar; 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(); Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish(); 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 //Initializes graphics
toolbar = findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
@ -164,7 +169,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d("Boardaa", "onResume called!");
refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark)); refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark));
} }

10
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")
|| Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php")) || Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php"))
return PageCategory.INDEX; 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.UNKNOWN_THMMY;
} }
return PageCategory.NOT_THMMY; return PageCategory.NOT_THMMY;
@ -172,7 +172,7 @@ public class ThmmyPage {
if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) { if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) {
String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6); String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6);
if (returnString.contains(".")) if (returnString.contains("."))
returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf(".")); returnString = returnString.substring(0, returnString.indexOf("."));
return returnString; return returnString;
} }
return null; return null;
@ -180,8 +180,10 @@ public class ThmmyPage {
public static String getTopicId(String topicUrl) { public static String getTopicId(String topicUrl) {
if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) { if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) {
String tmp = topicUrl.substring(topicUrl.indexOf("topic=") + 6); String returnString = topicUrl.substring(topicUrl.indexOf("topic=") + 6);
return tmp.substring(0, tmp.indexOf(".")); if (returnString.contains("."))
returnString = returnString.substring(0, returnString.indexOf("."));
return returnString;
} }
return null; return null;
} }

Loading…
Cancel
Save