From ae4dc86b64bd8ef85bc832106741fb98e8d516da Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 11 六月 2021 17:15:03 +0800
Subject: [PATCH] 特价完善

---
 app/src/main/java/com/tejia/lijin/app/ui/trends/SendCircleAdapter.java |   62 +++++++++++++++++++++---------
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/app/src/main/java/com/tejia/lijin/app/ui/trends/SendCircleAdapter.java b/app/src/main/java/com/tejia/lijin/app/ui/trends/SendCircleAdapter.java
index 77b1014..45fff71 100644
--- a/app/src/main/java/com/tejia/lijin/app/ui/trends/SendCircleAdapter.java
+++ b/app/src/main/java/com/tejia/lijin/app/ui/trends/SendCircleAdapter.java
@@ -1,6 +1,7 @@
 package com.tejia.lijin.app.ui.trends;
 
 import android.app.Activity;
+import android.content.ClipboardManager;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Color;
@@ -72,14 +73,30 @@
     private final int TYPE_BANNER = 1;
     private final int TYPE_CIRCLE_CONTENT = 2;
     private Integer maxImgHeight = null;
+    private TextViewUtil.URLClickListener mUrlClickListener;
 
     private DisplayImageOptions options;
 
+    private Html.ImageGetter imageGetter = new Html.ImageGetter() {
+        @Override
+        public Drawable getDrawable(String source) {
+            try {
+                int resId = mContext.getResources().getIdentifier(source, "drawable", mContext.getPackageName());
+                Drawable drawable = mContext.getResources().getDrawable(resId);
+                drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
+                return drawable;
+            } catch (Exception e) {
+                return null;
+            }
+        }
+    };
 
-    public SendCircleAdapter(Activity activity, List<HomeBanner> mBannerList, List<SendCircleContent> mContentList, AdapterEventActionListener actionListener) {
+
+    public SendCircleAdapter(Activity activity, List<HomeBanner> mBannerList, List<SendCircleContent> mContentList, AdapterEventActionListener actionListener, TextViewUtil.URLClickListener urlClickListener) {
         this.mContext = activity;
         this.mBannerList = mBannerList;
         this.mContentList = mContentList;
+        this.mUrlClickListener = urlClickListener;
         inflater = LayoutInflater.from(mContext);
         this.adapterEventActionListener = actionListener;
         this.options = new DisplayImageOptions.Builder()
@@ -241,8 +258,9 @@
             });
 
             circleContentHolder.tv_recommend.setMaxLines(6);
-            //鎺ㄨ崘璇祴鍊�
-            circleContentHolder.tv_recommend.setText(circleContent.getTitle());
+            circleContentHolder.tv_recommend.setMovementMethod(LinkMovementMethod.getInstance());
+            circleContentHolder.tv_recommend.setText(TextViewUtil.getClickableHtml(Html.fromHtml(circleContent.getTitle(), imageGetter, null), mContext, Color.parseColor("#586b95"), mUrlClickListener));
+
 
             circleContentHolder.tv_recommend.post(new Runnable() {
                 @Override
@@ -251,13 +269,24 @@
                     if (l != null) {
                         int lines = l.getLineCount();
                         if (lines > 0) {
-                            if (l.getEllipsisCount(lines - 1) > 0) {
+                            if (lines > circleContentHolder.tv_recommend.getMaxLines()) {
                                 circleContentHolder.iv_recommend_more.setVisibility(View.VISIBLE);
                             } else {
                                 circleContentHolder.iv_recommend_more.setVisibility(View.GONE);
                             }
                         }
                     }
+                }
+            });
+
+            circleContentHolder.tv_recommend.setOnLongClickListener(new View.OnLongClickListener() {
+                @Override
+                public boolean onLongClick(View v) {
+
+                    if (adapterEventActionListener != null)
+                        adapterEventActionListener.copyRecommendText(circleContent);
+
+                    return false;
                 }
             });
 
@@ -738,25 +767,12 @@
                 } else {
                     holder.ll_content.setVisibility(View.VISIBLE);
                     String content = comment.getContent();
-                    content += "<img src='icon_common_emoji_link' /> <a href='test:http://www.baidu.com'>杩欐槸涓彲浠ョ偣鍑荤殑閾炬帴</a> 娴嬭瘯12312312123";
-                    holder.tv_content.setText(TextViewUtil.getClickableHtml(Html.fromHtml(content, new Html.ImageGetter() {
-                        @Override
-                        public Drawable getDrawable(String source) {
-                            try {
-                                int resId = context.getResources().getIdentifier(source, "drawable", context.getPackageName());
-                                Drawable drawable = context.getResources().getDrawable(resId);
-                                drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
-                                return drawable;
-                            } catch (Exception e) {
-                                return null;
-                            }
-                        }
-                    }, null), context, Color.parseColor("#586b95")));
 
                     holder.tv_content.setMovementMethod(LinkMovementMethod.getInstance());
                     holder.tv_content.setFocusable(false);
                     holder.tv_content.setClickable(false);
                     holder.tv_content.setLongClickable(false);
+                    holder.tv_content.setText(TextViewUtil.getClickableHtml(Html.fromHtml(content, imageGetter, null), context, Color.parseColor("#586b95"), mUrlClickListener));
                 }
 
                 holder.tv_content.setMaxLines(6);
@@ -775,7 +791,7 @@
                         if (l != null) {
                             int lines = l.getLineCount();
                             if (lines > 0) {
-                                if (l.getEllipsisCount(lines - 1) > 0) {
+                                if (lines > holder.tv_content.getMaxLines()) {
                                     holder.iv_comment_more.setVisibility(View.VISIBLE);
 
                                 } else {
@@ -786,6 +802,14 @@
                     }
                 });
 
+                holder.tv_content.setOnLongClickListener(new View.OnLongClickListener() {
+                    @Override
+                    public boolean onLongClick(View v) {
+                        commentClickListener.onCopyClick(cposition);
+                        return false;
+                    }
+                });
+
                 holder.iv_comment_more.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {

--
Gitblit v1.8.0