| | |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | |
| | | import com.bumptech.glide.Glide; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.tejia.lijin.app.BasicTextHttpResponseHandler; |
| | | import com.tejia.lijin.app.R; |
| | | import com.tejia.lijin.app.ShoppingApi; |
| | |
| | | import com.tejia.lijin.app.entity.goods.GoodsDetailVO; |
| | | import com.tejia.lijin.app.ui.BaseActivity; |
| | | import com.tejia.lijin.app.ui.dialog.JumpTaoBaoDialog; |
| | | import com.tejia.lijin.app.ui.goods.GoodsDetailHongBaoListAdapter; |
| | | import com.tejia.lijin.app.ui.goods.GoodsDetailPreEventManager; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.ui.mine.LoginSelectActivity; |
| | |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.wang.avi.AVLoadingIndicatorView; |
| | | import com.wpc.library.content.ConnectivityChangeHelper; |
| | | import com.wpc.library.recyclerviewhelper.DividerItemDecoration; |
| | | import com.wpc.library.util.NetUtils; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | |
| | | import java.util.List; |
| | | import java.util.Timer; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | |
| | | private FlowLayout fl_rights_type; |
| | | |
| | | //价格信息/红包 |
| | | private LinearLayout ll_price; |
| | | private RelativeLayout rl_price; |
| | | private RecyclerView rv_price_info; |
| | | |
| | | //图文详情 |
| | |
| | | fl_rights_type = findViewById(R.id.fl_rights_type); |
| | | |
| | | //价格信息/红包 |
| | | ll_price = findViewById(R.id.ll_price); |
| | | rl_price = findViewById(R.id.rl_price); |
| | | rv_price_info = findViewById(R.id.rv_price_info); |
| | | |
| | | ll_fanli = findViewById(R.id.ll_fanli); |
| | |
| | | tv_top_title4.setOnClickListener(this); |
| | | ll_add_collect.setOnClickListener(this); |
| | | fl_back_face.setOnClickListener(this); |
| | | |
| | | ll_fanli.setOnClickListener(this); |
| | | ll_buy.setOnClickListener(this); |
| | | |
| | | if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1")) { |
| | | Intent intent = new Intent(GoodsDetailActivity.this, GoodsDetailBrowerActivity.class); |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optString("code").equalsIgnoreCase("0")) { |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); |
| | | params.bottomMargin = DimenUtils.dip2px(GoodsDetailActivity.this, 50); |
| | | lv_goods_pic.setLayoutParams(params); |
| | | |
| | | Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetailVO.class); |
| | | getGoodsRecommend(mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType()); |
| | | goodsDetailPreEventManager = new GoodsDetailPreEventManager(GoodsDetailActivity.this, mInfo); |
| | | couponUsers = mInfo.getExtra().getListCouponUser(); |
| | | |
| | |
| | | ll_notification.setAnimation(inAnima); |
| | | ll_notification.startAnimation(inAnima); |
| | | } |
| | | ImageUtil.showImageFace(GoodsDetailActivity.this, mInfo.getGoods().getTitle(), mInfo.getGoods().getShopType(), tv_name); |
| | | |
| | | tv_name.setText(mInfo.getGoods().getTitle()); |
| | | webView.loadUrl(mInfo.getExtra().getDetailUrl()); |
| | | |
| | | tv_sales_num.setText("月销 " + mInfo.getGoods().getSalesCount()); |
| | | |
| | | if (mInfo.getGoods().getShopInfo() != null) { |
| | |
| | | } else { |
| | | setCollectionData(false); |
| | | } |
| | | //权益设置 |
| | | |
| | | setRightsData(mInfo.getGoods().getRights()); |
| | | |
| | | //设置价格信息 |
| | | setPriceInfo(mInfo.getGoods()); |
| | | |
| | | //发货地设置 |
| | | if (!StringUtils.isBlank(mInfo.getGoods().getAddress())) { |
| | |
| | | Toast.makeText(GoodsDetailActivity.this, "请先登录板栗快省账号", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | break; |
| | | case R.id.fl_buy: |
| | | //TODO 去购买 |
| | | case R.id.ll_buy: |
| | | goBuy(); |
| | | break; |
| | | |
| | | case R.id.ll_fanli: |
| | | goFanli(); |
| | | break; |
| | | |
| | | case R.id.fl_back_face: |
| | |
| | | } |
| | | |
| | | |
| | | private void setRightsData(boolean coupon, String money, String desc, String link) { |
| | | LayoutInflater inflater = LayoutInflater.from(this); |
| | | View root = inflater.inflate(R.layout.item_goods_detail_rights, null); |
| | | AQuery query = new AQuery(root); |
| | | GradientDrawable gd = new GradientDrawable(); |
| | | gd.setCornerRadius(DimenUtils.dip2px(getApplicationContext(), 10)); |
| | | |
| | | |
| | | TextView tv_money = query.id(R.id.tv_money).getTextView(); |
| | | TextView tv_desc = query.id(R.id.tv_desc).getTextView(); |
| | | |
| | | if (coupon) { |
| | | gd.setColors(new int[]{Color.parseColor("#FFEF9A"), Color.parseColor("#FFFFFF")}); |
| | | tv_money.setTextColor(Color.parseColor("#FFB218")); |
| | | tv_desc.setTextColor(Color.parseColor("#FFB218")); |
| | | private void setRightsData(List<GoodsDetailVO.GoodsRightsVO> rightsList) { |
| | | if (rightsList == null || rightsList.size() == 0) { |
| | | ll_rights_type.setVisibility(View.GONE); |
| | | } else { |
| | | gd.setColors(new int[]{Color.parseColor("#FFE4E8"), Color.parseColor("#FFFFFF")}); |
| | | tv_money.setTextColor(Color.parseColor("#FF2B4B")); |
| | | tv_desc.setTextColor(Color.parseColor("#FF2B4B")); |
| | | ll_rights_type.setVisibility(View.VISIBLE); |
| | | } |
| | | fl_rights_type.removeAllViews(); |
| | | LayoutInflater inflater = LayoutInflater.from(this); |
| | | for (GoodsDetailVO.GoodsRightsVO rights : rightsList) { |
| | | View root = inflater.inflate(R.layout.item_goods_detail_rights, null); |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | params.setMargins(0, DimenUtils.dip2px(getApplicationContext(), 8), DimenUtils.dip2px(getApplicationContext(), 10), 0); |
| | | // root.setLayoutParams(params); |
| | | |
| | | AQuery query = new AQuery(root); |
| | | GradientDrawable gd = new GradientDrawable(); |
| | | gd.setCornerRadius(DimenUtils.dip2px(getApplicationContext(), 10)); |
| | | gd.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); |
| | | TextView tv_money = query.id(R.id.tv_money).getTextView(); |
| | | TextView tv_desc = query.id(R.id.tv_desc).getTextView(); |
| | | if (rights.getType() == 1) { |
| | | gd.setColors(new int[]{Color.parseColor("#FFEF9A"), Color.parseColor("#FFFFFF")}); |
| | | tv_money.setTextColor(Color.parseColor("#FFB218")); |
| | | tv_desc.setTextColor(Color.parseColor("#FFB218")); |
| | | tv_money.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_goods_detail_rights_coupon, 0, 0, 0); |
| | | } else { |
| | | gd.setColors(new int[]{Color.parseColor("#FFE4E8"), Color.parseColor("#FFFFFF")}); |
| | | tv_money.setTextColor(Color.parseColor("#FF2B4B")); |
| | | tv_desc.setTextColor(Color.parseColor("#FF2B4B")); |
| | | if (rights.getType() == 2) { |
| | | tv_money.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_goods_detail_rights_lijin, 0, 0, 0); |
| | | } else { |
| | | tv_money.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_goods_detail_rights_hb, 0, 0, 0); |
| | | } |
| | | |
| | | } |
| | | |
| | | ((LinearLayout) query.id(R.id.ll_content).getView()).setBackground(gd); |
| | | |
| | | if (!StringUtils.isNullOrEmpty(rights.getDescLink())) { |
| | | tv_desc.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.icon_goods_detail_rights_lijin, 0); |
| | | final String url = rights.getDescLink(); |
| | | tv_desc.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | startActivity(new Intent(getApplicationContext(), ShareBrowserActivity.class).putExtra("url", url)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | SpannableString moneyString = new SpannableString(rights.getMoney()); |
| | | moneyString.setSpan(new RelativeSizeSpan(1.5f), 1, (rights.getMoney().indexOf(".") > -1 ? rights.getMoney().indexOf(".") : rights.getMoney().length()), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | tv_money.setText(moneyString); |
| | | tv_desc.setText(rights.getDesc()); |
| | | fl_rights_type.addView(root, params); |
| | | } |
| | | } |
| | | |
| | | private void setPriceInfo(GoodsDetailVO.GoodsInfoVO goodsInfoVO) { |
| | | if (goodsInfoVO.getPriceList() == null || goodsInfoVO.getPriceList().size() == 0) { |
| | | rl_price.setVisibility(View.GONE); |
| | | } else { |
| | | rl_price.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | ((LinearLayout) query.id(R.id.ll_content).getView()).setBackground(gd); |
| | | rv_price_info.setLayoutManager(new LinearLayoutManager(rv_price_info.getContext())); |
| | | rv_price_info.setNestedScrollingEnabled(false); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(getApplicationContext(), 5)); |
| | | rv_price_info.addItemDecoration(decoration); |
| | | rv_price_info.setAdapter(new GoodsDetailHongBaoListAdapter(getApplicationContext(), goodsInfoVO.getPriceList(), false)); |
| | | |
| | | if (!StringUtils.isNullOrEmpty(link)) { |
| | | tv_desc.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); |
| | | } |
| | | tv_fanli_money_num.setText(goodsInfoVO.getMoneyInfo().getFanliMoney()); |
| | | tv_buy.setText(goodsInfoVO.getMoneyInfo().getHongBaoMoney()); |
| | | } |
| | | |
| | | SpannableString moneyString = new SpannableString(money); |
| | | moneyString.setSpan(new RelativeSizeSpan(1.5f), 1, (money.indexOf(".") > -1 ? money.indexOf(".") : money.length()), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | tv_money.setText(moneyString); |
| | | tv_desc.setText(desc); |
| | | |
| | | private void getGoodsRecommend(String goodsId, int goodsType) { |
| | | ShoppingApi.getGuessAndRecommend(this, goodsId, goodsType + "", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optString("code").equalsIgnoreCase("0")) { |
| | | gList.clear(); |
| | | Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | List<TaoBaoGoodsBrief> list1 = gson.fromJson( |
| | | jsonObject.optJSONObject("data").optJSONArray("listGuess").toString(), |
| | | new TypeToken<List<TaoBaoGoodsBrief>>() { |
| | | }.getType()); |
| | | List<TaoBaoGoodsBrief> list2 = gson.fromJson( |
| | | jsonObject.optJSONObject("data").optJSONArray("listQuality").toString(), |
| | | new TypeToken<List<TaoBaoGoodsBrief>>() { |
| | | }.getType()); |
| | | if (list1 != null && list1.size() > 0) { |
| | | gList.addAll(list1); |
| | | gAdapter.notifyDataSetChanged(); |
| | | } |
| | | if (list2 != null && list2.size() > 0) { |
| | | gList.addAll(list2); |
| | | gAdapter.notifyDataSetChanged(); |
| | | } |
| | | |
| | | if (gList.size() == 0) { |
| | | findViewById(R.id.fl_top_title3).setVisibility(View.GONE); |
| | | ll_guess_like.setVisibility(View.GONE); |
| | | } |
| | | if (gList.size() == 0) { |
| | | findViewById(R.id.fl_top_title4).setVisibility(View.GONE); |
| | | findViewById(R.id.ll_relative_goods).setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | } |