Make blog post text clickable

by making it only selectable in detail view
This commit is contained in:
Torsten Grote
2016-09-05 14:33:44 -03:00
parent e0e46a726e
commit 60b4c5649a
3 changed files with 13 additions and 10 deletions

View File

@@ -29,7 +29,6 @@
android:paddingLeft="@dimen/listitem_vertical_margin"
android:paddingRight="@dimen/listitem_vertical_margin"
android:textColor="@color/briar_text_secondary"
android:textIsSelectable="true"
android:textSize="@dimen/text_size_small"
tools:text="This is a comment that appears below a blog post. Usually, it is expected to be rather short. Not much longer than this one."/>

View File

@@ -6,7 +6,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
@@ -55,7 +56,6 @@
android:layout_height="wrap_content"
android:layout_below="@+id/authorView"
android:textColor="@color/briar_text_secondary"
android:textIsSelectable="true"
android:textSize="@dimen/text_size_medium"
tools:text="This is a body text that shows the content of a blog post.\n\nThis one is not short, but it is also not too long."/>

View File

@@ -10,6 +10,7 @@ import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -81,14 +82,15 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
void bindItem(final BlogPostItem item) {
setTransitionName(item.getId());
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
if (listener != null) {
layout.setClickable(true);
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
listener.onBlogPostClick(item);
}
}
});
});
}
// author and date
BlogPostHeader post = item.getPostHeader();
@@ -105,9 +107,10 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
// post body
body.setText(item.getBody());
if (listener == null) body.setTextIsSelectable(true);
// reblog button
reblogButton.setOnClickListener(new View.OnClickListener() {
reblogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(ctx, ReblogActivity.class);
@@ -154,6 +157,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
// TODO make author clickable #624
body.setText(c.getComment());
if (listener == null) body.setTextIsSelectable(true);
commentContainer.addView(v);
}