|
|
|
@ -33,10 +33,14 @@ import android.widget.TextView; |
|
|
|
|
import com.android.volley.toolbox.NetworkImageView; |
|
|
|
|
|
|
|
|
|
public class PostView extends LinearLayout implements View.OnClickListener, View.OnLongClickListener { |
|
|
|
|
private final static LinearLayout.LayoutParams matchParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
|
|
|
|
private final static LinearLayout.LayoutParams wrapParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); |
|
|
|
|
private final static LinearLayout.LayoutParams matchWrapParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); |
|
|
|
|
private final static LinearLayout.LayoutParams wrapMatchParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); |
|
|
|
|
private final static LinearLayout.LayoutParams matchParams = new LinearLayout.LayoutParams( |
|
|
|
|
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
|
|
|
|
private final static LinearLayout.LayoutParams wrapParams = new LinearLayout.LayoutParams( |
|
|
|
|
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); |
|
|
|
|
private final static LinearLayout.LayoutParams matchWrapParams = new LinearLayout.LayoutParams( |
|
|
|
|
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); |
|
|
|
|
private final static LinearLayout.LayoutParams wrapMatchParams = new LinearLayout.LayoutParams( |
|
|
|
|
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); |
|
|
|
|
|
|
|
|
|
private final Activity context; |
|
|
|
|
|
|
|
|
@ -54,11 +58,12 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
private ImageView stickyView; |
|
|
|
|
private ImageView closedView; |
|
|
|
|
private NetworkImageView countryView; |
|
|
|
|
private View lastSeen; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Represents a post. |
|
|
|
|
* Use setPost(Post ThreadManager) to fill it with data. |
|
|
|
|
* Represents a post. Use setPost(Post ThreadManager) to fill it with data. |
|
|
|
|
* setPost can be called multiple times (useful for ListView). |
|
|
|
|
* |
|
|
|
|
* @param activity |
|
|
|
|
*/ |
|
|
|
|
public PostView(Context activity) { |
|
|
|
@ -212,13 +217,20 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
full.setBackgroundColor(0x00000000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (manager.isPostLastSeen(post)) { |
|
|
|
|
lastSeen.setVisibility(View.VISIBLE); |
|
|
|
|
} else { |
|
|
|
|
lastSeen.setVisibility(View.GONE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (manager.getLoadable().isBoardMode()) { |
|
|
|
|
Utils.setPressedDrawable(right); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildView(final Context context) { |
|
|
|
|
if (isBuild) return; |
|
|
|
|
if (isBuild) |
|
|
|
|
return; |
|
|
|
|
isBuild = true; |
|
|
|
|
|
|
|
|
|
Resources resources = context.getResources(); |
|
|
|
@ -302,6 +314,10 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
|
|
|
|
|
right.addView(repliesCountView, wrapParams); |
|
|
|
|
|
|
|
|
|
lastSeen = new View(context); |
|
|
|
|
lastSeen.setBackgroundColor(0xffff0000); |
|
|
|
|
right.addView(lastSeen, new LayoutParams(LayoutParams.MATCH_PARENT, Utils.dp(context, 6f))); |
|
|
|
|
|
|
|
|
|
full.addView(right, matchWrapParams); |
|
|
|
|
|
|
|
|
|
addView(full, matchParams); |
|
|
|
@ -336,8 +352,7 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { |
|
|
|
|
int action = event.getAction(); |
|
|
|
|
|
|
|
|
|
if (action == MotionEvent.ACTION_UP || |
|
|
|
|
action == MotionEvent.ACTION_DOWN) { |
|
|
|
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { |
|
|
|
|
int x = (int) event.getX(); |
|
|
|
|
int y = (int) event.getY(); |
|
|
|
|
|
|
|
|
@ -357,9 +372,7 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
if (action == MotionEvent.ACTION_UP) { |
|
|
|
|
link[0].onClick(widget); |
|
|
|
|
} else if (action == MotionEvent.ACTION_DOWN) { |
|
|
|
|
Selection.setSelection(buffer, |
|
|
|
|
buffer.getSpanStart(link[0]), |
|
|
|
|
buffer.getSpanEnd(link[0])); |
|
|
|
|
Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
@ -379,8 +392,3 @@ public class PostView extends LinearLayout implements View.OnClickListener, View |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|