From 7199c982c620dc7d3fdb11f1349db26a67db5a1a Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 6 Oct 2018 13:50:17 +0300 Subject: [PATCH] Shoutbox improvements --- .../main/shoutbox/ShoutAdapter.java | 2 +- .../main/shoutbox/ShoutboxFragment.java | 7 +++-- .../main/shoutbox/ShoutboxTask.java | 5 ++-- .../thmmy/mthmmy/session/SessionManager.java | 1 + app/src/main/res/layout/fragment_shoutbox.xml | 22 +++++++-------- ...ut.xml => fragment_shoutbox_shout_row.xml} | 28 +++++++++++-------- 6 files changed, 37 insertions(+), 28 deletions(-) rename app/src/main/res/layout/{shout.xml => fragment_shoutbox_shout_row.xml} (84%) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java index 80d91fae..164d4105 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java @@ -48,7 +48,7 @@ public class ShoutAdapter extends CustomRecyclerView.Adapter { shoutboxTask = new ShoutboxTask(ShoutboxFragment.this::onShoutboxTaskSarted, ShoutboxFragment.this::onShoutboxTaskFinished); - shoutboxTask.execute("https://www.thmmy.gr/smf/index.php?action=forum"); + shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); }); emojiKeyboard = rootView.findViewById(R.id.emoji_keyboard); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java index 69cfd819..289ec0fb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java @@ -21,8 +21,8 @@ public class ShoutboxTask extends NewParseTask { @Override protected Shoutbox parse(Document document, Response response) throws ParseException { - // shout container: document.select("div[class=smalltext]" && div.text().contains("Τελευταίες 75 φωνές:") η στα αγγλικα - Element shoutboxContainer = document.select("div[style=width: 99%; height: 600px; overflow: auto;]").first(); + // fragment_shoutbox_shout_row container: document.select("div[class=smalltext]" && div.text().contains("Τελευταίες 75 φωνές:") η στα αγγλικα + Element shoutboxContainer = document.select("table.windowbg").first(); ArrayList shouts = new ArrayList<>(); for (Element shout : shoutboxContainer.select("div[style=margin: 4px;]")) { Element user = shout.child(0); @@ -35,6 +35,7 @@ public class ShoutboxTask extends NewParseTask { String dateString = date.text(); Element content = shout.child(2); + content.removeAttr("style"); String shoutContent = "" + ParseHelpers.youtubeEmbeddedFix(content); shouts.add(new Shout(profileName, profileUrl, dateString, shoutContent, memberOfTheMonth)); diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index c82ecaab..4811195d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -37,6 +37,7 @@ public class SessionManager { public static final HttpUrl forumUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=forum;theme=4"); private static final HttpUrl loginUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=login2"); public static final HttpUrl unreadUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=unread;all;start=0;theme=4"); + public static final HttpUrl shoutboxUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=tpmod;sa=shoutbox;theme=4"); private static final String guestName = "Guest"; //Response Codes diff --git a/app/src/main/res/layout/fragment_shoutbox.xml b/app/src/main/res/layout/fragment_shoutbox.xml index 1c602602..c7f8485c 100644 --- a/app/src/main/res/layout/fragment_shoutbox.xml +++ b/app/src/main/res/layout/fragment_shoutbox.xml @@ -1,8 +1,7 @@ - @@ -15,7 +14,7 @@ android:indeterminate="true" android:visibility="invisible" app:mpb_indeterminateTint="@color/accent" - app:mpb_progressStyle="horizontal"/> + app:mpb_progressStyle="horizontal" /> - + @@ -36,12 +35,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" - android:layout_marginEnd="8dp"/> + android:layout_marginEnd="8dp" + android:paddingTop="8dp" /> + android:visibility="gone" /> \ No newline at end of file diff --git a/app/src/main/res/layout/shout.xml b/app/src/main/res/layout/fragment_shoutbox_shout_row.xml similarity index 84% rename from app/src/main/res/layout/shout.xml rename to app/src/main/res/layout/fragment_shoutbox_shout_row.xml index c9f17aa7..9d606e5d 100644 --- a/app/src/main/res/layout/shout.xml +++ b/app/src/main/res/layout/fragment_shoutbox_shout_row.xml @@ -1,14 +1,13 @@ - + + android:paddingTop="9dp" + android:textColor="@color/accent" + android:textStyle="bold" + tools:text="author" /> + android:textSize="11sp" + tools:text="date & time" /> + tools:ignore="WebViewLayout" /> + + \ No newline at end of file