From 399ac289f80b7a40aa4210341db6b447cacdcf14 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 09 八月 2022 17:42:33 +0800 Subject: [PATCH] 广告升级,隐私政策整改 --- app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java | 635 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 540 insertions(+), 95 deletions(-) diff --git a/app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java b/app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java index 6cd32f6..4bebab3 100644 --- a/app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java +++ b/app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java @@ -1,5 +1,6 @@ package com.tejia.lijin.app.ui.recommend; +import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -8,6 +9,7 @@ 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; @@ -23,6 +25,8 @@ 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; @@ -30,6 +34,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -37,34 +42,50 @@ 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.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.invite.ShareBrowserActivity; 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 com.wpc.library.util.NetUtils; import com.wpc.library.util.common.DimenUtils; import com.wpc.library.util.common.StringUtils; @@ -78,9 +99,12 @@ 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. @@ -89,8 +113,9 @@ 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; @@ -119,7 +144,8 @@ //鍟嗗搧搴楅摵淇℃伅 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; @@ -129,15 +155,17 @@ private FlowLayout fl_rights_type; //浠锋牸淇℃伅/绾㈠寘 - private LinearLayout ll_price; + private RelativeLayout rl_price; 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; @@ -170,7 +198,7 @@ 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); @@ -182,7 +210,7 @@ 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); @@ -197,14 +225,18 @@ 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); @@ -241,7 +273,7 @@ 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); @@ -253,8 +285,29 @@ //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("瀹濊礉璇︽儏椤靛姞杞戒腑..."); @@ -265,13 +318,19 @@ 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); @@ -357,25 +416,16 @@ } }); - 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); } @@ -424,6 +474,9 @@ 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); @@ -521,6 +574,8 @@ } + GoodsDetailNotifyDialog notifyDialog; + @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); @@ -531,7 +586,41 @@ 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); } @@ -547,7 +636,7 @@ 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(); @@ -562,11 +651,23 @@ 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 @@ -579,6 +680,7 @@ } }, 3000); } + } private void getAppPageNotification() { @@ -648,12 +750,9 @@ @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(); @@ -677,9 +776,13 @@ 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 (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); @@ -691,19 +794,26 @@ 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) { } @@ -717,6 +827,12 @@ } else { setCollectionData(false); } + //鏉冪泭璁剧疆 + + setRightsData(mInfo.getGoods().getRights()); + + //璁剧疆浠锋牸淇℃伅 + setPriceInfo(mInfo.getGoods()); //鍙戣揣鍦拌缃� if (!StringUtils.isBlank(mInfo.getGoods().getAddress())) { @@ -736,10 +852,10 @@ 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); } } @@ -762,10 +878,8 @@ 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); } }); } @@ -814,19 +928,20 @@ 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; @@ -849,8 +964,12 @@ 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: @@ -1051,10 +1170,15 @@ * @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 @@ -1075,58 +1199,379 @@ 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(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); + return; } 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())); + DividerItemDecoration decoration = new DividerItemDecoration(); + decoration.setSize(DimenUtils.dip2px(getApplicationContext(), 5)); + rv_price_info.addItemDecoration(decoration); + rv_price_info.setAdapter(new GoodsDetailHongBaoListAdapter(getApplicationContext(), goodsInfoVO.getPriceList(), new GoodsDetailHongBaoListAdapter.ListClickListener() { - if (!StringUtils.isNullOrEmpty(link)) { - tv_desc.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - } + @Override + public void onHongBaoClick(int p, GoodsDetailVO.GoodsHongBaoListVO info) { + if (info.getType() == 4) { + goFanli(null); + } else { + goBuy(info); + } + } - 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); + @Override + public void onCouponClick(int p) { + + } + }, + false, true)); + + tv_fanli_money_num.setText(goodsInfoVO.getMoneyInfo().getFanliMoney()); + tv_buy.setText(goodsInfoVO.getMoneyInfo().getHongBaoMoney()); + } + + + 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); + } + } + } + + }); + } + + + 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); + } + }); + + } } -- Gitblit v1.8.0