diff --git a/Chan/res/drawable-hdpi/ic_action_back.png b/Chan/res/drawable-hdpi/ic_action_back.png
new file mode 100644
index 00000000..bff21fbd
Binary files /dev/null and b/Chan/res/drawable-hdpi/ic_action_back.png differ
diff --git a/Chan/res/drawable-hdpi/ic_action_cancel.png b/Chan/res/drawable-hdpi/ic_action_cancel.png
new file mode 100644
index 00000000..cde36e1f
Binary files /dev/null and b/Chan/res/drawable-hdpi/ic_action_cancel.png differ
diff --git a/Chan/res/drawable-hdpi/ic_action_done.png b/Chan/res/drawable-hdpi/ic_action_done.png
new file mode 100644
index 00000000..58bf9721
Binary files /dev/null and b/Chan/res/drawable-hdpi/ic_action_done.png differ
diff --git a/Chan/res/drawable-hdpi/ic_navigation_previous_item.png b/Chan/res/drawable-hdpi/ic_navigation_previous_item.png
new file mode 100644
index 00000000..23778ae9
Binary files /dev/null and b/Chan/res/drawable-hdpi/ic_navigation_previous_item.png differ
diff --git a/Chan/res/drawable-mdpi/ic_action_back.png b/Chan/res/drawable-mdpi/ic_action_back.png
new file mode 100644
index 00000000..64634618
Binary files /dev/null and b/Chan/res/drawable-mdpi/ic_action_back.png differ
diff --git a/Chan/res/drawable-mdpi/ic_action_cancel.png b/Chan/res/drawable-mdpi/ic_action_cancel.png
new file mode 100644
index 00000000..9f4c3d6a
Binary files /dev/null and b/Chan/res/drawable-mdpi/ic_action_cancel.png differ
diff --git a/Chan/res/drawable-mdpi/ic_action_done.png b/Chan/res/drawable-mdpi/ic_action_done.png
new file mode 100644
index 00000000..cf5fab3a
Binary files /dev/null and b/Chan/res/drawable-mdpi/ic_action_done.png differ
diff --git a/Chan/res/drawable-mdpi/ic_navigation_previous_item.png b/Chan/res/drawable-mdpi/ic_navigation_previous_item.png
new file mode 100644
index 00000000..8d19e391
Binary files /dev/null and b/Chan/res/drawable-mdpi/ic_navigation_previous_item.png differ
diff --git a/Chan/res/drawable-xhdpi/ic_action_back.png b/Chan/res/drawable-xhdpi/ic_action_back.png
new file mode 100644
index 00000000..28432f10
Binary files /dev/null and b/Chan/res/drawable-xhdpi/ic_action_back.png differ
diff --git a/Chan/res/drawable-xhdpi/ic_action_cancel.png b/Chan/res/drawable-xhdpi/ic_action_cancel.png
new file mode 100644
index 00000000..ca7d159f
Binary files /dev/null and b/Chan/res/drawable-xhdpi/ic_action_cancel.png differ
diff --git a/Chan/res/drawable-xhdpi/ic_action_done.png b/Chan/res/drawable-xhdpi/ic_action_done.png
new file mode 100644
index 00000000..b8915716
Binary files /dev/null and b/Chan/res/drawable-xhdpi/ic_action_done.png differ
diff --git a/Chan/res/drawable-xhdpi/ic_navigation_previous_item.png b/Chan/res/drawable-xhdpi/ic_navigation_previous_item.png
new file mode 100644
index 00000000..cf0b485f
Binary files /dev/null and b/Chan/res/drawable-xhdpi/ic_navigation_previous_item.png differ
diff --git a/Chan/res/drawable-xxhdpi/ic_action_back.png b/Chan/res/drawable-xxhdpi/ic_action_back.png
new file mode 100644
index 00000000..11eb5e19
Binary files /dev/null and b/Chan/res/drawable-xxhdpi/ic_action_back.png differ
diff --git a/Chan/res/drawable-xxhdpi/ic_action_cancel.png b/Chan/res/drawable-xxhdpi/ic_action_cancel.png
new file mode 100644
index 00000000..331c545b
Binary files /dev/null and b/Chan/res/drawable-xxhdpi/ic_action_cancel.png differ
diff --git a/Chan/res/drawable-xxhdpi/ic_action_done.png b/Chan/res/drawable-xxhdpi/ic_action_done.png
new file mode 100644
index 00000000..6fda89ec
Binary files /dev/null and b/Chan/res/drawable-xxhdpi/ic_action_done.png differ
diff --git a/Chan/res/drawable-xxhdpi/ic_navigation_previous_item.png b/Chan/res/drawable-xxhdpi/ic_navigation_previous_item.png
new file mode 100644
index 00000000..bc8ff124
Binary files /dev/null and b/Chan/res/drawable-xxhdpi/ic_navigation_previous_item.png differ
diff --git a/Chan/res/layout/post_replies.xml b/Chan/res/layout/post_replies.xml
new file mode 100644
index 00000000..381f8415
--- /dev/null
+++ b/Chan/res/layout/post_replies.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Chan/res/values/dimens.xml b/Chan/res/values/dimens.xml
index ba0ea4ac..5fe9aa2f 100644
--- a/Chan/res/values/dimens.xml
+++ b/Chan/res/values/dimens.xml
@@ -9,9 +9,6 @@
14dp
200dp
- 200dp
- 100dp
-
11dp
8dp
diff --git a/Chan/res/values/strings.xml b/Chan/res/values/strings.xml
index 0ed167b2..d7dfc14c 100644
--- a/Chan/res/values/strings.xml
+++ b/Chan/res/values/strings.xml
@@ -80,11 +80,14 @@
Unsupported link
Chan can\'t open this link. Opening it in your browser instead.
+ Back
+ Close
+
Info
- - Show clickables
- - Info
- Quote
+ - Info
+ - Show clickables
- Copy text
diff --git a/Chan/src/org/floens/chan/adapter/PostAdapter.java b/Chan/src/org/floens/chan/adapter/PostAdapter.java
index 4da61ff1..90615a95 100644
--- a/Chan/src/org/floens/chan/adapter/PostAdapter.java
+++ b/Chan/src/org/floens/chan/adapter/PostAdapter.java
@@ -1,6 +1,7 @@
package org.floens.chan.adapter;
import java.util.ArrayList;
+import java.util.List;
import org.floens.chan.R;
import org.floens.chan.entity.Post;
@@ -21,7 +22,7 @@ public class PostAdapter extends BaseAdapter {
private final ThreadManager threadManager;
private boolean endOfLine;
private int count = 0;
- private final ArrayList postList = new ArrayList();
+ private final List postList = new ArrayList();
public PostAdapter(Context activity, ThreadManager threadManager) {
this.activity = activity;
@@ -84,14 +85,14 @@ public class PostAdapter extends BaseAdapter {
}
}
- public void addToList(ArrayList list){
+ public void addToList(List list){
count += list.size();
postList.addAll(list);
notifyDataSetChanged();
}
- public ArrayList getList() {
+ public List getList() {
return postList;
}
diff --git a/Chan/src/org/floens/chan/entity/Pin.java b/Chan/src/org/floens/chan/entity/Pin.java
index 9d8e836e..f1f249ae 100644
--- a/Chan/src/org/floens/chan/entity/Pin.java
+++ b/Chan/src/org/floens/chan/entity/Pin.java
@@ -1,6 +1,7 @@
package org.floens.chan.entity;
import java.util.ArrayList;
+import java.util.List;
import org.floens.chan.net.ThreadLoader;
import org.floens.chan.net.ThreadLoader.ThreadLoaderListener;
@@ -11,12 +12,11 @@ public class Pin {
public Type type = Type.THREAD;
public Loadable loadable = new Loadable("", -1);
-
private int count;
private int newCount;
private final boolean watch = true;
private boolean error = false;
- private ArrayList postList = new ArrayList();
+ private List postList = new ArrayList();
public ThreadLoader threadLoader = new ThreadLoader(new ThreadLoaderListener() {
@Override
public void onError(VolleyError volleyError) {
@@ -24,7 +24,7 @@ public class Pin {
}
@Override
- public void onData(ArrayList result) {
+ public void onData(List result) {
postList = result;
int totalCount = result.size();
diff --git a/Chan/src/org/floens/chan/entity/Post.java b/Chan/src/org/floens/chan/entity/Post.java
index 9b6e8a79..8bdad320 100644
--- a/Chan/src/org/floens/chan/entity/Post.java
+++ b/Chan/src/org/floens/chan/entity/Post.java
@@ -50,8 +50,21 @@ public class Post {
public long time = 0;
public String email = "";
+ /**
+ * This post replies to the these ids
+ */
+ public List repliesTo = new ArrayList();
+
+ /**
+ * These ids replied to this post
+ */
+ public List repliesFrom = new ArrayList();
+
private PostView linkableListener;
public final ArrayList linkables = new ArrayList();
+ /**
+ * The PostView the Post is currently bound to.
+ */
public Post() {
}
@@ -166,10 +179,22 @@ public class Post {
SpannableString link = new SpannableString(anchor.text());
- PostLinkable pl = new PostLinkable(this, anchor.text(), anchor.attr("href"), anchor.text().contains("://") ? Type.LINK : Type.QUOTE);
+ Type t = anchor.text().contains("://") ? Type.LINK : Type.QUOTE;
+ PostLinkable pl = new PostLinkable(this, anchor.text(), anchor.attr("href"), t);
link.setSpan(pl, 0, link.length(), 0);
linkables.add(pl);
+ if (t == Type.QUOTE) {
+ try {
+ // Get post id
+ String[] splitted = anchor.attr("href").split("#p");
+ if (splitted.length == 2) {
+ int id = Integer.parseInt(splitted[1]);
+ repliesTo.add(id);
+ }
+ } catch(NumberFormatException e) {}
+ }
+
total = TextUtils.concat(total, link);
} else {
// Unknown tag, add the inner part
diff --git a/Chan/src/org/floens/chan/fragment/PostPopupFragment.java b/Chan/src/org/floens/chan/fragment/PostPopupFragment.java
deleted file mode 100644
index c9bbca46..00000000
--- a/Chan/src/org/floens/chan/fragment/PostPopupFragment.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.floens.chan.fragment;
-
-import org.floens.chan.R;
-import org.floens.chan.entity.Post;
-import org.floens.chan.manager.ThreadManager;
-import org.floens.chan.view.PostView;
-
-import android.app.DialogFragment;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ScrollView;
-
-public class PostPopupFragment extends DialogFragment {
- private Context context;
- private ScrollView wrapper;
-
- private Post post;
- private ThreadManager manager;
-
- public static PostPopupFragment newInstance(Post post, ThreadManager manager) {
- PostPopupFragment fragment = new PostPopupFragment();
- fragment.post = post;
- fragment.manager = manager;
-
- return fragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setStyle(STYLE_NO_TITLE, 0);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- context = inflater.getContext();
-
- Resources resources = context.getResources();
- int minWidth = resources.getDimensionPixelSize(R.dimen.post_popup_min_width);
- int minHeight = resources.getDimensionPixelSize(R.dimen.post_popup_min_height);
-
- wrapper = new ScrollView(context);
- wrapper.setMinimumWidth(minWidth);
- wrapper.setMinimumHeight(minHeight);
-
- return wrapper;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- if (post == null) {
- throw new IllegalArgumentException("No post specified");
- }
-
- PostView postView = new PostView(getActivity());
- postView.setPost(post, manager);
-
- wrapper.addView(postView);
- }
-}
-
-
-
-
-
diff --git a/Chan/src/org/floens/chan/fragment/PostRepliesFragment.java b/Chan/src/org/floens/chan/fragment/PostRepliesFragment.java
new file mode 100644
index 00000000..25939c15
--- /dev/null
+++ b/Chan/src/org/floens/chan/fragment/PostRepliesFragment.java
@@ -0,0 +1,122 @@
+package org.floens.chan.fragment;
+
+import java.util.List;
+
+import org.floens.chan.R;
+import org.floens.chan.entity.Post;
+import org.floens.chan.manager.ThreadManager;
+import org.floens.chan.view.PostView;
+
+import android.app.DialogFragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+/**
+ * A DialogFragment that shows a list of posts. Use the newInstance method for instantiating.
+ */
+public class PostRepliesFragment extends DialogFragment {
+ private Context context;
+ private ListView listView;
+
+ private List posts;
+ private ThreadManager manager;
+ private boolean callback = true;
+
+ public static PostRepliesFragment newInstance(List posts, ThreadManager manager) {
+ PostRepliesFragment fragment = new PostRepliesFragment();
+ fragment.posts = posts;
+ fragment.manager = manager;
+
+ return fragment;
+ }
+
+ public void dismissNoCallback() {
+ callback = false;
+ dismiss();
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setStyle(STYLE_NO_TITLE, 0);
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
+
+ if (callback) {
+ manager.onPostRepliesPop();
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup unused, Bundle savedInstanceState) {
+ context = inflater.getContext();
+
+ View container = inflater.inflate(R.layout.post_replies, null);
+
+ Resources resources = context.getResources();
+
+ listView = (ListView) container.findViewById(R.id.post_list);
+
+ container.findViewById(R.id.replies_back).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismiss();
+ }
+ });
+
+ container.findViewById(R.id.replies_close).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ manager.closeAllPostFragments();
+ dismiss();
+ }
+ });
+
+ return container;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ if (posts == null) {
+ // Restoring from background.
+ dismiss();
+ } else {
+ ArrayAdapter adapter = new ArrayAdapter(getActivity(), 0) {
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ PostView postView = null;
+ if (convertView instanceof PostView) {
+ postView = (PostView) convertView;
+ } else {
+ postView = new PostView(getActivity());
+ }
+
+ postView.setPost(getItem(position), manager);
+
+ return postView;
+ }
+ };
+
+ adapter.addAll(posts);
+ listView.setAdapter(adapter);
+ }
+ }
+}
+
+
+
+
+
diff --git a/Chan/src/org/floens/chan/fragment/ThreadFragment.java b/Chan/src/org/floens/chan/fragment/ThreadFragment.java
index a8ec0fb8..a75def12 100644
--- a/Chan/src/org/floens/chan/fragment/ThreadFragment.java
+++ b/Chan/src/org/floens/chan/fragment/ThreadFragment.java
@@ -1,6 +1,7 @@
package org.floens.chan.fragment;
import java.util.ArrayList;
+import java.util.List;
import org.floens.chan.R;
import org.floens.chan.activity.BaseActivity;
@@ -91,7 +92,7 @@ public class ThreadFragment extends Fragment implements ThreadListener {
}
@Override
- public void onThreadLoaded(ArrayList posts) {
+ public void onThreadLoaded(List posts) {
if (!shown) {
shown = true;
diff --git a/Chan/src/org/floens/chan/manager/ThreadManager.java b/Chan/src/org/floens/chan/manager/ThreadManager.java
index 90edd4d5..b60097b5 100644
--- a/Chan/src/org/floens/chan/manager/ThreadManager.java
+++ b/Chan/src/org/floens/chan/manager/ThreadManager.java
@@ -1,13 +1,14 @@
package org.floens.chan.manager;
import java.util.ArrayList;
+import java.util.List;
import org.floens.chan.ChanApplication;
import org.floens.chan.R;
import org.floens.chan.entity.Loadable;
import org.floens.chan.entity.Post;
import org.floens.chan.entity.PostLinkable;
-import org.floens.chan.fragment.PostPopupFragment;
+import org.floens.chan.fragment.PostRepliesFragment;
import org.floens.chan.net.ThreadLoader;
import android.app.Activity;
@@ -21,7 +22,6 @@ import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
-import android.util.SparseArray;
import android.view.Gravity;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
@@ -41,7 +41,9 @@ public class ThreadManager {
private final ThreadManager.ThreadListener threadListener;
private Loadable loadable;
private boolean endOfLine = false;
- private final SparseArray postsById = new SparseArray();
+
+ private final List> popupQueue = new ArrayList>();
+ private PostRepliesFragment currentPopupFragment;
public ThreadManager(Activity context, final ThreadListener listener) {
this.activity = context;
@@ -54,11 +56,7 @@ public class ThreadManager {
}
@Override
- public void onData(ArrayList result) {
- for (Post post : result) {
- postsById.append(post.no, post);
- }
-
+ public void onData(List result) {
listener.onThreadLoaded(result);
}
});
@@ -68,8 +66,8 @@ public class ThreadManager {
return loadable != null;
}
- public Post getPostById(int id) {
- return postsById.get(id);
+ public Post findPostById(int id) {
+ return threadLoader.getPostById(id);
}
public Loadable getLoadable() {
@@ -85,7 +83,6 @@ public class ThreadManager {
public void stop() {
threadLoader.stop();
endOfLine = false;
- postsById.clear();
}
public void reload() {
@@ -131,14 +128,14 @@ public class ThreadManager {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
- case 0: // Show clickables
- showPostLinkables(post);
- break;
- case 1: // Info
- showPostInfo(post);
- case 2: // Quote
+ case 0: // Quote
ReplyManager.getInstance().quote(post.no);
break;
+ case 1: // Info
+ showPostInfo(post);
+ case 2: // Show clickables
+ showPostLinkables(post);
+ break;
case 3: // Copy text
copyText(post.comment.toString());
break;
@@ -252,13 +249,27 @@ public class ThreadManager {
}
}
+ public void showPostReplies(Post post) {
+ List p = new ArrayList();
+ for (int no : post.repliesFrom) {
+ Post r = findPostById(no);
+ if (r != null) {
+ p.add(r);
+ }
+ }
+
+ if (p.size() > 0) {
+ showPostsReplies(p);
+ }
+ }
+
/**
* Handle when a linkable has been clicked.
* @param linkable the selected linkable.
*/
private void handleLinkableSelected(final PostLinkable linkable) {
if (linkable.type == PostLinkable.Type.QUOTE) {
- showPostPopup(linkable);
+ showPostReply(linkable);
} else if (linkable.type == PostLinkable.Type.LINK) {
if (ChanApplication.getPreferences().getBoolean("preference_open_link_confirmation", true)) {
AlertDialog dialog = new AlertDialog.Builder(activity)
@@ -289,7 +300,7 @@ public class ThreadManager {
* show a dialog with the referenced post in it.
* @param linkable the clicked linkable.
*/
- private void showPostPopup(PostLinkable linkable) {
+ private void showPostReply(PostLinkable linkable) {
String value = linkable.value;
Post post = null;
@@ -300,14 +311,12 @@ public class ThreadManager {
if (splitted.length == 2) {
int id = Integer.parseInt(splitted[1]);
- post = getPostById(id);
+ post = findPostById(id);
if (post != null) {
- PostPopupFragment popup = PostPopupFragment.newInstance(post, this);
-
- FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
- ft.add(popup, "postPopup");
- ft.commitAllowingStateLoss();
+ List l = new ArrayList();
+ l.add(post);
+ showPostsReplies(l);
}
}
} catch(NumberFormatException e) {
@@ -323,8 +332,48 @@ public class ThreadManager {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(linkable.value)));
}
- public interface ThreadListener {
- public void onThreadLoaded(ArrayList result);
+ private void showPostsReplies(List list) {
+ // Post popups are now queued up, more than 32 popups on top of each other makes the system crash!
+ popupQueue.add(list);
+
+ if (currentPopupFragment != null) {
+ currentPopupFragment.dismissNoCallback();
+ }
+
+ PostRepliesFragment popup = PostRepliesFragment.newInstance(list, this);
+
+ FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
+ ft.add(popup, "postPopup");
+ ft.commit();
+
+ currentPopupFragment = popup;
+ }
+
+ public void onPostRepliesPop() {
+ if (popupQueue.size() == 0) return;
+
+ popupQueue.remove(popupQueue.size() - 1);
+
+ if (popupQueue.size() > 0) {
+ PostRepliesFragment popup = PostRepliesFragment.newInstance(popupQueue.get(popupQueue.size() - 1), this);
+
+ FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
+ ft.add(popup, "postPopup");
+ ft.commit();
+
+ currentPopupFragment = popup;
+ } else {
+ currentPopupFragment = null;
+ }
+ }
+
+ public void closeAllPostFragments() {
+ popupQueue.clear();
+ currentPopupFragment = null;
+ }
+
+ public interface ThreadListener {
+ public void onThreadLoaded(List result);
public void onThreadLoadError(VolleyError error);
public void onPostClicked(Post post);
public void onThumbnailClicked(Post post);
diff --git a/Chan/src/org/floens/chan/net/ThreadLoader.java b/Chan/src/org/floens/chan/net/ThreadLoader.java
index a93e71f2..cf8dea4b 100644
--- a/Chan/src/org/floens/chan/net/ThreadLoader.java
+++ b/Chan/src/org/floens/chan/net/ThreadLoader.java
@@ -1,12 +1,14 @@
package org.floens.chan.net;
import java.util.ArrayList;
+import java.util.List;
import org.floens.chan.ChanApplication;
import org.floens.chan.entity.Loadable;
import org.floens.chan.entity.Post;
import android.util.Log;
+import android.util.SparseArray;
import com.android.volley.Response;
import com.android.volley.ServerError;
@@ -18,6 +20,7 @@ public class ThreadLoader {
private boolean stopped = false;
private boolean loading = false;
private Loadable loadable;
+ private final SparseArray postsById = new SparseArray();
public ThreadLoader(ThreadLoaderListener listener) {
this.listener = listener;
@@ -52,9 +55,15 @@ public class ThreadLoader {
loader = null;
}
+ postsById.clear();
+
stopped = true;
}
+ public Post getPostById(int id) {
+ return postsById.get(id);
+ }
+
private ChanReaderRequest getData(Loadable loadable) {
ChanReaderRequest request = ChanReaderRequest.newInstance(loadable, new Response.Listener>() {
@Override
@@ -76,9 +85,11 @@ public class ThreadLoader {
return request;
}
- private void onData(ArrayList result) {
+ private void onData(List result) {
if (stopped) return;
+ processPosts(result);
+
listener.onData(result);
}
@@ -95,8 +106,20 @@ public class ThreadLoader {
listener.onError(error);
}
+ private void processPosts(List posts) {
+ for (Post post : posts) {
+ postsById.append(post.no, post);
+
+ for (Post other : posts) {
+ if (other.repliesTo.contains(post.no)) {
+ post.repliesFrom.add(other.no);
+ }
+ }
+ }
+ }
+
public static abstract class ThreadLoaderListener {
- public abstract void onData(ArrayList result);
+ public abstract void onData(List result);
public abstract void onError(VolleyError error);
}
}
diff --git a/Chan/src/org/floens/chan/view/PostView.java b/Chan/src/org/floens/chan/view/PostView.java
index 68af263b..a7d0509c 100644
--- a/Chan/src/org/floens/chan/view/PostView.java
+++ b/Chan/src/org/floens/chan/view/PostView.java
@@ -42,7 +42,7 @@ public class PostView extends LinearLayout implements View.OnClickListener, View
private NetworkImageView imageView;
private TextView titleView;
private TextView commentView;
- private TextView repliesView;
+ private TextView repliesCountView;
private LinearLayout iconView;
private ImageView stickyView;
private NetworkImageView countryView;
@@ -81,7 +81,7 @@ public class PostView extends LinearLayout implements View.OnClickListener, View
}
@SuppressWarnings("deprecation")
- public void setPost(Post post, ThreadManager manager) {
+ public void setPost(final Post post, final ThreadManager manager) {
this.post = post;
this.manager = manager;
@@ -162,20 +162,32 @@ public class PostView extends LinearLayout implements View.OnClickListener, View
post.setLinkableListener(null);
}
- if (post.isOP && post.replies > 0 && manager.getLoadable().isBoardMode()) {
- repliesView.setVisibility(View.VISIBLE);
+ if ((post.isOP && manager.getLoadable().isBoardMode() && post.replies > 0) || (post.repliesFrom.size() > 0)) {
+ repliesCountView.setVisibility(View.VISIBLE);
String text = "";
- if (post.replies > 1) {
- text = context.getString(R.string.multiple_replies);
- } else if (post.replies == 1) {
- text = context.getString(R.string.one_reply);
+ int count = manager.getLoadable().isBoardMode() ? post.replies : post.repliesFrom.size();
+
+ if (count > 1) {
+ text = count + " " + context.getString(R.string.multiple_replies);
+ } else if (count == 1) {
+ text = count + " " + context.getString(R.string.one_reply);
+ }
+
+ if (manager.getLoadable().isThreadMode()) {
+ repliesCountView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ manager.showPostReplies(post);
+ }
+ });
}
- repliesView.setText(post.replies + " " + text);
+ repliesCountView.setText(text);
} else {
- repliesView.setVisibility(View.GONE);
+ repliesCountView.setVisibility(View.GONE);
+ repliesCountView.setOnClickListener(null);
}
boolean showCountryFlag = !TextUtils.isEmpty(post.country);
@@ -275,13 +287,13 @@ public class PostView extends LinearLayout implements View.OnClickListener, View
commentView.setTextSize(15);
right.addView(commentView, matchWrapParams);
- repliesView = new TextView(context);
- repliesView.setTextColor(Color.argb(255, 100, 100, 100));
- repliesView.setPadding(0, textPadding, 0, 0);
- repliesView.setTextSize(12);
+ repliesCountView = new TextView(context);
+ repliesCountView.setTextColor(Color.argb(255, 100, 100, 100));
+ repliesCountView.setPadding(0, textPadding, 0, 0);
+ repliesCountView.setTextSize(14);
+
+ right.addView(repliesCountView, matchWrapParams);
- right.addView(repliesView, matchWrapParams);
-
full.addView(right, matchWrapParams);
addView(full, wrapParams);