From 1b4b3fed2569ac21ad6feb0a3a2c051175e7c36e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 14 五月 2021 19:47:25 +0800 Subject: [PATCH] 用户IDString改为Long,详情页初步修改 --- app/src/main/java/com/tejia/lijin/app/ui/recommend/GoodsDetailActivity.java | 831 ++++------------------------------------------------------- 1 files changed, 58 insertions(+), 773 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 40e35d6..6cd32f6 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,7 +1,6 @@ package com.tejia.lijin.app.ui.recommend; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; @@ -15,8 +14,6 @@ import android.provider.Settings; import android.text.SpannableString; import android.text.Spanned; -import android.text.SpannedString; -import android.text.TextUtils; import android.text.style.RelativeSizeSpan; import android.util.Log; import android.view.LayoutInflater; @@ -26,7 +23,6 @@ import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; -import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -37,62 +33,36 @@ import android.widget.TextView; import android.widget.Toast; -import com.alibaba.baichuan.android.trade.AlibcTrade; -import com.alibaba.baichuan.android.trade.AlibcTradeSDK; -import com.alibaba.baichuan.android.trade.model.AlibcShowParams; -import com.alibaba.baichuan.android.trade.model.OpenType; -import com.alibaba.baichuan.android.trade.page.AlibcBasePage; -import com.alibaba.baichuan.android.trade.page.AlibcDetailPage; -import com.alibaba.baichuan.trade.biz.AlibcConstants; -import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; -import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; -import com.alibaba.baichuan.trade.biz.login.AlibcLogin; -import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback; import com.androidquery.AQuery; import com.bumptech.glide.Glide; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.tejia.lijin.app.BasicTextHttpResponseHandler; -import com.tejia.lijin.app.BuXinConstant; import com.tejia.lijin.app.R; import com.tejia.lijin.app.ShoppingApi; -import com.tejia.lijin.app.callBack.MiDuoTradeCallback; -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.TbPidInfo; -import com.tejia.lijin.app.entity.UserInfo; import com.tejia.lijin.app.entity.common.ImageShowEntity; -import com.tejia.lijin.app.entity.share.SingleGoodsShareInfo; +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.dialog.ReceiveCouponHintDialog; -import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; import com.tejia.lijin.app.ui.goods.GoodsDetailPreEventManager; import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; -import com.tejia.lijin.app.ui.mine.Collect28Activity; import com.tejia.lijin.app.ui.mine.LoginSelectActivity; import com.tejia.lijin.app.ui.mine.MyFootmarkActivity; -import com.tejia.lijin.app.ui.mine.ShoppingTrolleyActivity; import com.tejia.lijin.app.ui.trends.BigImageActivity; -import com.tejia.lijin.app.util.ApkUtil; 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.ImageUtil; -import com.tejia.lijin.app.util.InitAlibcSdk; 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.baichuan.AlibcTradeUtil; import com.tejia.lijin.app.util.clipboard.ClipboardUtil; import com.tejia.lijin.app.util.umengCustomEvent.GoodsCustomEvent; -import com.tejia.lijin.app.util.umengCustomEvent.SearchCustomEvent; import com.tejia.lijin.app.util.user.LoginAndInviteStatusUtil; import com.tejia.lijin.app.util.user.UserUtil; -import com.umeng.analytics.MobclickAgent; import com.wang.avi.AVLoadingIndicatorView; import com.wpc.library.content.ConnectivityChangeHelper; import com.wpc.library.util.NetUtils; @@ -105,10 +75,7 @@ import org.json.JSONObject; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Timer; import androidx.recyclerview.widget.RecyclerView; @@ -131,7 +98,7 @@ private ImageView iv_back, iv_top_left; private LinearLayout ll_top_title; private TextView tv_top_title1, tv_top_title2, tv_top_title3, tv_top_title4; - private View v_1, v_2, v_3, v_4, v_cover, v_cover1, v_cover2; + private View v_1, v_2, v_3, v_4, v_cover, v_cover1; //鍟嗗搧鍩虹淇℃伅 private ViewPager vp_goods_detail; @@ -225,11 +192,12 @@ tv_shop_service_grade = findViewById(R.id.tv_shop_service_grade); v_cover = findViewById(R.id.v_cover); v_cover1 = findViewById(R.id.v_cover1); - v_cover2 = findViewById(R.id.v_cover2); v_1 = findViewById(R.id.v_1); v_2 = findViewById(R.id.v_2); v_3 = findViewById(R.id.v_3); v_4 = findViewById(R.id.v_4); + + avLoadingIndicatorView = findViewById(R.id.avi); ll_guess_like = findViewById(R.id.ll_guess_like); iv_imgtext_status = findViewById(R.id.iv_imgtext_status); @@ -285,7 +253,9 @@ //umeng缁熻 GoodsCustomEvent.goodsDetail(this, from); inputTime = System.currentTimeMillis(); - goodsId = getIntent().getExtras().getString("id"); + final String goodsId = getIntent().getExtras().getString("goodsId"); + final int goodsType = Integer.parseInt(getIntent().getExtras().getString("goodsType")); + from = getIntent().getExtras().getString("from"); tv_loading.setText("瀹濊礉璇︽儏椤靛姞杞戒腑..."); AnimationDrawable animationDrawable = (AnimationDrawable) getResources().getDrawable( @@ -454,7 +424,6 @@ tv_top_title4.setOnClickListener(this); ll_add_collect.setOnClickListener(this); fl_back_face.setOnClickListener(this); - v_cover2.setOnClickListener(this); if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1")) { Intent intent = new Intent(GoodsDetailActivity.this, GoodsDetailBrowerActivity.class); @@ -467,8 +436,7 @@ @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { TaoBaoGoodsBrief info = (TaoBaoGoodsBrief) adapterView.getAdapter().getItem(position); - goodsId = info.getGoodsId(); - getGoodsDetail(); + getGoodsDetail(info.getGoodsId(), info.getGoodsType()); } }); @@ -500,7 +468,7 @@ public void onNetworkAvailable() { requestState(0); if (mInfo == null) { - getGoodsDetail(); + getGoodsDetail(goodsId, goodsType); } } }); @@ -513,12 +481,6 @@ private List<String> mBanners = new ArrayList<>(); private int picNum = 1; - String goodsId; - String goodsTaoBaoId; - - private Map<String, String> exParams;//yhhpass鍙傛暟 - AlibcShowParams alibcShowParams; - AlibcTaokeParams alibcTaokeParams; Animation inAnima; @@ -562,14 +524,14 @@ @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); - setContentView(R.layout.activity_goods_detail_transition); + setContentView(R.layout.activity_goods_detail_new); TopStatusSettings.setStatusViewAndDeepColor2(this); from = getIntent().getStringExtra("from"); if (StringUtils.isEmpty(from)) from = ""; initView(); initData(); - getAppPageNotification(); +// getAppPageNotification(); } @@ -600,6 +562,7 @@ 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; } @@ -673,19 +636,15 @@ } - GoodsDetail mInfo; - boolean isNative = true; - TbPidInfo tInfo; + GoodsDetailVO mInfo; List<CouponUser> couponUsers; String from; - String noRebateHelpLink; boolean isQuestDetail; - private void getGoodsDetail() { + private void getGoodsDetail(String goodsId, int goodsType) { isQuestDetail = true; - String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0"); - ShoppingApi.getGoodsInfoTB(this, goodsId, uid, from, new BasicTextHttpResponseHandler() { + ShoppingApi.getGoodsInfo(this, goodsId, goodsType, UserUtil.getUid(getApplicationContext()), from, new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { if (jsonObject.optString("code").equalsIgnoreCase("0")) { @@ -694,13 +653,9 @@ lv_goods_pic.setLayoutParams(params); Gson gson = new GsonBuilder().serializeNulls().create(); - mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetail.class); - + mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetailVO.class); goodsDetailPreEventManager = new GoodsDetailPreEventManager(GoodsDetailActivity.this, mInfo); - - h5Url = mInfo.getExtra().getH5Url();//浜у搧h5 閾炬帴 couponUsers = mInfo.getExtra().getListCouponUser(); - noRebateHelpLink = mInfo.getExtra().getShare().getHelpLink(); if (mInfo.getGoods() != null && mInfo.getGoods().getLabels() != null && mInfo.getGoods().getLabels().size() > 0) { SetLabels.addLabel(GoodsDetailActivity.this, ll_labels, mInfo.getGoods().getLabels()); @@ -715,7 +670,6 @@ index = 1; } - goodsTaoBaoId = mInfo.getGoods().getGoodsId(); isCollect = mInfo.getExtra().isCollected(); if (couponUsers != null && couponUsers.size() > 0) { @@ -727,25 +681,36 @@ webView.loadUrl(mInfo.getExtra().getDetailUrl()); tv_sales_num.setText("鏈堥攢 " + mInfo.getGoods().getSalesCount()); + if (mInfo.getGoods().getShopInfo() != null) { + ll_shop.setVisibility(View.VISIBLE); + Glide.with(GoodsDetailActivity.this).load(mInfo.getGoods().getShopInfo().getShopIcon()) + .placeholder(R.drawable.ic_goods_default) + .error(R.drawable.ic_goods_default) + .transform(new GlideRoundTransform(GoodsDetailActivity.this, + 5)).into(iv_shop_img); + tv_shop_name.setText(mInfo.getGoods().getShopInfo().getShopName()); - Glide.with(GoodsDetailActivity.this).load(mInfo.getGoods().getShopInfo().getShopIcon()) - .placeholder(R.drawable.ic_goods_default) - .error(R.drawable.ic_goods_default) - .transform(new GlideRoundTransform(GoodsDetailActivity.this, - 5)).into(iv_shop_img); - tv_shop_name.setText(mInfo.getGoods().getShopInfo().getShopName()); - 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 ? "楂�" : "浣�"); + try { + + 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 ? "楂�" : "浣�"); + } catch (Exception e) { + + } + } else { + ll_shop.setVisibility(View.GONE); + } + if (mInfo.getExtra().isCollected()) { setCollectionData(true); @@ -754,9 +719,11 @@ } //鍙戣揣鍦拌缃� - if (!StringUtils.isBlank(mInfo.getGoods().getProvCity())) { + if (!StringUtils.isBlank(mInfo.getGoods().getAddress())) { ll_address.setVisibility(View.VISIBLE); - tv_address.setText(mInfo.getGoods().getProvCity()); + tv_address.setText(mInfo.getGoods().getAddress()); + } else { + ll_address.setVisibility(View.GONE); } Log.i("mResult", "isLike鐨勫�间负" + mInfo.getGoods().getGoodsId()); @@ -767,8 +734,7 @@ mBanners.addAll(mInfo.getGoods().getImgList()); bannerAdapter.notifyDataSetChanged(); vp_goods_detail.setCurrentItem(0); - isNative = mInfo.getExtra().isNative(); - initFanliAndBuyBtn(mInfo.getExtra().isShareValid(), mInfo.getExtra().isFanliValid()); + initFanliAndBuyBtn(mInfo.getExtra().isBuyValid(), mInfo.getExtra().isFanliValid()); requestState(0); } else if (jsonObject.optString("code").equalsIgnoreCase("2")) { ll_content.setVisibility(View.GONE); @@ -807,66 +773,16 @@ Timer timer; JumpTaoBaoDialog dialog; - boolean isFirst = true; @Override protected void onResume() { super.onResume(); + if (mChangeHelper != null) + mChangeHelper.registerReceiver(); if (goodsDetailPreEventManager != null) goodsDetailPreEventManager.onResume(); isVisible = true; - mChangeHelper.registerReceiver(); - SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); - boolean isLogin = sp.getBoolean("isLogin", false); - - //VIP涓嶅湪灞曠ず瓒呯骇浼氬憳 - UserInfo user = UserUtil.getUserInfo(this); - - if (isLogin) { - if (isClick == 1 && !isTBStartBind) { - if (isFirst) { - getTaoBaoH5AuthInfo("zigou"); - } else { - getTaoBaoH5AuthInfo2("zigou"); - } - } else if (isClick == 2 && !isTBStartBind) { - if (mInfo != null) { - if (isFirst) { - getTaoBaoH5AuthInfo("share"); - } else { - getTaoBaoH5AuthInfo2("share"); - isClick = 0; - } - } else { - Toast.makeText(GoodsDetailActivity.this, "鏆傛湭鑾峰彇鍒板垎浜繑鍒╋紝璇风◢绛�", Toast.LENGTH_LONG).show(); - isClick = 0; - } - } else if (isClick == 3) { - if (isCollect) { - setCollectionData(true); - } else { - collection(); - } - isClick = 0; - } else if (isClick == 4) { - if (AlibcLogin.getInstance().isLogin()) { - isClick = 0; - startActivity(new Intent(GoodsDetailActivity.this, ShoppingTrolleyActivity.class)); - } - } else if (isClick == 5) { - isClick = 0; - startActivity(new Intent(GoodsDetailActivity.this, Collect28Activity.class)); - } else if (isClick == 7) { - isClick = 0; - } else if (isClick == 8) {//澶嶅埗娣樺彛浠� - commandCopy(); - isClick = 0; - } else if (isClick == 9) {//璺宠浆濂栧姳鍒歌幏鍙� - jumpDetail(); - isClick = 0; - } - } } @Override @@ -874,89 +790,16 @@ super.onPause(); isVisible = false; mChangeHelper.unregisterReceiver(); - timer(); } - - String clickUrl = ""; - String couponUrl = ""; - private String h5Url = "";//浜у搧閾炬帴 int type = 0; - /** - * 鑾峰彇PID 淇℃伅 - */ - private void getTBLinkInfo(String uid) { - if (pd == null) - pd = new ShapeLoadingDialog.Builder(this).build(); - if (!pd.isShowing()) - pd.show(); - ShoppingApi.getTBLinkInfo(this, uid, goodsId, "goodsDetail", from, new BasicTextHttpResponseHandler() { - @Override - public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { - if (jsonObject.optString("code").equalsIgnoreCase("0")) { - Gson gson = new GsonBuilder().serializeNulls().create(); - isNative = jsonObject.optJSONObject("data").optBoolean("native"); - type = Integer.parseInt(jsonObject.optJSONObject("data").optString("type")); - if (jsonObject.optJSONObject("data").optJSONObject("tbPidInfo") != null) - tInfo = gson.fromJson(jsonObject.optJSONObject("data").optJSONObject("tbPidInfo").toString(), TbPidInfo.class); - JSONObject object = jsonObject.optJSONObject("data").optJSONObject("link"); - if (object != null) { - clickUrl = object.optString("clickUrl"); - couponUrl = object.optString("couponUrl"); - } - Log.e("mResult", "getTBLinkInfo():type---" + type + "---isLogin---" + AlibcLogin.getInstance().isLogin()); - goBuy(); - pd.dismiss(); - } - } - - @Override - public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { - super.onFailure(statusCode, headers, jsonObject, e); - pd.dismiss(); - } - }); - } - private boolean isCollect = false; - private int isClick = 0; private boolean isSpread = false;//鍥炬枃鏄惁灞曞紑 List<TaoBaoGoodsBrief> gList = new ArrayList<>(); RelativeGoodsAdapter gAdapter; - long lastShareTimeClick = 0; - long lastBuyTimeClick = 0; - //鏄惁涓哄鍒堕摼鎺ユ寜閽� - boolean copyLink = false; - - //寮�濮嬪垎浜� - private void startShare(boolean isLogin) { - if (mInfo == null || mInfo.getGoods() == null) - return; - long cTime = System.currentTimeMillis(); - if (cTime - lastShareTimeClick < 500) { - lastShareTimeClick = cTime; - return; - } - lastShareTimeClick = cTime; - isTBStartBind = false; - GoodsCustomEvent.goodsDetailShare(GoodsDetailActivity.this); - if (isLogin) { - if (mInfo != null) { - getTaoBaoH5AuthInfo("share"); - } else { - Toast.makeText(GoodsDetailActivity.this, "鏆傛湭鑾峰彇鍒板垎浜繑鍒╋紝璇风◢绛�", Toast.LENGTH_LONG).show(); - } - } else { - isClick = 2; - Toast.makeText(GoodsDetailActivity.this, "璇峰厛鐧诲綍鏉挎牀蹇渷璐﹀彿", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(GoodsDetailActivity.this, LoginSelectActivity.class); - intent.putExtra("from", "娣樺疂"); - startActivity(intent); - } - } @Override public void onClick(View v) { @@ -988,7 +831,7 @@ break; case R.id.ll_add_collect: - if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", true)) + if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()), true)) return; ll_add_collect.setEnabled(false); if (mInfo == null) { @@ -1000,54 +843,14 @@ collection(); } else { ll_add_collect.setEnabled(true); - isClick = 3; Intent intent = new Intent(GoodsDetailActivity.this, LoginSelectActivity.class); intent.putExtra("from", "娣樺疂"); startActivity(intent); Toast.makeText(GoodsDetailActivity.this, "璇峰厛鐧诲綍鏉挎牀蹇渷璐﹀彿", Toast.LENGTH_SHORT).show(); } break; - case R.id.ll_copy_link: - if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", true)) - return; - copyLink = true; - startShare(isLogin); - break; - //鍒嗕韩濂栭噾 - case R.id.ll_share_gain: - if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", true)) - return; - copyLink = false; - startShare(isLogin); - break; - //棰嗗埜 - case R.id.fl_receive_coupon: - - if (mInfo == null || mInfo.getGoods() == null) - return; - long cTime1 = System.currentTimeMillis(); - if (cTime1 - lastBuyTimeClick < 500) { - lastBuyTimeClick = cTime1; - break; - } - lastBuyTimeClick = cTime1; - GoodsCustomEvent.goodsDetailCouponClick(this); - - break; - case R.id.tv_big_btn: case R.id.fl_buy: - if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", true)) - return; - if (mInfo == null || mInfo.getGoods() == null) - return; - long cTime2 = System.currentTimeMillis(); - if (cTime2 - lastBuyTimeClick < 500) { - lastBuyTimeClick = cTime2; - break; - } - lastBuyTimeClick = cTime2; - GoodsCustomEvent.goodsDetailBuyCommon(this); - buyOrGainCoupon(isLogin); + //TODO 鍘昏喘涔� break; case R.id.fl_back_face: @@ -1065,12 +868,10 @@ return; if (isSpread) { webView.setVisibility(View.GONE); -// ll_imgs.removeAllViews(); iv_imgtext_status.setImageDrawable(getResources().getDrawable(R.drawable.ic_detail_img_close)); } else { webView.setVisibility(View.VISIBLE); iv_imgtext_status.setImageDrawable(getResources().getDrawable(R.drawable.ic_detail_img_open)); -// getImgText(); } isSpread = !isSpread; break; @@ -1089,191 +890,13 @@ Gson gson = new GsonBuilder().serializeNulls().create(); String data = gson.toJson(info); break; - case R.id.fl_command_copy: - if (isLogin) - commandCopy(); - else - commandCopyHint(); - break; - case R.id.iv_footermark: startActivity(new Intent(GoodsDetailActivity.this, MyFootmarkActivity.class)); break; - - case R.id.ll_same: - if (mInfo == null || mInfo.getGoods() == null) - return; - Intent intent = new Intent(this, SearchResultActivity.class); - intent.putExtra("content", mInfo.getGoods().getTitle()); - startActivity(intent); - break; } } - private void jumpDetail() { - Intent intent; - if ((!StringUtils.isEmpty(mInfo.getGoods().getOtherInfo().getRewardCoupon().getJumpDetail().getActivity()))) { - try { - intent = new Intent(this, Class.forName(mInfo.getGoods().getOtherInfo().getRewardCoupon().getJumpDetail().getActivity())); - } catch (Exception e) { - e.printStackTrace(); - return; - } - if (mInfo.getGoods().getOtherInfo().getRewardCoupon().getParams() != null) { - @SuppressWarnings("unchecked") - Iterator<String> its = mInfo.getGoods().getOtherInfo().getRewardCoupon().getParams().keySet().iterator(); - while (its.hasNext()) { - String key = its.next(); - String value = mInfo.getGoods().getOtherInfo().getRewardCoupon().getParams().getString(key); - intent.putExtra(key, value); - } - } - startActivity(intent); - } - } - - /* - *棰嗗埜鎻愮ず - */ - private void receiveCouponHint(final String couponUrl) { - final SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); - boolean receiveCouponHint = sp.getBoolean("receiveCouponHint", true); - if (!receiveCouponHint) { - receiveCoupon(couponUrl); - } else { - ReceiveCouponHintDialog.Builder builder = new ReceiveCouponHintDialog.Builder(GoodsDetailActivity.this); - builder.setMessage("鏈櫥褰曟棤杩斿埄锛岀‘瀹氬厤璐归鍒革紵").setTitle("娓╅Θ鎻愮ず") - .setPositiveButton("鍘婚鍒�", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface cDialog, int which) { - cDialog.dismiss(); - SharedPreferences.Editor editor = sp.edit(); - editor.putBoolean("receiveCouponHint", false); - editor.commit(); - receiveCoupon(couponUrl); - } - }) - .setNegativeButton("鍘荤櫥褰�", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(GoodsDetailActivity.this, LoginSelectActivity.class); - intent.putExtra("from", "娣樺疂"); - startActivity(intent); - isClick = 1; - dialog.dismiss(); - } - }).create().show(); - } - } - - private void receiveCoupon(String couponUrl) { - if (ApkUtil.checkAPP(GoodsDetailActivity.this, "com.taobao.taobao")) { - alibcShowParams = new AlibcShowParams(); - alibcShowParams.setOpenType(OpenType.Native); - } else { - alibcShowParams = new AlibcShowParams(); - alibcShowParams.setOpenType(OpenType.Auto); - } - alibcTaokeParams = new AlibcTaokeParams("", "", ""); - alibcTaokeParams.setPid(BuXinConstant.BAICHUAN_PID); - alibcTaokeParams.setAdzoneid(BuXinConstant.BAICHUAN_ADZONE_ID); - alibcTaokeParams.pid = BuXinConstant.BAICHUAN_PID; - alibcTaokeParams.adzoneid = BuXinConstant.BAICHUAN_ADZONE_ID; - alibcTaokeParams.extraParams = new HashMap<>(); - alibcTaokeParams.extraParams.put("taokeAppkey", BuXinConstant.TAO_BAO_KE_KEY); - - exParams = new HashMap<>(); - exParams.put(AlibcConstants.ISV_CODE, "appisvcode"); - exParams.put("alibaba", "闃块噷宸村反");//鑷畾涔夊弬鏁伴儴鍒嗭紝鍙换鎰忓鍒犳敼 - - if (!StringUtils.isEmpty(couponUrl)) { - jumpWeb(couponUrl); - } else { - AlibcDetailPage basePage = new AlibcDetailPage(goodsId); - jumpNative(basePage); - } - - boolean isLogin = getSharedPreferences("user", MODE_PRIVATE) - .getBoolean("isLogin", false); - String msg = "璐拱鍚庢湁杩斿埄锛屽垎浜悗鏈夊閲�"; - if (!isLogin) { - msg = "鏈櫥褰曪紝鏃犺繑鍒�"; - } - if (dialog == null) { - JumpTaoBaoDialog.Builder builder1 = new JumpTaoBaoDialog.Builder(GoodsDetailActivity.this); - builder1.setMessage(msg); - builder1.setPlatform(1); - dialog = builder1.create(); - } else { - if (dialog != null && dialog.isShowing()) - dialog.dismiss(); - } - - dialog.show(); - isClick = 0; - timer();//5绉掕秴鏃跺叧闂� 寮圭獥 - } - - - private void recieveCoupon(CouponInfo couponInfo) { - if (couponInfo == null) - return; - - boolean isLogin = getSharedPreferences("user", MODE_PRIVATE) - .getBoolean("isLogin", false); - if (!isLogin) { - receiveCouponHint(couponInfo.getLink()); - } else { - if (!LoginAndInviteStatusUtil.acessNext(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", true)) - return; - if (couponInfo.isShopCoupon()) { - receiveCoupon(couponInfo.getLink()); - } else - buyOrGainCoupon(isLogin); - } - } - - /* - *棰嗗埜鎻愮ず - */ - private void commandCopyHint() { - final SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); - boolean commandHint = sp.getBoolean("receiveCouponHint", true); - if (!commandHint) { - commandCopy(); - } else { - ReceiveCouponHintDialog.Builder builder = new ReceiveCouponHintDialog.Builder(GoodsDetailActivity.this); - builder.setMessage("鏈櫥褰曟棤杩斿埄锛岀‘瀹氬厤璐归鍒革紵").setTitle("娓╅Θ鎻愮ず") - .setPositiveButton("鍘婚鍒�", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface cDialog, int which) { - cDialog.dismiss(); - SharedPreferences.Editor editor = sp.edit(); - editor.putBoolean("receiveCouponHint", false); - editor.commit(); - commandCopy(); - } - }) - .setNegativeButton("鍘荤櫥褰�", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(GoodsDetailActivity.this, LoginSelectActivity.class); - intent.putExtra("from", "娣樺疂"); - startActivity(intent); - dialog.dismiss(); - isClick = 8; - } - }).create().show(); - } - } - - private void commandCopy() { - ClipboardUtil.copy(getApplicationContext(), mInfo.getGoods().getCouponInfo().getToken()); - - Toast.makeText(GoodsDetailActivity.this, "娣樺彛浠ゅ鍒舵垚鍔�", - Toast.LENGTH_SHORT).show(); - } private void setPosition(int position) { tv_top_title1.setTextColor(position == 1 ? getResources().getColor(R.color.main_text_color) : getResources().getColor(R.color.black2)); @@ -1290,100 +913,11 @@ v_4.setVisibility(position == 4 ? View.VISIBLE : View.GONE); } - private void buyOrGainCoupon(boolean isLogin) { - isClick = 1; - isTBStartBind = false; - if (!isLogin) { - Toast.makeText(GoodsDetailActivity.this, "璇峰厛鐧诲綍鏉挎牀蹇渷璐﹀彿", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(GoodsDetailActivity.this, LoginSelectActivity.class); - intent.putExtra("from", "娣樺疂"); - startActivity(intent); - return; - } -// if (!AlibcLogin.getInstance().isLogin()) { -// tbLogin(); -// return; -// } - getTaoBaoH5AuthInfo("zigou"); -// getTBLinkInfo(getSharedPreferences("user", MODE_PRIVATE).getString("uid", "")); - } - - - /** - * 鎵撳紑鎸囧畾閾炬帴 - */ - public void showGoods() { -// Log.e("mResult", "showGoods():type---" + type); - if (TextUtils.isEmpty(goodsId)) { - Toast.makeText(GoodsDetailActivity.this, "鏆傛湭鑾峰彇鍒板晢鍝佷俊鎭�", - Toast.LENGTH_SHORT).show(); - return; - } - alibcShowParams = new AlibcShowParams(); - if (!isNative) { - alibcShowParams.setOpenType(OpenType.Auto); - } else if (ApkUtil.checkAPP(GoodsDetailActivity.this, "com.taobao.taobao")) { - alibcShowParams.setOpenType(OpenType.Native); - } else { - alibcShowParams.setOpenType(OpenType.Auto); - } - alibcShowParams.setBackUrl("alisdk://"); - alibcTaokeParams = new AlibcTaokeParams("", "", ""); - if (tInfo != null) { - alibcTaokeParams = new AlibcTaokeParams("", "", ""); - alibcTaokeParams.setPid(tInfo.getPid()); - alibcTaokeParams.setAdzoneid(tInfo.getAdZoneId()); - alibcTaokeParams.pid = tInfo.getPid(); - alibcTaokeParams.adzoneid = tInfo.getAdZoneId(); - alibcTaokeParams.extraParams = new HashMap<>(); - alibcTaokeParams.extraParams.put("taokeAppkey", tInfo.getAppKey()); - } - exParams = new HashMap<>(); - exParams.put(AlibcConstants.ISV_CODE, "appisvcode"); - exParams.put("alibaba", "闃块噷宸村反");//鑷畾涔夊弬鏁伴儴鍒嗭紝鍙换鎰忓鍒犳敼 - - if (type == 1) { -// Log.e("mResult", (!StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl); - if (!StringUtils.isEmpty(clickUrl) || !StringUtils.isEmpty(couponUrl)) { - String url = (!StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl; - jumpWeb(url); - } - } else { - if (!StringUtils.isEmpty(clickUrl) || !StringUtils.isEmpty(couponUrl)) { - String url = (!StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl; - jumpWeb(url); - } else { - Toast.makeText(GoodsDetailActivity.this, "杩涘叆璇︽儏", Toast.LENGTH_LONG).show(); - AlibcDetailPage basePage = new AlibcDetailPage(goodsId); -// AlibcTrade.openByBizCode(GoodsDetailActivity.this, basePage, alibcShowParams, alibcTaokeParams, exParams, new MiDuoTradeCallback("")); - jumpNative(basePage); - } - } - boolean isLogin = getSharedPreferences("user", MODE_PRIVATE) - .getBoolean("isLogin", false); - String msg = "璐拱鍚庢湁杩斿埄锛屽垎浜悗鏈夊閲�"; - if (!isLogin) { - msg = "鏈櫥褰曪紝鏃犺繑鍒�"; - } - if (dialog == null) { - JumpTaoBaoDialog.Builder builder = new JumpTaoBaoDialog.Builder(GoodsDetailActivity.this); - builder.setPlatform(1).setMessage(msg); - dialog = builder.create(); - } else { - if (dialog != null && dialog.isShowing()) - dialog.dismiss(); - } - - dialog.show(); - isClick = 0; - timer();//5绉掕秴鏃跺叧闂� 寮圭獥 - } - /** * 涓昏鏄敤浜� 寮圭獥鎷夎捣娣樺疂寮圭獥鍗℃寤舵椂鍏抽棴 5绉掕秴鏃� */ - private void timer() { + private void startTimer() { new Thread(new Runnable() { public void run() { try { @@ -1413,43 +947,12 @@ } }; - private void getTaobaoShareLink() { - final ShapeLoadingDialog pb = new ShapeLoadingDialog.Builder(this).build(); - pb.show(); - Log.e("mResult", "getTaobaoShareLink()"); - String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0"); - ShoppingApi.createShareLink(this, uid, mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType() + "", from, null, null, new BasicTextHttpResponseHandler() { - @Override - public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { - - if (jsonObject.optString("code").equalsIgnoreCase("0")) { - JSONObject data = jsonObject.optJSONObject("data"); - SingleGoodsShareInfo shareInfo = new Gson().fromJson(data.toString(), SingleGoodsShareInfo.class); - shareInfo.setGoodsInfo(mInfo.getGoods()); - Intent intent = new Intent(GoodsDetailActivity.this, ShareGoodsImageActivity31.class); - intent.putExtra("shareInfo", shareInfo); - if (copyLink) { - ClipboardUtil.copy(getApplicationContext(), shareInfo.getCommentText()); - Toast.makeText(GoodsDetailActivity.this, "澶嶅埗鎴愬姛", Toast.LENGTH_SHORT).show(); - } else - startActivity(intent); - } - } - - @Override - public void onFinish() { - super.onFinish(); - pb.dismiss(); - } - }); - } /** * 娣诲姞鍒版敹钘� */ private void collection() { - String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0"); - ShoppingApi.collectionGoods(GoodsDetailActivity.this, goodsId, uid, isCollect ? "2" : "1", + ShoppingApi.collectionGoods(GoodsDetailActivity.this, mInfo.getGoods().getGoodsId(), UserUtil.getUid(getApplicationContext()), isCollect ? "2" : "1", mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() { @Override public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { @@ -1474,203 +977,6 @@ ll_add_collect.setEnabled(true); } }); - } - - private boolean isFirstLogin = true; - - private void tbLogin() { - final AlibcLogin alibcLogin = AlibcLogin.getInstance(); - Log.e("detail", "tbLogin--" + alibcLogin.isLogin()); - isTBStartBind = true; - alibcLogin.showLogin(new AlibcLoginCallback() { - - @Override - public void onSuccess(int i, String s, String s1) { - SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); - SharedPreferences.Editor editor = sp.edit(); - editor.putString("TrolleyTransformationLink", ""); - editor.commit(); - - - if (isClick == 4) { - startActivity(new Intent(GoodsDetailActivity.this, ShoppingTrolleyActivity.class)); - isClick = 0; - } - - bindInfo(); - } - - @Override - public void onFailure(int code, String msg) { - if (isFirstLogin) { - InitAlibcSdk.init(); - isFirstLogin = false; - } - isTBStartBind = false; - isClick = 0; - Toast.makeText(GoodsDetailActivity.this, "鐧诲綍澶辫触锛岃绋嶅�欏啀璇�", - Toast.LENGTH_LONG).show(); - MobclickAgent.reportError(GoodsDetailActivity.this, "GoodsDetailActivity---code:" + code + "---msg:" + msg); - } - }); - } - - /** - * 缁戝畾娣樺疂璐﹀彿 - * - * @param uid - */ - boolean isTBStartBind = false; - - private void bindInfo() { - if (isClick == 1 || isClick == 2) { - Log.e("detail", authLink); - if (!StringUtils.isEmpty(authLink)) { - GoodsCustomEvent.goodsDetailTaobaoAuth(GoodsDetailActivity.this, isClick == 1 ? "璐拱" : "鍒嗕韩"); - - AlibcTradeUtil.openAuthLink(GoodsDetailActivity.this, authLink); - } - isFirst = false; - } - Log.e("detail", "bindInfo--isClick---" + isClick); - isTBStartBind = false; - } - - private void bindInfo2() { - SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); - String uid = sp.getString("uid", ""); - getTBLinkInfo(uid); - isTBStartBind = false; - } - - /** - * 鏄惁闇�瑕佹窐瀹濇巿鏉� - * - * @param source - */ - String authLink; - String orderJS; - String orderUrl; - ShapeLoadingDialog pd; - - private void getTaoBaoH5AuthInfo(final String source) { - if (pd == null) - pd = new ShapeLoadingDialog.Builder(this).build(); - if (!pd.isShowing()) - pd.show(); - Log.e("detail", "getTaoBaoH5AuthInfo--" + source); - String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", null); - ShoppingApi.getTaoBaoAuthInfo(GoodsDetailActivity.this, uid, goodsId, source, true, new BasicTextHttpResponseHandler() { - @Override - public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { - if (jsonObject.optInt("code") == 0) { - isClick = source.equalsIgnoreCase("share") ? 2 - : source.equalsIgnoreCase("zigou") ? 1 : 0; - authLink = jsonObject.optJSONObject("data").getString("authLink"); - orderJS = jsonObject.optJSONObject("data").getString("orderJS"); - orderUrl = jsonObject.optJSONObject("data").getString("orderUrl"); - Log.e("detail", "authLink--" + authLink); - if (!StringUtils.isEmpty(authLink)) { - if (AlibcLogin.getInstance().isLogin()) { - bindInfo(); - } else { - tbLogin(); - } - } - pd.dismiss(); - } else if (jsonObject.optInt("code") == 1) { - if (source.equalsIgnoreCase("share")) { - getTaobaoShareLink(); - pd.dismiss(); - } else if (source.equalsIgnoreCase("zigou")) { - getTBLinkInfo(getSharedPreferences("user", MODE_PRIVATE).getString("uid", "")); - } - } else { - pd.dismiss(); - } - } - - @Override - public void onFinish() { - super.onFinish(); - isFirst = false; - } - - @Override - public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { - super.onFailure(statusCode, headers, responseString, throwable); -// SingleToast.showToast(GoodsDetailActivity.this, "璇锋眰澶辫触"); - pd.dismiss(); - Toast.makeText(GoodsDetailActivity.this, "璇锋眰澶辫触", Toast.LENGTH_SHORT).show(); - } - - }); - } - - private void getTaoBaoH5AuthInfo2(final String source) { - String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", null); - ShoppingApi.getTaoBaoAuthInfo(GoodsDetailActivity.this, uid, goodsId, source, false, new BasicTextHttpResponseHandler() { - @Override - public void onSuccessPerfect(int statusCode, Header[] headers, final JSONObject jsonObject) throws Exception { -// Log.e("mResult", "getTaoBaoH5AuthInfo2:code:" + jsonObject.optInt("code")); - if (jsonObject.optInt("code") == 1) { - if (source.equalsIgnoreCase("share")) { - getTaobaoShareLink(); - } else if (source.equalsIgnoreCase("zigou")) { -// Log.e("mResult", "getTaoBaoH5AuthInfo2():isLogin---" + AlibcLogin.getInstance().isLogin()); - if (AlibcLogin.getInstance().isLogin()) { - getTBLinkInfo(getSharedPreferences("user", MODE_PRIVATE).getString("uid", "")); - } else { - tbBuyLogin(); - } - } - } else { -// Log.e("mResult", "getTaoBaoH5AuthInfo2:" + jsonObject.optString("msg")); - runOnUiThread(new Runnable() { - @Override - public void run() { - String msg = jsonObject.optString("msg"); - if (!StringUtils.isEmpty(msg)) { -// SingleToast.showToast(GoodsDetailActivity.this, msg); - Toast.makeText(GoodsDetailActivity.this, msg, Toast.LENGTH_SHORT).show(); - } - } - }); - } - } - - @Override - public void onFinish() { - super.onFinish(); - if (source.equalsIgnoreCase("share")) { - isClick = 0; - } - isFirst = true; - } - }); - } - - private void tbBuyLogin() { - isTBStartBind = true; - AlibcLogin.getInstance().showLogin(new AlibcLoginCallback() { - - @Override - public void onSuccess(int i, String s, String s1) { - bindInfo2(); - } - - @Override - public void onFailure(int i, String s) { - isClick = 0; - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(GoodsDetailActivity.this, "鐧诲綍澶辫触锛岃绋嶅�欏啀璇�", - Toast.LENGTH_LONG).show(); - } - }); - } - }); } class ImageAdapter extends PagerAdapter { @@ -1768,32 +1074,12 @@ } - /** - * 鐧惧窛璇︽儏椤佃烦杞綉椤� - */ - private void jumpWeb(String url) { - alibcShowParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpBROWER); - AlibcTradeSDK.setTaokeParams(alibcTaokeParams); - AlibcTradeUtil.openByUrl(GoodsDetailActivity.this, - url, null, new WebViewClient(), new WebChromeClient(), - alibcShowParams, alibcTaokeParams, null); - } - - /** - * 鐧惧窛璇︽儏椤佃烦杞師鐢� - */ - private void jumpNative(AlibcBasePage basePage) { - AlibcTrade.openByBizCode(GoodsDetailActivity.this, basePage, null, - new WebViewClient(), new WebChromeClient(), "", alibcShowParams, - alibcTaokeParams, exParams, new MiDuoTradeCallback("")); - } - - private void goFanli() { goodsDetailPreEventManager.startClick(0, new GoodsDetailPreEventManager.IPreEventListener() { @Override public void onPreSuccess() { + //TODO 杩斿埄 } }); //鍒ゆ柇鏄惁鏈夊寮犲埜鎯呭喌 @@ -1804,7 +1090,7 @@ @Override public void onPreSuccess() { - showGoods(); + //TODO 璐拱 } }); } @@ -1841,7 +1127,6 @@ 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); - } } -- Gitblit v1.8.0