| | |
| | | package com.tejia.lijin.app.ui.recommend; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Bitmap; |
| | |
| | | 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.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; |
| | |
| | | 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 android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.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.google.gson.reflect.TypeToken; |
| | | 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.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.dialog.ReceiveCouponHintDialog; |
| | | import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; |
| | | 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.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.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.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.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.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.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; |
| | |
| | | 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.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 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; |
| | |
| | | |
| | | //商品店铺信息 |
| | | 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 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; |
| | |
| | | |
| | | 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); |
| | |
| | | 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); |
| | | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | //umeng统计 |
| | | GoodsCustomEvent.goodsDetail(this, from); |
| | | inputTime = System.currentTimeMillis(); |
| | | goodsId = getIntent().getExtras().getString("id"); |
| | | |
| | | 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("宝贝详情页加载中..."); |
| | | AnimationDrawable animationDrawable = (AnimationDrawable) getResources().getDrawable( |
| | |
| | | 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); |
| | | } |
| | |
| | | tv_top_title4.setOnClickListener(this); |
| | | ll_add_collect.setOnClickListener(this); |
| | | fl_back_face.setOnClickListener(this); |
| | | v_cover2.setOnClickListener(this); |
| | | |
| | | ll_fanli.setOnClickListener(this); |
| | | ll_buy.setOnClickListener(this); |
| | | |
| | | if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1")) { |
| | | Intent intent = new Intent(GoodsDetailActivity.this, GoodsDetailBrowerActivity.class); |
| | |
| | | @Override |
| | | public void 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()); |
| | | } |
| | | }); |
| | | |
| | |
| | | public void onNetworkAvailable() { |
| | | requestState(0); |
| | | if (mInfo == null) { |
| | | getGoodsDetail(); |
| | | getGoodsDetail(goodsId, goodsType); |
| | | } |
| | | } |
| | | }); |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | |
| | | GoodsDetailNotifyDialog notifyDialog; |
| | | |
| | | @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)) |
| | |
| | | initView(); |
| | | initData(); |
| | | 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(); |
| | |
| | | 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 |
| | | public void onPageStarted(WebView view, String url, Bitmap favicon) { |
| | | super.onPageStarted(view, url, favicon); |
| | |
| | | } |
| | | }, 3000); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void getAppPageNotification() { |
| | |
| | | } |
| | | |
| | | |
| | | 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")) { |
| | | 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(), GoodsDetail.class); |
| | | |
| | | mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetailVO.class); |
| | | getGoodsRecommend(mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType()); |
| | | 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()); |
| | |
| | | index = 1; |
| | | } |
| | | |
| | | goodsTaoBaoId = mInfo.getGoods().getGoodsId(); |
| | | isCollect = mInfo.getExtra().isCollected(); |
| | | |
| | | if (couponUsers != null && couponUsers.size() > 0) { |
| | |
| | | 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); |
| | | 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 { |
| | | GoodsDetailUtil.fillShopType(tv_shop_type, mInfo.getGoods().getShopType()); |
| | | |
| | | 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) { |
| | | |
| | | } |
| | | } else { |
| | | ll_shop.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | if (mInfo.getExtra().isCollected()) { |
| | | setCollectionData(true); |
| | | } else { |
| | | setCollectionData(false); |
| | | } |
| | | //权益设置 |
| | | |
| | | setRightsData(mInfo.getGoods().getRights()); |
| | | |
| | | //设置价格信息 |
| | | setPriceInfo(mInfo.getGoods()); |
| | | |
| | | //发货地设置 |
| | | 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()); |
| | |
| | | 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); |
| | | 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); |
| | | } |
| | | }); |
| | | } |
| | |
| | | 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 |
| | |
| | | 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) { |
| | |
| | | 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; |
| | | |
| | | 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) { |
| | |
| | | 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); |
| | | case R.id.ll_buy: |
| | | goBuy(); |
| | | 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); |
| | | case R.id.ll_fanli: |
| | | goFanli(); |
| | | break; |
| | | |
| | | case R.id.fl_back_face: |
| | |
| | | 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; |
| | |
| | | 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)); |
| | |
| | | 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 { |
| | |
| | | } |
| | | }; |
| | | |
| | | 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 { |
| | |
| | | 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 { |
| | |
| | | * @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 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() { |
| | | |
| | | } |
| | | }); |
| | | 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() { |
| | | showGoods(); |
| | | 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); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |