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.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));
}

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/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;
}

Loading…
Cancel
Save