| | |
| | | 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.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 Integer maxImgHeight = null; |
| | | |
| | | 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) { |
| | |
| | | SendCircleImageGoods imageGoods = imageList.get(position).getGoods(); |
| | | int goodsType = imageGoods.getGoodsType(); |
| | | //跳转商品详情 |
| | | Intent intent = GoodsDetailJumpUtil.getGoodsDetailIntent(mContext, imageGoods.getGoodsType()); |
| | | intent.putExtra("id", imageGoods.getGoodsId() + ""); |
| | | Intent intent = new Intent(mContext, GoodsDetailActivity.class); |
| | | intent.putExtra("goodsId", imageGoods.getGoodsId()); |
| | | intent.putExtra("goodsType", goodsType); |
| | | intent.putExtra("from", "faquan"); |
| | | mContext.startActivity(intent); |
| | | } |
| | |
| | | } |
| | | }); |
| | | |
| | | circleContentHolder.tv_recommend.setMaxLines(6); |
| | | //推荐语赋值 |
| | | circleContentHolder.tv_recommend.setText(circleContent.getTitle()); |
| | | circleContentHolder.tv_recommend.setMaxLines(8); |
| | | |
| | | circleContentHolder.tv_recommend.setText(TextViewUtil.getClickableHtml(Html.fromHtml(circleContent.getTitle(), imageGetter, null), mContext, Color.parseColor("#586b95"))); |
| | | |
| | | |
| | | circleContentHolder.tv_recommend.post(new Runnable() { |
| | | @Override |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | circleContentHolder.tv_recommend.setOnLongClickListener(new View.OnLongClickListener() { |
| | | @Override |
| | | public boolean onLongClick(View v) { |
| | | |
| | | if (adapterEventActionListener != null) |
| | | adapterEventActionListener.copyRecommendText(circleContent); |
| | | |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | |
| | | if (circleContentHolder.rv_content.getItemDecorationCount() == 0) { |
| | | circleContentHolder.rv_content.addItemDecoration(new SpaceItemDecoration(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 2))); |
| | | circleContentHolder.rv_content.addItemDecoration(new SpaceItemDecoration(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 1))); |
| | | } else { |
| | | SpaceItemDecoration spaceItemDecoration = (SpaceItemDecoration) circleContentHolder.rv_content.getItemDecorationAt(0); |
| | | spaceItemDecoration.initData(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 2)); |
| | | spaceItemDecoration.initData(largeImageCount, smallImageCount + invalidImageCount, goodsCount, commentCount, circleContent.getLineNum(), DimenUtils.dip2px(mContext, 1)); |
| | | } |
| | | |
| | | if (maxImgHeight == null) { |
| | |
| | | |
| | | 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) |
| | |
| | | if (imgInfo.isLarge()) |
| | | width = maxImgWidth; |
| | | else { |
| | | width = (maxImgWidth - DimenUtils.dip2px(mContext, 2) * 8) / 3; |
| | | width = (maxImgWidth - DimenUtils.dip2px(mContext, 2) * 3) / 3; |
| | | } |
| | | height = (int) (width * ratio); |
| | | params.width = width; |
| | |
| | | }); |
| | | |
| | | } else if (holder1 instanceof GoodsViewHolder) { |
| | | |
| | | |
| | | GoodsViewHolder goodsViewHolder = (GoodsViewHolder) holder1; |
| | | |
| | | final TaoBaoGoodsBrief info = goods; |
| | | String disCount; |
| | | if (info.isHasCoupon()) { |
| | | goodsViewHolder.ll_coupon_bg.setVisibility(View.VISIBLE); |
| | | disCount = "¥ " + info.getCouponPrice(); |
| | | goodsViewHolder.tv_coupon_price.setText("¥ " + info.getCouponInfo().getAmount()); |
| | | } else { |
| | | goodsViewHolder.ll_coupon_bg.setVisibility(View.GONE); |
| | | disCount = "¥ " + info.getZkPrice(); |
| | | } |
| | | |
| | | if (info.getShopType() == 11) {//天猫 |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_tmall); |
| | | } else if (info.getShopType() == 20 || info.getShopType() == 21) { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_jingdong); |
| | | } else if (info.getShopType() == 30) { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.ic_pinduoduo); |
| | | } else { |
| | | goodsViewHolder.iv_shop_type.setImageResource(R.drawable.icon); |
| | | } |
| | | |
| | | int pos = disCount.indexOf("."); |
| | | Spannable span = new SpannableString(disCount); |
| | | span.setSpan(new RelativeSizeSpan(1.54f), 1, pos > 1 ? pos : disCount.length(), |
| | | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | goodsViewHolder.tv_price.setText(span); |
| | | |
| | | goodsViewHolder.tv_sales_num.setText(info.getSalesType() == 1 ? "月销 " + info.getSalesCount() : |
| | | info.getSalesType() == 2 ? "2小时销量 " + info.getSalesCount() : info.getSalesType() == 3 ? |
| | | "今日销量 " + info.getSalesCount() : "总销量 " + info.getSalesCount()); |
| | | |
| | | |
| | | goodsViewHolder.tv_zkprice.setText("¥" + info.getZkPrice()); |
| | | goodsViewHolder.tv_zkprice.setPaintFlags(goodsViewHolder.tv_zkprice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); |
| | | |
| | | goodsViewHolder.tv_favourable.setBackgroundResource(R.drawable.shape_goods_list_price_fan); |
| | | goodsViewHolder.tv_favourable.setText(" 奖 " + info.getMoneyInfo().getShareMoney()); |
| | | goodsViewHolder.tv_favourable.setVisibility(View.GONE); |
| | | |
| | | if (info.getState() != 0) { |
| | | GoodsDetailListUtil.setGoodsDetail(context, content.getGoods(), goodsViewHolder.goodsRightViewHolder); |
| | | if (content.getGoods().getState() != 0) { |
| | | goodsViewHolder.view.setOnClickListener(null); |
| | | goodsViewHolder.iv_state_invalid.setVisibility(View.VISIBLE); |
| | | } else { |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | //跳转商品详情 |
| | | Intent intent = GoodsDetailJumpUtil.getGoodsDetailIntent(mContext, info.getGoodsType()); |
| | | intent.putExtra("id", info.getGoodsId()); |
| | | Intent intent = new Intent(mContext, GoodsDetailActivity.class); |
| | | intent.putExtra("goodsId", content.getGoods().getGoodsId()); |
| | | intent.putExtra("goodsType", content.getGoods().getGoodsType()); |
| | | intent.putExtra("from", "faquan"); |
| | | mContext.startActivity(intent); |
| | | } |
| | |
| | | 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(); |
| | | 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, imageGetter, 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.setMaxLines(6); |
| | |
| | | // holder.tv_type.setVisibility(View.VISIBLE); |
| | | // holder.tv_type.setText(comment.getType()); |
| | | // } else { |
| | | holder.tv_type.setVisibility(View.GONE); |
| | | holder.tv_type.setVisibility(View.GONE); |
| | | // } |
| | | |
| | | holder.tv_content.post(new Runnable() { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | holder.tv_content.setOnLongClickListener(new View.OnLongClickListener() { |
| | | @Override |
| | | public boolean onLongClick(View v) { |
| | | commentClickListener.onCopyClick(cposition); |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | |
| | | private ImageView iv_in; |
| | | private TextView tv_content; |
| | | private TextView tv_type; |
| | | private LinearLayout ll_content; |
| | | private LinearLayout ll_content; |
| | | private ImageView iv_comment_more; |
| | | |
| | | public CommentViewHolder(View view) { |
| | |
| | | |
| | | class GoodsViewHolder extends RecyclerView.ViewHolder { |
| | | private View view; |
| | | //商品信息控件 |
| | | private TextView tv_price, tv_zkprice, tv_sales_num, tv_coupon_price, tv_favourable; |
| | | private LinearLayout ll_coupon_bg; |
| | | private GoodsRightViewHolder goodsRightViewHolder; |
| | | //过期标识 |
| | | private ImageView iv_state_invalid, iv_shop_type; |
| | | private ImageView iv_state_invalid; |
| | | |
| | | public GoodsViewHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | tv_price = view.findViewById(R.id.tv_price); |
| | | tv_zkprice = view.findViewById(R.id.tv_zkprice); |
| | | tv_sales_num = view.findViewById(R.id.tv_sales_num); |
| | | tv_coupon_price = view.findViewById(R.id.tv_coupon_price1); |
| | | tv_favourable = view.findViewById(R.id.tv_favourable); |
| | | ll_coupon_bg = view.findViewById(R.id.ll_coupon_bg1); |
| | | iv_state_invalid = view.findViewById(R.id.iv_state_invalid); |
| | | iv_shop_type = view.findViewById(R.id.iv_shop_type); |
| | | goodsRightViewHolder = new GoodsRightViewHolder(view); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | int position = parent.getChildLayoutPosition(view); |
| | | if (position < largeImgCount) { |
| | | outRect.bottom = space * 3; |
| | | outRect.bottom = space * 6; |
| | | if (position == 0) |
| | | outRect.top = 0; |
| | | } else if (position < largeImgCount + smallImageCount) { |
| | |
| | | outRect.left = space; |
| | | outRect.right = space; |
| | | } |
| | | //判断是否为最后一行 |
| | | int currentRow = cposition / lineNum; |
| | | int totalRow = smallImageCount % lineNum == 0 ? smallImageCount / lineNum : smallImageCount / lineNum + 1; |
| | | if (currentRow + 1 == totalRow) { |
| | | outRect.bottom = space * 6; |
| | | } |
| | | |
| | | |
| | | } else if (position < largeImgCount + smallImageCount + goodsCount) { |
| | | outRect.bottom = space; |
| | | outRect.bottom = space * 3; |
| | | outRect.top = 0; |
| | | outRect.left = 0; |
| | | outRect.right = 0; |
| | | } else if (position < largeImgCount + smallImageCount + goodsCount + commentCount) { |
| | | outRect.bottom = space * 2; |
| | | outRect.top = space * 2; |
| | | outRect.bottom = space * 3; |
| | | outRect.top = space * 3; |
| | | int cposition = position - (largeImgCount + smallImageCount + goodsCount + commentCount); |
| | | if (cposition == 0 && goodsCount > 0) |
| | | outRect.top = 0; |
| | |
| | | public void onClick(int position); |
| | | } |
| | | |
| | | interface CommentClickListener { |
| | | public interface CommentClickListener { |
| | | //标签点击 |
| | | public void onTagClick(int position); |
| | | |
| | | //复制点击 |
| | | public void onCopyClick(int position); |
| | | } |
| | | |
| | | //adapter中的事件响应 |
| | | public interface AdapterEventActionListener { |
| | | //复制评论 |
| | | public void copyComment(SendCircleContent content, SendCircleCommment comment); |
| | | |
| | | //生成二维码 |
| | | public void createERCode(SendCircleContent content, List<SendCircleImage> imgList, SendCircleImage img, int position); |
| | | |
| | | //分享 |
| | | public void share(SendCircleContent content); |
| | | |
| | | //批量存图 |
| | | public void saveImgs(SendCircleContent content); |
| | | |
| | | //复制推荐语 |
| | | public void copyRecommendText(SendCircleContent content); |
| | | |
| | | public void sendOrder(SendCircleContent content); |
| | | } |
| | | } |