From 4ee13d970f907819535f9d62c19e4f9759a2e0e6 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 22 Mar 2017 13:10:06 +0200 Subject: [PATCH 1/4] Bug fixes --- .../activities/board/BoardActivity.java | 15 +++++++++----- .../activities/topic/TopicActivity.java | 20 +++++++++---------- .../mthmmy/activities/topic/TopicAdapter.java | 10 ++-------- 3 files changed, 21 insertions(+), 24 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 d4cf2236..00dbb69a 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 @@ -54,6 +54,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo private String boardUrl; private String boardTitle; + private String parsedTitle; private int numberOfPages = -1; private int pagesLoaded = 0; @@ -71,7 +72,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo boardUrl = extras.getString(BUNDLE_BOARD_URL); ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(boardUrl)); if (!target.is(ThmmyPage.PageCategory.BOARD)) { - Timber.e("Bundle came with a non board url!\nUrl:\n%s" , boardUrl); + Timber.e("Bundle came with a non board url!\nUrl:\n%s", boardUrl); Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show(); finish(); } @@ -175,7 +176,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo *

BoardTask's {@link AsyncTask#execute execute} method needs a boards's url as String * parameter!

*/ - public class BoardTask extends AsyncTask { + private class BoardTask extends AsyncTask { @Override protected void onPreExecute() { if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); @@ -200,7 +201,12 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo @Override protected void onPostExecute(Void voids) { - if (boardTitle == null || Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle); + if (boardTitle == null || Objects.equals(boardTitle, "") + || !Objects.equals(boardTitle, parsedTitle)) { + boardTitle = parsedTitle; + toolbar.setTitle(boardTitle); + thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl)); + } //Parse was successful ++pagesLoaded; @@ -211,8 +217,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo } private void parseBoard(Document boardPage) { - if (boardTitle == null || Objects.equals(boardTitle, "")) - boardTitle = boardPage.select("div.nav a.nav").last().text(); + parsedTitle = boardPage.select("div.nav a.nav").last().text(); //Removes loading item if (isLoadingMore) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index a733caf5..16528844 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -18,6 +18,7 @@ import android.text.method.LinkMovementMethod; import android.text.method.ScrollingMovementMethod; import android.text.style.ClickableSpan; import android.text.style.URLSpan; +import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.Menu; @@ -165,7 +166,7 @@ public class TopicActivity extends BaseActivity { recyclerView.setHasFixedSize(true); LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(layoutManager); - topicAdapter = new TopicAdapter(this, postsList, topicTask, topicTitle, loadedPageUrl); + topicAdapter = new TopicAdapter(this, postsList, topicTask); recyclerView.setAdapter(topicAdapter); replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); @@ -178,10 +179,10 @@ public class TopicActivity extends BaseActivity { public void onClick(View view) { if (sessionManager.isLoggedIn()) { postsList.add(null); - topicAdapter.prepareForReply(new ReplyTask()); + topicAdapter.notifyItemInserted(postsList.size()); + topicAdapter.prepareForReply(new ReplyTask(), topicTitle, loadedPageUrl); replyFAB.hide(); bottomNavBar.setVisibility(View.GONE); - topicAdapter.notifyItemInserted(postsList.size()); } } }); @@ -536,14 +537,16 @@ public class TopicActivity extends BaseActivity { switch (parseResult) { case SUCCESS: - if (topicTitle == null || Objects.equals(topicTitle, "")) { + if (topicTitle == null || Objects.equals(topicTitle, "") + || !Objects.equals(topicTitle, parsedTitle)) { + toolbarTitle.setText(parsedTitle); + topicTitle = parsedTitle; thisPageBookmark = new Bookmark(parsedTitle, ThmmyPage.getTopicId(loadedPageUrl)); invalidateOptionsMenu(); } progressBar.setVisibility(ProgressBar.INVISIBLE); topicAdapter.customNotifyDataSetChanged(new TopicTask()); - topicAdapter.setTopicInfo(parsedTitle, loadedPageUrl); if (replyPageUrl == null) replyFAB.hide(); if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true); @@ -552,11 +555,6 @@ public class TopicActivity extends BaseActivity { pageRequestValue = thisPage; paginationEnabled(true); - - if (topicTitle != null) - if (parsedTitle != null) - if (topicTitle == null || Objects.equals(topicTitle, "")) - toolbarTitle.setText(parsedTitle); break; case NETWORK_ERROR: Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); @@ -602,7 +600,7 @@ public class TopicActivity extends BaseActivity { } //Finds topic title if missing - if (topicTitle == null || Objects.equals(topicTitle, "")) { + { parsedTitle = topic.select("td[id=top_subject]").first().text(); if (parsedTitle.contains("Topic:")) { parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Topic:") + 7 diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index b06b684a..0e6d326d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -111,8 +111,7 @@ class TopicAdapter extends RecyclerView.Adapter { * @param context the context of the {@link RecyclerView} * @param postsList List of {@link Post} objects to use */ - TopicAdapter(Context context, List postsList, TopicActivity.TopicTask topicTask - , String topicTitle, String loadedPageUrl) { + TopicAdapter(Context context, List postsList, TopicActivity.TopicTask topicTask) { this.context = context; this.postsList = postsList; @@ -122,15 +121,10 @@ class TopicAdapter extends RecyclerView.Adapter { viewProperties.add(new boolean[3]); } this.topicTask = topicTask; - this.topicTitle = topicTitle; - this.loadedPageUrl = loadedPageUrl; } - void prepareForReply(TopicActivity.ReplyTask replyTask) { + void prepareForReply(TopicActivity.ReplyTask replyTask, String topicTitle, String loadedPageUrl) { this.replyTask = replyTask; - } - - void setTopicInfo(String topicTitle, String loadedPageUrl) { this.topicTitle = topicTitle; this.loadedPageUrl = loadedPageUrl; } From 79475860ee3f2eced92638bde9b5a1c9b57094a6 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 22 Mar 2017 23:43:55 +0200 Subject: [PATCH 2/4] Bug fixes --- .../java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java | 1 - .../main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 16528844..050fea14 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -18,7 +18,6 @@ import android.text.method.LinkMovementMethod; import android.text.method.ScrollingMovementMethod; import android.text.style.ClickableSpan; import android.text.style.URLSpan; -import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.Menu; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 0e6d326d..f1a0cca2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -476,6 +476,7 @@ class TopicAdapter extends RecyclerView.Adapter { holder.quickReplySubject.getText().clear(); holder.quickReplySubject.setText("Re: " + topicTitle); holder.quickReply.getText().clear(); + holder.submitButton.setEnabled(true); } }); } From 8d846896694b76327c2663a18a037a7e32b79cc3 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Wed, 22 Mar 2017 23:56:06 +0200 Subject: [PATCH 3/4] Updated Version to 1.2.1 --- VERSION | 2 +- app/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 26aaba0e..6085e946 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.0 +1.2.1 diff --git a/app/build.gradle b/app/build.gradle index f1403f49..1517040e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 19 targetSdkVersion 25 - versionCode 6 - versionName "1.2.0" + versionCode 7 + versionName "1.2.1" archivesBaseName = "mTHMMY-v$versionName" } From 9066096b46d29affb1e6bafa1964d21bccfeb708 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 23 Mar 2017 00:12:37 +0200 Subject: [PATCH 4/4] Added margin below last post --- app/src/main/res/layout/activity_topic.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index e4735bcc..2a0eb516 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -46,6 +46,8 @@ android:layout_gravity="top|start" android:layout_marginTop="64dp" android:background="@color/background" + android:paddingBottom="54dp" + android:clipToPadding="false" android:scrollbars="none" tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity">