|
|
@ -83,7 +83,7 @@ import static org.floens.chan.utils.AndroidUtils.getString; |
|
|
|
import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground; |
|
|
|
import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground; |
|
|
|
import static org.floens.chan.utils.AndroidUtils.sp; |
|
|
|
import static org.floens.chan.utils.AndroidUtils.sp; |
|
|
|
|
|
|
|
|
|
|
|
public class PostCell extends LinearLayout implements PostCellInterface, PostLinkable.Callback { |
|
|
|
public class PostCell extends LinearLayout implements PostCellInterface { |
|
|
|
private static final String TAG = "PostCell"; |
|
|
|
private static final String TAG = "PostCell"; |
|
|
|
private static final int COMMENT_MAX_LENGTH_BOARD = 350; |
|
|
|
private static final int COMMENT_MAX_LENGTH_BOARD = 350; |
|
|
|
|
|
|
|
|
|
|
@ -297,7 +297,7 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin |
|
|
|
|
|
|
|
|
|
|
|
threadMode = callback.getLoadable().isThreadMode(); |
|
|
|
threadMode = callback.getLoadable().isThreadMode(); |
|
|
|
|
|
|
|
|
|
|
|
setPostLinkableListener(post, this); |
|
|
|
setPostLinkableListener(post, true); |
|
|
|
|
|
|
|
|
|
|
|
replies.setClickable(threadMode); |
|
|
|
replies.setClickable(threadMode); |
|
|
|
|
|
|
|
|
|
|
@ -468,26 +468,18 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin |
|
|
|
|
|
|
|
|
|
|
|
icons.cancelCountryRequest(); |
|
|
|
icons.cancelCountryRequest(); |
|
|
|
|
|
|
|
|
|
|
|
setPostLinkableListener(post, null); |
|
|
|
setPostLinkableListener(post, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setPostLinkableListener(Post post, PostLinkable.Callback callback) { |
|
|
|
private void setPostLinkableListener(Post post, boolean bind) { |
|
|
|
if (post.comment instanceof Spanned) { |
|
|
|
if (post.comment instanceof Spanned) { |
|
|
|
Spanned commentSpanned = (Spanned) post.comment; |
|
|
|
Spanned commentSpanned = (Spanned) post.comment; |
|
|
|
PostLinkable[] linkables = commentSpanned.getSpans(0, commentSpanned.length(), PostLinkable.class); |
|
|
|
PostLinkable[] linkables = commentSpanned.getSpans(0, commentSpanned.length(), PostLinkable.class); |
|
|
|
for (PostLinkable linkable : linkables) { |
|
|
|
for (PostLinkable linkable : linkables) { |
|
|
|
if (callback == null) { |
|
|
|
linkable.setMarkedNo(bind ? markedNo : -1); |
|
|
|
while (linkable.hasCallback(this)) { |
|
|
|
|
|
|
|
linkable.removeCallback(this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!linkable.hasCallback(this)) { |
|
|
|
|
|
|
|
linkable.addCallback(callback); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (callback == null) { |
|
|
|
if (!bind) { |
|
|
|
if (commentSpanned instanceof Spannable) { |
|
|
|
if (commentSpanned instanceof Spannable) { |
|
|
|
Spannable commentSpannable = (Spannable) commentSpanned; |
|
|
|
Spannable commentSpannable = (Spannable) commentSpanned; |
|
|
|
commentSpannable.removeSpan(BACKGROUND_SPAN); |
|
|
|
commentSpannable.removeSpan(BACKGROUND_SPAN); |
|
|
@ -496,16 +488,6 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onLinkableClick(PostLinkable postLinkable) { |
|
|
|
|
|
|
|
callback.onPostLinkableClicked(postLinkable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public int getMarkedNo(PostLinkable postLinkable) { |
|
|
|
|
|
|
|
return markedNo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static BackgroundColorSpan BACKGROUND_SPAN = new BackgroundColorSpan(0x6633B5E5); |
|
|
|
private static BackgroundColorSpan BACKGROUND_SPAN = new BackgroundColorSpan(0x6633B5E5); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -534,12 +516,16 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin |
|
|
|
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); |
|
|
|
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); |
|
|
|
|
|
|
|
|
|
|
|
if (link.length != 0) { |
|
|
|
if (link.length != 0) { |
|
|
|
|
|
|
|
ClickableSpan clickableSpan = link[0]; |
|
|
|
if (action == MotionEvent.ACTION_UP) { |
|
|
|
if (action == MotionEvent.ACTION_UP) { |
|
|
|
ignoreNextOnClick = true; |
|
|
|
ignoreNextOnClick = true; |
|
|
|
link[0].onClick(widget); |
|
|
|
clickableSpan.onClick(widget); |
|
|
|
|
|
|
|
if (clickableSpan instanceof PostLinkable) { |
|
|
|
|
|
|
|
callback.onPostLinkableClicked((PostLinkable) clickableSpan); |
|
|
|
|
|
|
|
} |
|
|
|
buffer.removeSpan(BACKGROUND_SPAN); |
|
|
|
buffer.removeSpan(BACKGROUND_SPAN); |
|
|
|
} else if (action == MotionEvent.ACTION_DOWN && link[0] instanceof PostLinkable) { |
|
|
|
} else if (action == MotionEvent.ACTION_DOWN && clickableSpan instanceof PostLinkable) { |
|
|
|
buffer.setSpan(BACKGROUND_SPAN, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0]), 0); |
|
|
|
buffer.setSpan(BACKGROUND_SPAN, buffer.getSpanStart(clickableSpan), buffer.getSpanEnd(clickableSpan), 0); |
|
|
|
} else if (action == MotionEvent.ACTION_CANCEL) { |
|
|
|
} else if (action == MotionEvent.ACTION_CANCEL) { |
|
|
|
buffer.removeSpan(BACKGROUND_SPAN); |
|
|
|
buffer.removeSpan(BACKGROUND_SPAN); |
|
|
|
} |
|
|
|
} |
|
|
|