Browse Source

Merge pull request #24 from Thodoris1999/develop

new sticky icon, add unread icon
pull/27/head
Apostolos Fanakis 7 years ago
committed by GitHub
parent
commit
d186f2743c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  2. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
  3. 18
      app/src/main/java/gr/thmmy/mthmmy/model/Topic.java
  4. 2
      app/src/main/res/values/strings.xml

6
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -265,7 +265,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
for (Element topicRow : topicRows) {
if (!Objects.equals(topicRow.className(), "titlebg")) {
String pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl, pStats;
boolean pLocked = false, pSticky = false;
boolean pLocked = false, pSticky = false, pUnread = false;
Elements topicColumns = topicRow.select(">td");
{
Element column = topicColumns.get(2);
@ -276,6 +276,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
pSticky = true;
if (column.select("img[id^=lockicon]").first() != null)
pLocked = true;
if (column.select("a[id^=newicon]").first() != null)
pUnread = true;
}
pStartedBy = topicColumns.get(3).text();
pStats = "Replies " + topicColumns.get(4).text() + ", Views " + topicColumns.get(5).text();
@ -290,7 +292,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
}
pLastPostUrl = topicColumns.last().select("a:has(img)").first().attr("href");
parsedTopics.add(new Topic(pTopicUrl, pSubject, pStartedBy, pLastPost, pLastPostUrl,
pStats, pLocked, pSticky));
pStats, pLocked, pSticky, pUnread));
}
}
}

7
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java

@ -6,6 +6,7 @@ import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -231,12 +232,14 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
});
topicViewHolder.topicSubject.setTypeface(Typeface.createFromAsset(context.getAssets()
, "fonts/fontawesome-webfont.ttf"));
String lockedSticky = topic.getSubject();
String lockedSticky = topic.isUnread() ?
Html.fromHtml("<font size=\"1\">" + context.getString(R.string.fa_circle) + "</font> ").toString() : "";
lockedSticky += topic.getSubject();
if (topic.isLocked())
lockedSticky += " " + context.getResources().getString(R.string.fa_lock);
if (topic.isSticky()) {
//topicViewHolder.topicSubject.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_pin, 0);
lockedSticky += " " + context.getResources().getString(R.string.fa_sticky);
lockedSticky += " " + context.getResources().getString(R.string.fa_thumbtack);
}
topicViewHolder.topicSubject.setText(lockedSticky);
topicViewHolder.topicStartedBy.setText(context.getString(R.string.topic_started_by, topic.getStarter()));

18
app/src/main/java/gr/thmmy/mthmmy/model/Topic.java

@ -5,11 +5,11 @@ package gr.thmmy.mthmmy.model;
* Class has one constructor and getter methods for all variables.
* <p>A topic is described by its url, subject, username of creator, its date and time of this
* topic's last post, url of this topic's last post, its view and reply stats, whether it's locked or
* not and whether it's sticky or not.</b>.
* not, whether it's sticky or not and whether it contains an unread post or not.</b>.
*/
public class Topic extends TopicSummary {
private final String lastPostUrl, stats;
private final boolean locked, sticky;
private final boolean locked, sticky, unread;
// Suppresses default constructor
@SuppressWarnings("unused")
@ -19,6 +19,7 @@ public class Topic extends TopicSummary {
this.stats = null;
this.locked = false;
this.sticky = false;
this.unread = false;
}
/**
@ -33,14 +34,16 @@ public class Topic extends TopicSummary {
* @param stats this topic's view and reply stats
* @param locked whether this topic is locked or not
* @param sticky whether this topic is sticky or not
* @param unread whether this topic contains an unread post or not
*/
public Topic(String topicUrl, String subject, String starter, String lastPost, String lastPostUrl,
String stats, boolean locked, boolean sticky) {
String stats, boolean locked, boolean sticky, boolean unread) {
super(topicUrl, subject, starter, lastPost);
this.lastPostUrl = lastPostUrl;
this.stats = stats;
this.locked = locked;
this.sticky = sticky;
this.unread = unread;
}
/**
@ -114,4 +117,13 @@ public class Topic extends TopicSummary {
public boolean isSticky() {
return sticky;
}
/**
* Gets this topic's unread status. True if it contains an unread post, false otherwise.
*
* @return this topic's unread status
*/
public boolean isUnread() {
return unread;
}
}

2
app/src/main/res/values/strings.xml

@ -89,9 +89,9 @@
<string name="fa_file_excel_o">&#xf1c3;</string>
<string name="fa_file_video_o">&#xf1c8;</string>
<string name="fa_lock">&#xf023;</string>
<string name="fa_sticky">&#xf249;</string>
<string name="fa_folder">&#xf07b;</string>
<string name="fa_circle">&#xf111;</string>
<string name="fa_thumbtack">&#xf08d;</string>
<!--Download Prompt-->
<string name="downloadPromptText">File \"%1$s\" already exists. Download again?"</string>

Loading…
Cancel
Save