| | |
| | | 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.Paint; |
| | | import android.graphics.Color; |
| | | import android.graphics.Rect; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import android.graphics.drawable.Drawable; |
| | | import android.text.Html; |
| | | import android.text.Layout; |
| | | import android.text.Spannable; |
| | | import android.text.SpannableString; |
| | | import android.text.Spanned; |
| | | import android.text.style.RelativeSizeSpan; |
| | | import android.text.method.LinkMovementMethod; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailListUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsRightViewHolder; |
| | | import com.viewpagerindicator.CirclePageIndicator; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.widget.RatioLayout; |
| | | import com.tejia.lijin.app.R; |
| | | import com.tejia.lijin.app.entity.HomeBanner; |
| | | import com.tejia.lijin.app.entity.Label; |
| | |
| | | import com.tejia.lijin.app.entity.trends.SendCircleImageGoods; |
| | | import com.tejia.lijin.app.entity.trends.SendCircleUser; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.ui.recommend.RecommendTopAdapter2; |
| | | import com.tejia.lijin.app.util.SetLabels; |
| | | import com.tejia.lijin.app.util.downutil.StringUtils; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailJumpUtil; |
| | | import com.tejia.lijin.app.util.goods.GoodsDetailListUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsRightViewHolder; |
| | | import com.tejia.lijin.app.util.ui.TextViewUtil; |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.viewpagerindicator.CirclePageIndicator; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.widget.RatioLayout; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | /** |
| | | * 发圈adapter |
| | | */ |
| | | public class SendCircleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
| | | |
| | | private static final String TAG = "SendCircleAdapter"; |
| | | private List<HomeBanner> mBannerList; |
| | | private List<SendCircleContent> mContentList; |
| | | private Activity mContext; |
| | |
| | | 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() |
| | |
| | | }); |
| | | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | public SendCircleContentAdapter(Context context, SendCircleContent content, int maxImgHeight, int maxImgWidth, CommentClickListener commentClickListener, ImgClickListener imgClickListener, int outPosition) { |
| | | this.outPosition = outPosition; |
| | | options = new RequestOptions().skipMemoryCache(false).centerCrop().placeholder(R.drawable.ic_send_circle_default).diskCacheStrategy(DiskCacheStrategy.ALL).error(R.drawable.ic_send_circle_default); |
| | | options = new RequestOptions().skipMemoryCache(false).centerCrop().placeholder(R.color.send_circle_img_default_color).diskCacheStrategy(DiskCacheStrategy.ALL).error(R.color.send_circle_img_default_color); |
| | | this.content = content; |
| | | this.context = context; |
| | | if (content.getImgList() != null) |
| | |
| | | holder.ll_tag.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | holder.tv_content.setClickable(false); |
| | | if (StringUtils.isNullOrEmpty(comment.getContent())) { |
| | | holder.ll_content.setVisibility(View.GONE); |
| | | } else { |
| | | holder.ll_content.setVisibility(View.VISIBLE); |
| | | holder.tv_content.setText(comment.getContent()); |
| | | String content = comment.getContent(); |
| | | |
| | | 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); |
| | |
| | | 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 { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | holder.tv_content.setOnLongClickListener(new View.OnLongClickListener() { |
| | | @Override |
| | | public boolean onLongClick(View v) { |
| | | commentClickListener.onCopyClick(cposition); |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | |
| | | } |
| | | //判断是否为最后一行 |
| | | int currentRow = cposition / lineNum; |
| | | int totalRow=smallImageCount%lineNum==0?smallImageCount/lineNum:smallImageCount/lineNum+1; |
| | | if(currentRow+1==totalRow){ |
| | | int totalRow = smallImageCount % lineNum == 0 ? smallImageCount / lineNum : smallImageCount / lineNum + 1; |
| | | if (currentRow + 1 == totalRow) { |
| | | outRect.bottom = space * 6; |
| | | } |
| | | |
| | | |
| | | |
| | | } else if (position < largeImgCount + smallImageCount + goodsCount) { |