| | |
| | | package com.tejia.lijin.app.ui.recommend; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | |
| | | import android.graphics.Typeface; |
| | | import android.graphics.drawable.AnimationDrawable; |
| | | import android.graphics.drawable.GradientDrawable; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | |
| | | import android.view.animation.Animation; |
| | | import android.view.animation.AnimationUtils; |
| | | import android.view.animation.DecelerateInterpolator; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebResourceRequest; |
| | | import android.webkit.WebSettings; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | |
| | | import com.tejia.lijin.app.BasicTextHttpResponseHandler; |
| | | import com.tejia.lijin.app.R; |
| | | import com.tejia.lijin.app.ShoppingApi; |
| | | import com.tejia.lijin.app.entity.CouponInfo; |
| | | import com.tejia.lijin.app.entity.CouponUser; |
| | | import com.tejia.lijin.app.entity.GoodsDetail; |
| | | import com.tejia.lijin.app.entity.PushEventData; |
| | | import com.tejia.lijin.app.entity.TaoBaoGoodsBrief; |
| | | import com.tejia.lijin.app.entity.common.ImageShowEntity; |
| | | import com.tejia.lijin.app.entity.goods.GoodsDetailVO; |
| | | import com.tejia.lijin.app.entity.user.UserLijinLevelInfoVO; |
| | | import com.tejia.lijin.app.ui.BaseActivity; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailHongBaoAndCouponSelectDialog; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailJumpLoaingDialog; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailNoLoginFailiDialog; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailNotifyDialog; |
| | | 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.mine.LoginSelectActivity; |
| | | import com.tejia.lijin.app.ui.mine.MyFootmarkActivity; |
| | | import com.tejia.lijin.app.ui.trends.BigImageActivity; |
| | | import com.tejia.lijin.app.util.Constant; |
| | | import com.tejia.lijin.app.util.FlowLayout; |
| | | import com.tejia.lijin.app.util.GlideCircleTransform; |
| | | import com.tejia.lijin.app.util.GlideRoundTransform; |
| | | import com.tejia.lijin.app.util.GoodsBuyJumpUtil; |
| | | import com.tejia.lijin.app.util.ImageUtil; |
| | | import com.tejia.lijin.app.util.SetLabels; |
| | | import com.tejia.lijin.app.util.Toast_Dialog; |
| | | import com.tejia.lijin.app.util.TopStatusSettings; |
| | | import com.tejia.lijin.app.util.clipboard.ClipboardUtil; |
| | | import com.tejia.lijin.app.util.goods.GoodsBuyUtil; |
| | | import com.tejia.lijin.app.util.ui.GoodsDetailUtil; |
| | | import com.tejia.lijin.app.util.ui.dialog.DialogUtil; |
| | | import com.tejia.lijin.app.util.umengCustomEvent.GoodsCustomEvent; |
| | | import com.tejia.lijin.app.util.user.LoginAndInviteStatusUtil; |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.tejia.lijin.app.util.web.RebateJavaInterfaceBS; |
| | | import com.wang.avi.AVLoadingIndicatorView; |
| | | import com.wpc.library.content.ConnectivityChangeHelper; |
| | | import com.wpc.library.recyclerviewhelper.DividerItemDecoration; |
| | |
| | | import java.util.List; |
| | | import java.util.Timer; |
| | | |
| | | import androidx.annotation.RequiresApi; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import wendu.dsbridge.DWebView; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2018/5/11. |
| | |
| | | |
| | | public class GoodsDetailActivity extends BaseActivity implements View.OnClickListener { |
| | | |
| | | private static final String TAG = "GoodsDetailActivity"; |
| | | /**************************控件定义开始**************************/ |
| | | private MyScrollView lv_goods_pic; |
| | | private MyScrollView sv_goods; |
| | | |
| | | private LinearLayout ll_content; |
| | | |
| | |
| | | |
| | | //商品店铺信息 |
| | | private LinearLayout ll_shop; |
| | | private ImageView iv_shop_img, iv_shop_type; |
| | | private ImageView iv_shop_img; |
| | | private TextView tv_shop_type; |
| | | private TextView tv_shop_name; |
| | | private TextView tv_shop_des, tv_shop_service, tv_shop_logistics, tv_shop_des_grade, tv_shop_logistics_grade, |
| | | tv_shop_service_grade; |
| | |
| | | private RecyclerView rv_price_info; |
| | | |
| | | //图文详情 |
| | | private FrameLayout fl_goods_detail; |
| | | private ImageView iv_imgtext_status; |
| | | private WebView webView; |
| | | private DWebView webView; |
| | | private LinearLayout ll_loading; |
| | | private ImageView iv_loading; |
| | | private TextView tv_loading; |
| | | private View view_goods_imgs_tag;//用来标识导航栏选中 |
| | | |
| | | //猜你喜欢 |
| | | private LinearLayout ll_guess_like; |
| | |
| | | |
| | | private void initView() { |
| | | ll_content = findViewById(R.id.ll_content); |
| | | lv_goods_pic = findViewById(R.id.lv_goods_pic); |
| | | sv_goods = findViewById(R.id.lv_goods_pic); |
| | | tv_top_title1 = findViewById(R.id.tv_top_title1); |
| | | tv_top_title2 = findViewById(R.id.tv_top_title2); |
| | | tv_top_title3 = findViewById(R.id.tv_top_title3); |
| | |
| | | tv_buy = findViewById(R.id.tv_buy); |
| | | ll_top_title = findViewById(R.id.ll_top_title); |
| | | iv_shop_img = findViewById(R.id.iv_shop_img); |
| | | iv_shop_type = findViewById(R.id.iv_shop_type); |
| | | tv_shop_type = findViewById(R.id.tv_shop_type); |
| | | tv_shop_name = findViewById(R.id.tv_shop_name); |
| | | tv_shop_des = findViewById(R.id.tv_shop_des); |
| | | tv_shop_service = findViewById(R.id.tv_shop_service); |
| | |
| | | v_3 = findViewById(R.id.v_3); |
| | | v_4 = findViewById(R.id.v_4); |
| | | |
| | | fl_face = findViewById(R.id.fl_face); |
| | | |
| | | |
| | | avLoadingIndicatorView = findViewById(R.id.avi); |
| | | ll_guess_like = findViewById(R.id.ll_guess_like); |
| | | iv_imgtext_status = findViewById(R.id.iv_imgtext_status); |
| | | fl_goods_detail = findViewById(R.id.fl_goods_detail); |
| | | ll_loading = findViewById(R.id.ll_loading); |
| | | tv_loading = findViewById(R.id.tv_loading); |
| | | iv_loading = findViewById(R.id.iv_loading); |
| | | webView = findViewById(R.id.webView); |
| | | view_goods_imgs_tag = findViewById(R.id.view_goods_imgs_tag); |
| | | |
| | | |
| | | vp_goods_detail = findViewById(R.id.vp_goods_img); |
| | |
| | | //umeng统计 |
| | | GoodsCustomEvent.goodsDetail(this, from); |
| | | inputTime = System.currentTimeMillis(); |
| | | final String goodsId = getIntent().getExtras().getString("goodsId"); |
| | | final int goodsType = Integer.parseInt(getIntent().getExtras().getString("goodsType")); |
| | | |
| | | String tempGoodsType = ""; |
| | | String tempGoodsId = ""; |
| | | |
| | | |
| | | //获取商品ID |
| | | tempGoodsId = getIntent().getExtras().getString("goodsId"); |
| | | if (StringUtils.isNullOrEmpty(tempGoodsId)) |
| | | tempGoodsId = getIntent().getExtras().getString("id"); |
| | | final String goodsId = tempGoodsId; |
| | | |
| | | |
| | | //获取商品类型 |
| | | tempGoodsType = getIntent().getExtras().getString("goodsType"); |
| | | if (StringUtils.isNullOrEmpty(tempGoodsType)) |
| | | tempGoodsType = getIntent().getExtras().getInt("goodsType", 0) + ""; |
| | | if (tempGoodsType.equalsIgnoreCase("0")) |
| | | tempGoodsType = Constant.GOODS_TYPE_TB + ""; |
| | | |
| | | |
| | | final int goodsType = Integer.parseInt(tempGoodsType); |
| | | |
| | | |
| | | from = getIntent().getExtras().getString("from"); |
| | | |
| | | tv_loading.setText("宝贝详情页加载中..."); |
| | |
| | | webView.setWebViewClient(new MWebviewClient()); |
| | | WebSettings settings = webView.getSettings(); |
| | | settings.setJavaScriptEnabled(true); |
| | | settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); |
| | | settings.setUseWideViewPort(true); |
| | | webView.setInitialScale(100); |
| | | RebateJavaInterfaceBS javaInterface1 = new RebateJavaInterfaceBS(GoodsDetailActivity.this, |
| | | null, null, new TextView(this), null, webView, null); |
| | | webView.addJavascriptObject(javaInterface1, "yestv"); |
| | | |
| | | ll_loading.setVisibility(View.VISIBLE); |
| | | |
| | | avLoadingIndicatorView.setVisibility(View.VISIBLE); |
| | | Animation ani = AnimationUtils.loadAnimation(this, R.anim.touming); //申明一个动画 |
| | | avLoadingIndicatorView.setAnimation(ani);//为图片绑定动画 |
| | | findViewById(R.id.fl_face).setVisibility(View.VISIBLE); |
| | | fl_face.setVisibility(View.VISIBLE); |
| | | bannerAdapter = new ImageAdapter(mBanners, this); |
| | | vp_goods_detail.setAdapter(bannerAdapter); |
| | | vp_goods_detail.setCurrentItem(0, true); |
| | |
| | | } |
| | | }); |
| | | |
| | | lv_goods_pic.setOnScrollListener(new MyScrollView.OnScrollListener() { |
| | | sv_goods.setOnScrollListener(new MyScrollView.OnScrollListener() { |
| | | @Override |
| | | public void onScroll(int scrollY) { |
| | | int titleHeight = DimenUtils.dip2px(GoodsDetailActivity.this, 48); |
| | | int marginTopHeight = DimenUtils.dip2px(GoodsDetailActivity.this, 8); |
| | | if (scrollY < (vp_goods_detail.getHeight() - titleHeight * 2)) {//头部 |
| | | if (scrollY < fl_goods_detail.getTop()) {//头部 |
| | | setPosition(1); |
| | | } else if (scrollY >= vp_goods_detail.getHeight() - titleHeight * 2 |
| | | && scrollY < (vp_goods_detail.getHeight() + webView.getHeight() - titleHeight) |
| | | && webView.getVisibility() != View.GONE) {//详情图片 |
| | | } else if (scrollY >= (fl_goods_detail.getTop() - titleHeight) |
| | | && scrollY < view_goods_imgs_tag.getTop()) {//详情图片 |
| | | setPosition(2); |
| | | } else if (scrollY >= (vp_goods_detail.getHeight() |
| | | + webView.getHeight() - titleHeight + marginTopHeight) && scrollY < (vp_goods_detail.getHeight() |
| | | + webView.getHeight() + ll_guess_like.getHeight() - titleHeight + marginTopHeight) |
| | | && webView.getVisibility() != View.GONE) {//猜你喜欢 |
| | | setPosition(3); |
| | | } else if (scrollY >= (vp_goods_detail.getHeight() + webView.getHeight() |
| | | + ll_guess_like.getHeight() - titleHeight + marginTopHeight)) {//推荐 |
| | | setPosition(4); |
| | | } else { |
| | | setPosition(4); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | GoodsDetailNotifyDialog notifyDialog; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | |
| | | from = ""; |
| | | initView(); |
| | | initData(); |
| | | // getAppPageNotification(); |
| | | getAppPageNotification(); |
| | | |
| | | |
| | | // notifyDialog = new GoodsDetailNotifyDialog.Builder(GoodsDetailActivity.this).setMessage("测试12123123").setOnButtonClickListener(new GoodsDetailNotifyDialog.Builder.IDialogButtonClick() { |
| | | // @Override |
| | | // public void onLeftClick() { |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onRightClick() { |
| | | // DialogUtil.dismiss(notifyDialog); |
| | | // goFanli(); |
| | | // } |
| | | // }).create(); |
| | | // |
| | | // DialogUtil.show(notifyDialog); |
| | | |
| | | } |
| | | |
| | | public void showNotifyDialog(String btnName, String link) { |
| | | DialogUtil.dismiss(notifyDialog); |
| | | |
| | | notifyDialog = new GoodsDetailNotifyDialog.Builder(this).setIconResource(R.drawable.icon_goods_detail_notify).setLeftBtnInfo(btnName, link).setOnButtonClickListener(new GoodsDetailNotifyDialog.Builder.IDialogButtonClick() { |
| | | @Override |
| | | public void onLeftClick() { |
| | | DialogUtil.dismiss(notifyDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onRightClick() { |
| | | DialogUtil.dismiss(notifyDialog); |
| | | goFanli(); |
| | | } |
| | | }).create(); |
| | | DialogUtil.show(notifyDialog); |
| | | } |
| | | |
| | | |
| | |
| | | inAnima.setInterpolator(new DecelerateInterpolator()); |
| | | ll_notification.setAnimation(inAnima); |
| | | ll_notification.startAnimation(inAnima); |
| | | // inAnima.start(); |
| | | inAnima.start(); |
| | | } else if (msg.what == 3) {//关闭弹窗 |
| | | if (dialog != null && dialog.isShowing()) |
| | | dialog.dismiss(); |
| | |
| | | if (null != url && url.startsWith("yestv://webviewHeight#")) { |
| | | int height = Integer.parseInt(url.replace("yestv://webviewHeight#", "")); |
| | | Log.i("mResult", "webView的高度为:" + height + ""); |
| | | //TODO 测试 |
| | | webView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)); |
| | | return true; |
| | | } |
| | | return super.shouldOverrideUrlLoading(view, url); |
| | | } |
| | | |
| | | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { |
| | | String url = request.getUrl().toString(); |
| | | if (null != url && url.startsWith("yestv://webviewHeight#")) { |
| | | int height = Integer.parseInt(url.replace("yestv://webviewHeight#", "")); |
| | | Log.i("mResult", "webView的高度为:" + height + ""); |
| | | webView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)); |
| | | return true; |
| | | } |
| | | return super.shouldOverrideUrlLoading(view, request); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | }, 3000); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void getAppPageNotification() { |
| | |
| | | |
| | | tv_name.setText(mInfo.getGoods().getTitle()); |
| | | webView.loadUrl(mInfo.getExtra().getDetailUrl()); |
| | | |
| | | tv_sales_num.setText("月销 " + mInfo.getGoods().getSalesCount()); |
| | | if (StringUtils.isNullOrEmpty(mInfo.getGoods().getSalesCount())) { |
| | | tv_sales_num.setText(""); |
| | | } else |
| | | tv_sales_num.setText(GoodsDetailUtil.getSalesTypeDesc(mInfo.getGoods().getSalesType()) + " " + mInfo.getGoods().getSalesCount()); |
| | | |
| | | if (mInfo.getGoods().getShopInfo() != null) { |
| | | ll_shop.setVisibility(View.VISIBLE); |
| | |
| | | tv_shop_name.setText(mInfo.getGoods().getShopInfo().getShopName()); |
| | | |
| | | try { |
| | | GoodsDetailUtil.fillShopType(tv_shop_type, mInfo.getGoods().getShopType()); |
| | | |
| | | iv_shop_type.setImageDrawable(mInfo.getGoods().getShopInfo().getUserType() == 0 ? |
| | | getResources().getDrawable(R.drawable.ic_shop_type_taobao) : |
| | | getResources().getDrawable(R.drawable.ic_shop_type_tmall)); |
| | | tv_shop_des.setText("宝贝描述: " + mInfo.getGoods().getShopInfo().getScoreGoods()); |
| | | tv_shop_service.setText("卖家服务: " + mInfo.getGoods().getShopInfo().getScoreSeller()); |
| | | tv_shop_logistics.setText("物流服务: " + mInfo.getGoods().getShopInfo().getScoreLogistics()); |
| | | tv_shop_des_grade.setText(mInfo.getGoods().getShopInfo().getScoreGoodsD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreGoodsD() == 1 ? "高" : "低"); |
| | | tv_shop_service_grade.setText(mInfo.getGoods().getShopInfo().getScoreSellerD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreSellerD() == 1 ? "高" : "低"); |
| | | tv_shop_logistics_grade.setText(mInfo.getGoods().getShopInfo().getScoreLogisticsD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreLogisticsD() == 1 ? "高" : "低"); |
| | | if (!StringUtils.isNullOrEmpty(mInfo.getGoods().getShopInfo().getScoreGoods())) { |
| | | tv_shop_des.setText("宝贝描述: " + mInfo.getGoods().getShopInfo().getScoreGoods()); |
| | | tv_shop_service.setText("卖家服务: " + mInfo.getGoods().getShopInfo().getScoreSeller()); |
| | | tv_shop_logistics.setText("物流服务: " + mInfo.getGoods().getShopInfo().getScoreLogistics()); |
| | | tv_shop_des_grade.setText(mInfo.getGoods().getShopInfo().getScoreGoodsD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreGoodsD() == 1 ? "高" : "低"); |
| | | tv_shop_service_grade.setText(mInfo.getGoods().getShopInfo().getScoreSellerD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreSellerD() == 1 ? "高" : "低"); |
| | | tv_shop_logistics_grade.setText(mInfo.getGoods().getShopInfo().getScoreLogisticsD() == 0 ? "平" : |
| | | mInfo.getGoods().getShopInfo().getScoreLogisticsD() == 1 ? "高" : "低"); |
| | | } else { |
| | | tv_shop_des.setVisibility(View.INVISIBLE); |
| | | tv_shop_service.setVisibility(View.INVISIBLE); |
| | | tv_shop_logistics.setVisibility(View.INVISIBLE); |
| | | tv_shop_des_grade.setVisibility(View.INVISIBLE); |
| | | tv_shop_service_grade.setVisibility(View.INVISIBLE); |
| | | tv_shop_logistics_grade.setVisibility(View.INVISIBLE); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | |
| | | vp_goods_detail.setCurrentItem(0); |
| | | initFanliAndBuyBtn(mInfo.getExtra().isBuyValid(), mInfo.getExtra().isFanliValid()); |
| | | requestState(0); |
| | | sv_goods.scrollTo(0, 0); |
| | | } else if (jsonObject.optString("code").equalsIgnoreCase("2")) { |
| | | ll_content.setVisibility(View.GONE); |
| | | findViewById(R.id.ll_goods_nothing).setVisibility(View.VISIBLE); |
| | | findViewById(R.id.fl_face).setVisibility(View.VISIBLE); |
| | | fl_face.setVisibility(View.VISIBLE); |
| | | } |
| | | } |
| | | |
| | |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | Log.e("mResult", "goodsdetail---onFinish()"); |
| | | lv_goods_pic.scrollTo(0, 0); |
| | | sv_goods.scrollTo(0, 0); |
| | | avLoadingIndicatorView.hide(); |
| | | findViewById(R.id.fl_face).setVisibility(View.GONE); |
| | | ll_content.setVisibility(View.VISIBLE); |
| | | } |
| | | }); |
| | | } |
| | |
| | | finish(); |
| | | break; |
| | | case R.id.tv_top_title1: |
| | | lv_goods_pic.scrollTo(0, 0); |
| | | sv_goods.scrollTo(0, 0); |
| | | setPosition(1); |
| | | break; |
| | | case R.id.tv_top_title2: |
| | | lv_goods_pic.scrollTo(0, vp_goods_detail.getHeight() - titleHeight * 2); |
| | | case R.id.tv_top_title2://详情 |
| | | sv_goods.scrollTo(0, fl_goods_detail.getTop()); |
| | | setPosition(2); |
| | | break; |
| | | case R.id.tv_top_title3: |
| | | lv_goods_pic.scrollTo(0, vp_goods_detail.getHeight() + webView.getHeight() - titleHeight + marginTopHeight); |
| | | case R.id.tv_top_title3://猜你喜欢 |
| | | sv_goods.scrollTo(0, (int) ll_guess_like.getTop()); |
| | | setPosition(3); |
| | | break; |
| | | case R.id.tv_top_title4: |
| | | lv_goods_pic.scrollTo(0, vp_goods_detail.getHeight() + webView.getHeight() + ll_guess_like.getHeight() - titleHeight + marginTopHeight); |
| | | case R.id.tv_top_title4://推荐 |
| | | Log.i(TAG, (int) ll_guess_like.getTop() + ""); |
| | | sv_goods.scrollTo(0, (int) ll_guess_like.getTop()); |
| | | setPosition(4); |
| | | break; |
| | | |
| | |
| | | * @param state |
| | | */ |
| | | private void requestState(int state) { |
| | | ll_content.setVisibility(state == 0 ? View.VISIBLE : View.GONE); |
| | | // fl_face.setVisibility(state != 0 ? View.VISIBLE : View.GONE); |
| | | ll_no_data.setVisibility(state == 1 ? View.VISIBLE : View.GONE); |
| | | ll_request_failture.setVisibility(state == 2 ? View.VISIBLE : View.GONE); |
| | | ll_no_net.setVisibility(state == 3 ? View.VISIBLE : View.GONE); |
| | | if (mInfo == null) { |
| | | fl_face.setVisibility(View.VISIBLE); |
| | | } else { |
| | | fl_face.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | private void goFanli() { |
| | | goodsDetailPreEventManager.startClick(0, new GoodsDetailPreEventManager.IPreEventListener() { |
| | | @Override |
| | | public void onPreSuccess() { |
| | | |
| | | //TODO 返利 |
| | | } |
| | | }); |
| | | if (mInfo.getGoods().getCouponInfoList() != null && mInfo.getGoods().getCouponInfoList().size() > 1) { |
| | | new GoodsDetailHongBaoAndCouponSelectDialog.Builder(this).setCouponList(mInfo.getGoods().getCouponInfoList()).setItemClickListener(new GoodsDetailHongBaoAndCouponSelectDialog.OnItemClickListener() { |
| | | @Override |
| | | public void onClick(int p) { |
| | | goFanli(mInfo.getGoods().getCouponInfoList().get(p)); |
| | | } |
| | | }).create().show(); |
| | | } else { |
| | | goFanli(null); |
| | | } |
| | | //判断是否有多张券情况 |
| | | } |
| | | |
| | | private void goBuy() { |
| | | goodsDetailPreEventManager.startClick(1, new GoodsDetailPreEventManager.IPreEventListener() { |
| | | private GoodsDetailNoLoginFailiDialog mGoodsDetailNoLoginFailiDialog; |
| | | |
| | | private void goFanli(final CouponInfo couponInfo) { |
| | | |
| | | if (UserUtil.isLogin(getApplicationContext())) { |
| | | goodsDetailPreEventManager.startClick(0, true, new GoodsDetailPreEventManager.IPreEventListener() { |
| | | @Override |
| | | public void onPreSuccess() { |
| | | fanliRequest(couponInfo); |
| | | } |
| | | }); |
| | | } else { |
| | | DialogUtil.dismiss(mGoodsDetailNoLoginFailiDialog); |
| | | mGoodsDetailNoLoginFailiDialog = new GoodsDetailNoLoginFailiDialog.Builder(this).setOnButtonClickListener(new GoodsDetailNoLoginFailiDialog.Builder.IDialogButtonClick() { |
| | | @Override |
| | | public void onLeftClick() { |
| | | DialogUtil.dismiss(mGoodsDetailNoLoginFailiDialog); |
| | | fanliRequest(couponInfo); |
| | | } |
| | | |
| | | @Override |
| | | public void onRightClick() { |
| | | DialogUtil.dismiss(mGoodsDetailNoLoginFailiDialog); |
| | | goodsDetailPreEventManager.startClick(0, true, new GoodsDetailPreEventManager.IPreEventListener() { |
| | | @Override |
| | | public void onPreSuccess() { |
| | | fanliRequest(couponInfo); |
| | | } |
| | | }); |
| | | } |
| | | }).create(); |
| | | mGoodsDetailNoLoginFailiDialog.show(); |
| | | } |
| | | } |
| | | |
| | | private void goBuy() { |
| | | final List<GoodsDetailVO.GoodsHongBaoListVO> hongBaoList = new ArrayList<>(); |
| | | hongBaoList.addAll(mInfo.getGoods().getPriceList()); |
| | | for (int i = 0; i < hongBaoList.size(); i++) { |
| | | if (hongBaoList.get(i).getType() != 2) { |
| | | hongBaoList.remove(i--); |
| | | } |
| | | } |
| | | if (hongBaoList.size() > 1) { |
| | | new GoodsDetailHongBaoAndCouponSelectDialog.Builder(this).setHongBaoList(hongBaoList).setItemClickListener(new GoodsDetailHongBaoAndCouponSelectDialog.OnItemClickListener() { |
| | | @Override |
| | | public void onClick(int p) { |
| | | goBuy(hongBaoList.get(p)); |
| | | } |
| | | }).create().show(); |
| | | } else { |
| | | if (hongBaoList.size() > 0) |
| | | goBuy(hongBaoList.get(0)); |
| | | } |
| | | } |
| | | |
| | | private void goBuy(final GoodsDetailVO.GoodsHongBaoListVO lijinVO) { |
| | | goodsDetailPreEventManager.startClick(1, false, new GoodsDetailPreEventManager.IPreEventListener() { |
| | | @Override |
| | | public void onPreSuccess() { |
| | | //TODO 购买 |
| | | buyRequest(lijinVO); |
| | | } |
| | | }); |
| | | } |
| | |
| | | private void setRightsData(List<GoodsDetailVO.GoodsRightsVO> rightsList) { |
| | | if (rightsList == null || rightsList.size() == 0) { |
| | | ll_rights_type.setVisibility(View.GONE); |
| | | return; |
| | | } else { |
| | | ll_rights_type.setVisibility(View.VISIBLE); |
| | | } |
| | |
| | | } |
| | | |
| | | 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)); |
| | | rv_price_info.setAdapter(new GoodsDetailHongBaoListAdapter(getApplicationContext(), goodsInfoVO.getPriceList(), new GoodsDetailHongBaoListAdapter.ListClickListener() { |
| | | |
| | | @Override |
| | | public void onHongBaoClick(int p, GoodsDetailVO.GoodsHongBaoListVO info) { |
| | | if (info.getType() == 4) { |
| | | goFanli(null); |
| | | } else { |
| | | goBuy(info); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCouponClick(int p) { |
| | | |
| | | } |
| | | }, |
| | | false, true)); |
| | | |
| | | tv_fanli_money_num.setText(goodsInfoVO.getMoneyInfo().getFanliMoney()); |
| | | tv_buy.setText(goodsInfoVO.getMoneyInfo().getHongBaoMoney()); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | private void buyRequest(GoodsDetailVO.GoodsHongBaoListVO goodsHongBaoListVO) { |
| | | |
| | | ShoppingApi.buyWithLijin(getApplicationContext(), mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType(), goodsHongBaoListVO.getId(), UserUtil.getUid(getApplicationContext()), from, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | int code = jsonObject.optInt("code"); |
| | | if (code == 0) { |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | JSONObject link = data.optJSONObject("link"); |
| | | UserLijinLevelInfoVO userLevel = null; |
| | | if (data.optJSONObject("userLevel") != null) { |
| | | userLevel = new Gson().fromJson(data.optJSONObject("userLevel").toString(), UserLijinLevelInfoVO.class); |
| | | } |
| | | |
| | | if (link != null) { |
| | | final String linkUrl = link.optString("clickUrl"); |
| | | GoodsBuyJumpUtil.jumpTB(GoodsDetailActivity.this, null, linkUrl, linkUrl, userLevel, null); |
| | | } |
| | | String todayLeftCount = data.optString("todayLeftCount"); |
| | | if (!StringUtils.isNullOrEmpty(todayLeftCount)) { |
| | | Toast.makeText(GoodsDetailActivity.this, todayLeftCount, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | |
| | | } else { |
| | | if (code == 2001) { |
| | | //用户机会已经用完了 |
| | | getBuyChanceInfoRequest(); |
| | | } else { |
| | | notifyDialog = new GoodsDetailNotifyDialog.Builder(GoodsDetailActivity.this).setMessage(jsonObject.optString("msg")).setOnButtonClickListener(new GoodsDetailNotifyDialog.Builder.IDialogButtonClick() { |
| | | @Override |
| | | public void onLeftClick() { |
| | | } |
| | | |
| | | @Override |
| | | public void onRightClick() { |
| | | DialogUtil.dismiss(notifyDialog); |
| | | goFanli(); |
| | | } |
| | | }).create(); |
| | | DialogUtil.show(notifyDialog); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void fanliRequest(CouponInfo couponInfo) { |
| | | GoodsBuyUtil.GoodsBuyRequestInfo requestInfo = new GoodsBuyUtil.GoodsBuyRequestInfo(); |
| | | requestInfo.setGoodsId(mInfo.getGoods().getGoodsId()); |
| | | requestInfo.setGoodsType(mInfo.getGoods().getGoodsType()); |
| | | if (couponInfo != null) |
| | | requestInfo.setCouponLink(couponInfo.getLink()); |
| | | requestInfo.setUid(UserUtil.getUid(getApplicationContext())); |
| | | requestInfo.setFrom(from); |
| | | |
| | | //返利 |
| | | GoodsBuyUtil.fanli(this, getApplicationContext(), requestInfo, new GoodsBuyUtil.IBuyGoodsResultListener() { |
| | | @Override |
| | | public void onConvertLinkStart() { |
| | | DialogUtil.show(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkSuccess() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkFail(String msg) { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkComplete() { |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppStart() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppSuccess() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppFail() { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取购买机会信息 |
| | | */ |
| | | private void getBuyChanceInfoRequest() { |
| | | ShoppingApi.getUserLijinCreatedInfo(getApplicationContext(), mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType(), UserUtil.getUid(getApplicationContext()), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject.optInt("code") == 0) { |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | int leftCount = data.optInt("leftCount"); |
| | | // if (leftCount <= 0) { |
| | | JSONObject openInfo = data.optJSONObject("openInfo"); |
| | | if (openInfo != null) { |
| | | showNotifyDialog(openInfo.optString("btnName"), openInfo.optString("vipLink")); |
| | | } else { |
| | | showNotifyDialog(null, null); |
| | | } |
| | | // } |
| | | |
| | | |
| | | } else { |
| | | Toast.makeText(GoodsDetailActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | Toast.makeText(GoodsDetailActivity.this, "网络请求出错", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | DialogUtil.dismiss(loadingDialog); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | } |