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;
|
import android.graphics.Color;
|
import android.graphics.Paint;
|
import android.graphics.Typeface;
|
import android.graphics.drawable.AnimationDrawable;
|
import android.os.Bundle;
|
import android.os.Handler;
|
import android.os.Message;
|
import android.provider.Settings;
|
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.ViewPager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.RecyclerView;
|
import android.text.SpannableStringBuilder;
|
import android.text.Spanned;
|
import android.text.TextUtils;
|
import android.text.style.ForegroundColorSpan;
|
import android.util.Log;
|
import android.view.Gravity;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.view.animation.AccelerateInterpolator;
|
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;
|
import android.widget.AdapterView;
|
import android.widget.BaseAdapter;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.ListView;
|
import android.widget.PopupWindow;
|
import android.widget.ProgressBar;
|
import android.widget.TextView;
|
import android.widget.Toast;
|
|
import com.alibaba.baichuan.android.trade.AlibcTrade;
|
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.app.hubert.guide.util.ScreenUtils;
|
import com.bumptech.glide.Glide;
|
import com.google.gson.Gson;
|
import com.google.gson.GsonBuilder;
|
import com.google.gson.reflect.TypeToken;
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
import com.umeng.analytics.MobclickAgent;
|
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.SystemCommon;
|
import com.wpc.library.util.common.DimenUtils;
|
import com.wpc.library.util.common.StringUtils;
|
import com.wpc.library.widget.MyGridView;
|
import com.wpc.library.widget.MyScrollView;
|
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.CouponUser;
|
import com.tejia.lijin.app.entity.FreeSingleTicket;
|
import com.tejia.lijin.app.entity.GoodsDetail;
|
import com.tejia.lijin.app.entity.PushEventData;
|
import com.tejia.lijin.app.entity.ShareUser;
|
import com.tejia.lijin.app.entity.TaoBaoGoodsBrief;
|
import com.tejia.lijin.app.entity.TbPidInfo;
|
import com.tejia.lijin.app.entity.TopMenuRightPopContent;
|
import com.tejia.lijin.app.entity.common.ImageShowEntity;
|
import com.tejia.lijin.app.entity.share.SingleGoodsShareInfo;
|
import com.tejia.lijin.app.ui.BaseActivity;
|
import com.tejia.lijin.app.ui.dialog.AddZFBInfoDialog;
|
import com.tejia.lijin.app.ui.dialog.AddZFBInfoDialog2;
|
import com.tejia.lijin.app.ui.dialog.CustomGoodsDetailBottomDialog;
|
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.invite.ShareBrowserActivity;
|
import com.tejia.lijin.app.ui.mine.ActivationInviteCodeAcitvity;
|
import com.tejia.lijin.app.ui.mine.Collect28Activity;
|
import com.tejia.lijin.app.ui.mine.FreeSingleTicketAdapter;
|
import com.tejia.lijin.app.ui.mine.MyFootmarkActivity;
|
import com.tejia.lijin.app.ui.mine.PromotionRedenvelopeActivity;
|
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.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.KeFuUtil;
|
import com.tejia.lijin.app.util.OrderTransformationLink;
|
import com.tejia.lijin.app.util.RecordImageTextVideo;
|
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.user.UserUtil;
|
|
import org.apache.http.Header;
|
import org.json.JSONObject;
|
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Timer;
|
import java.util.TimerTask;
|
|
/**
|
* 自购立减/新人免单的商品详情
|
* Created by weikou2015 on 2018/5/11.
|
* 分享爆款商品详情过渡页--可跳转手淘原生,自我网页
|
*/
|
|
public class ShareExplosionsGoodsDetailActivity extends BaseActivity implements View.OnClickListener {
|
private static int FROM_TYPE_NEWER_MIANDAN = 1;//新人免单
|
private static int FROM_TYPE_ZIGOULIJIAN = 2;//自购立减
|
private static int FROM_TYPE_OTHER = 3;//其他
|
|
//来源类型
|
int fromType = 0;
|
|
|
private ImageView iv_top_left, iv_back, iv_shop_img,
|
iv_notif_portrait, iv_imgtext_status, iv_share, iv_top_right,
|
iv_like_state, iv_add_selection_storehouse, iv_loading, iv_footermark;
|
private TextView tv_top_title1, tv_top_title2, tv_top_title3, tv_top_title4, tv_shop_name,
|
tv_shop_des, tv_shop_service, tv_shop_logistics, tv_shop_des_grade,
|
tv_shop_logistics_grade, tv_shop_service_grade, tv_notif_name, tv_notif_des, tv_shop_see;
|
private FrameLayout fl_buy, fl_back_face, fl_content;
|
private LinearLayout ll_share_gain, ll_goods_detail_transition_top,
|
ll_guess_like, ll_add_share_house, ll_add_collect, ll_labels;
|
|
//发货地,相似搜索
|
private LinearLayout ll_address_same, ll_same;
|
private TextView tv_address;
|
|
private View v_1, v_2, v_3, v_4;
|
private MyGridView gv_guess, gv_relative;
|
|
private TextView tv_goods_des;
|
private TextView tv_currunt_page;
|
private int picNum = 1;
|
private TextView tv_goods_price_before;
|
private TextView tv_sales_num;
|
private TextView tv_coupon_show;
|
private TextView tv_goods_price_coupon;
|
private TextView tv_rebate_num, tv_loading;
|
private TextView tv_coupon_num, tv_share_red_packet_num, tv_command_num;
|
private TextView tv_coupon_date, tv_share_red_packet_date;
|
private TextView tv_share_money_num, tv_buy, tv_february_share_reward;
|
private FrameLayout fl_command_copy;
|
private LinearLayout ll_coupon, ll_top_title, ll_february_share_reward, ll_command_copy, ll_no_rebate;
|
private MyScrollView lv_goods_pic;
|
private WebView webView;
|
private ViewPager vp_goods_detail;
|
private View v_cover, v_cover1, v_cover2;
|
private ConnectivityChangeHelper mChangeHelper;
|
private LinearLayout ll_no_net, ll_no_data, ll_request_failture, ll_notification, ll_loading;
|
private ImageAdapter bannerAdapter;
|
private List<String> mBanners = new ArrayList<>();
|
|
//进度条布局
|
private LinearLayout progress_share_packet_view;
|
//进度条
|
private ProgressBar progress_share_packet_num;
|
//剩余商品
|
private TextView tv_share_packet_num;
|
//自购立减 无返利
|
private TextView iv_doubt_no_rebatetxt;
|
//间隔
|
private View iv_doubt_no_rebateview;
|
private TextView tv_share_red_packet_datetxt;
|
//推广红包
|
private LinearLayout ll_share_red_packet;
|
|
String goodsId;
|
String goodsTaoBaoId;
|
private DisplayImageOptions options = new DisplayImageOptions.Builder()
|
.showImageForEmptyUri(R.drawable.ic_goods_default)
|
.showImageOnFail(R.drawable.ic_goods_default)
|
.showImageOnLoading(R.drawable.ic_goods_default)
|
.resetViewBeforeLoading(true).cacheInMemory(true)
|
.cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY)
|
.considerExifParams(true)
|
.displayer(new FadeInBitmapDisplayer(300)).build();
|
|
private Map<String, String> exParams;//yhhpass参数
|
AlibcShowParams alibcShowParams;
|
AlibcTaokeParams alibcTaokeParams;
|
private String TYPE = "taolijin_free_buy";//默认为新人免单
|
private TextView tv_notice_content;
|
private LinearLayout ll_notice;
|
private ImageView iv_close, iv_doubt;
|
AVLoadingIndicatorView avLoadingIndicatorView;
|
|
Animation inAnima;
|
Animation outAnima;
|
|
int index = 1;
|
ListView lv_share_des;
|
|
PopupWindow mTopRightPopupWindow;
|
private List<TopMenuRightPopContent> mulList = new ArrayList<>();
|
TopMenuRightPopContentAdapter shareFromAdapter;
|
private Toast_Dialog toast_dialog;
|
|
boolean isScroll = false;
|
boolean isVisible = false;
|
|
private ShapeLoadingDialog shapeLoadingDialog;
|
|
/**
|
* 初始化界面
|
*/
|
private void initView() {
|
//自购立减
|
tv_share_red_packet_datetxt = findViewById(R.id.tv_share_red_packet_datetxt);
|
iv_doubt_no_rebateview = findViewById(R.id.iv_doubt_no_rebateview);
|
iv_doubt_no_rebatetxt = findViewById(R.id.iv_doubt_no_rebatetxt);
|
progress_share_packet_view = findViewById(R.id.progress_share_packet_view);
|
progress_share_packet_num = findViewById(R.id.progress_share_packet_num);
|
tv_share_packet_num = findViewById(R.id.tv_share_packet_num);
|
ll_share_red_packet = findViewById(R.id.ll_share_red_packet);
|
lv_goods_pic = 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_top_title4 = findViewById(R.id.tv_top_title4);
|
iv_like_state = findViewById(R.id.iv_like_state);
|
ll_add_collect = findViewById(R.id.ll_add_collect);
|
ll_labels = findViewById(R.id.ll_labels);
|
iv_add_selection_storehouse = findViewById(R.id.iv_add_selection_storehouse);
|
ll_add_share_house = findViewById(R.id.ll_add_share_house);
|
tv_share_money_num = findViewById(R.id.tv_share_money_num);
|
tv_buy = findViewById(R.id.tv_buy);
|
tv_february_share_reward = findViewById(R.id.tv_february_share_reward);
|
ll_top_title = findViewById(R.id.ll_top_title);
|
iv_shop_img = findViewById(R.id.iv_shop_img);
|
tv_shop_see = findViewById(R.id.tv_shop_see);
|
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_logistics = findViewById(R.id.tv_shop_logistics);
|
tv_shop_des_grade = findViewById(R.id.tv_shop_des_grade);
|
tv_shop_logistics_grade = findViewById(R.id.tv_shop_logistics_grade);
|
tv_shop_service_grade = findViewById(R.id.tv_shop_service_grade);
|
iv_footermark = findViewById(R.id.iv_footermark);
|
// iv_like = findViewById(R.id.iv_like);
|
v_cover = findViewById(R.id.v_cover);
|
v_cover1 = findViewById(R.id.v_cover1);
|
v_cover2 = findViewById(R.id.v_cover2);
|
ll_goods_detail_transition_top = findViewById(R.id.ll_goods_detail_transition_top);
|
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_share_gain = findViewById(R.id.ll_share_gain);
|
ll_guess_like = findViewById(R.id.ll_guess_like);
|
fl_buy = findViewById(R.id.fl_buy);
|
ll_february_share_reward = findViewById(R.id.ll_february_share_reward);
|
iv_imgtext_status = findViewById(R.id.iv_imgtext_status);
|
iv_share = findViewById(R.id.iv_share);
|
iv_top_right = findViewById(R.id.iv_top_bar_right);
|
|
//页面底部按钮
|
ll_no_rebate = findViewById(R.id.ll_no_rebate);
|
|
|
ll_loading = findViewById(R.id.ll_loading);
|
tv_loading = findViewById(R.id.tv_loading);
|
iv_loading = findViewById(R.id.iv_loading);
|
tv_loading.setText("宝贝详情页加载中...");
|
ll_loading.setVisibility(View.VISIBLE);
|
AnimationDrawable animationDrawable = (AnimationDrawable) getResources().getDrawable(
|
R.drawable.anim_list_loading);
|
iv_loading.setImageDrawable(animationDrawable);
|
animationDrawable.start();
|
|
webView = findViewById(R.id.webView);
|
webView.setWebViewClient(new MWebviewClient());
|
WebSettings settings = webView.getSettings();
|
settings.setJavaScriptEnabled(true);
|
webView.setInitialScale(100);
|
|
avLoadingIndicatorView.setVisibility(View.VISIBLE);
|
Animation ani = AnimationUtils.loadAnimation(this, R.anim.touming); //申明一个动画
|
avLoadingIndicatorView.setAnimation(ani);//为图片绑定动画
|
vp_goods_detail = findViewById(R.id.vp_goods_img);
|
tv_currunt_page = findViewById(R.id.tv_page_num);
|
tv_goods_price_before = findViewById(R.id.tv_goods_price_before);
|
tv_sales_num = findViewById(R.id.tv_sales_num);
|
tv_coupon_show = findViewById(R.id.tv_coupon_show);
|
tv_goods_price_coupon = findViewById(R.id.tv_goods_price_coupon);
|
tv_rebate_num = findViewById(R.id.tv_rebate_num);
|
tv_coupon_num = findViewById(R.id.tv_coupon_num);
|
tv_share_red_packet_num = findViewById(R.id.tv_share_red_packet_num);
|
tv_command_num = findViewById(R.id.tv_command_num);
|
tv_coupon_date = findViewById(R.id.tv_coupon_date);
|
tv_share_red_packet_date = findViewById(R.id.tv_share_red_packet_date);
|
tv_currunt_page = findViewById(R.id.tv_page_num);
|
tv_currunt_page = findViewById(R.id.tv_page_num);
|
tv_currunt_page = findViewById(R.id.tv_page_num);
|
fl_command_copy = findViewById(R.id.fl_command_copy);
|
ll_coupon = findViewById(R.id.ll_coupon);
|
ll_command_copy = findViewById(R.id.ll_command_copy);
|
gv_relative = findViewById(R.id.gv_relative);
|
gv_guess = findViewById(R.id.gv_guess_like);
|
fl_back_face = findViewById(R.id.fl_back_face);
|
findViewById(R.id.fl_face).setVisibility(View.VISIBLE);
|
iv_notif_portrait = findViewById(R.id.iv_notif_portrait);
|
tv_notif_name = findViewById(R.id.tv_notif_name);
|
tv_notif_des = findViewById(R.id.tv_notif_des);
|
lv_share_des = findViewById(R.id.lv_share_des);
|
lv_share_des.setClickable(false);
|
|
//发货地,相似搜索
|
ll_address_same = findViewById(R.id.ll_address_same);
|
ll_same = findViewById(R.id.ll_same);
|
tv_address = findViewById(R.id.tv_address);
|
|
bannerAdapter = new ImageAdapter(mBanners, this);
|
vp_goods_detail.setAdapter(bannerAdapter);
|
vp_goods_detail.setCurrentItem(0, true);
|
|
iv_top_left = findViewById(R.id.iv_top_bar_left1);
|
iv_back = findViewById(R.id.iv_back);
|
tv_goods_des = findViewById(R.id.tv_goods_des);
|
goodsId = getIntent().getExtras().getString("id");
|
rAdapter = new RelativeGoodsAdapter(this, rList, "相关推荐");
|
gv_relative.setAdapter(rAdapter);
|
gAdapter = new RelativeGoodsAdapter(this, gList, "猜你喜欢");
|
gv_guess.setAdapter(gAdapter);
|
ll_notification = findViewById(R.id.ll_notification);
|
inAnima = AnimationUtils.loadAnimation(this, R.anim.goods_detail_notify_input);
|
outAnima = AnimationUtils
|
.loadAnimation(this, R.anim.goods_detail_notify_out);
|
// ll_notification.startAnimation(inAnima);
|
// inAnima.start();
|
inAnima.setAnimationListener(new Animation.AnimationListener() {
|
@Override
|
public void onAnimationStart(Animation animation) {
|
if (couponUsers != null && couponUsers.size() > 0) {
|
CouponUser info = couponUsers.get(0);
|
ll_notification.setVisibility(View.VISIBLE);
|
Glide.with(ShareExplosionsGoodsDetailActivity.this).load(info.getPicUrl())
|
.placeholder(R.drawable.ic_default_portrait_light).error(R.drawable.ic_default_portrait_light)
|
.transform(new GlideCircleTransform(ShareExplosionsGoodsDetailActivity.this)).into(iv_notif_portrait);
|
|
tv_notif_name.setText(info.getName());//info.getName()
|
tv_notif_des.setText(info.getMsg());
|
}
|
}
|
|
@Override
|
public void onAnimationEnd(Animation animation) {
|
ll_notification.postDelayed(new Runnable() {
|
@Override
|
public void run() {
|
handler.sendEmptyMessage(0);
|
}
|
}, 3000);
|
}
|
|
@Override
|
public void onAnimationRepeat(Animation animation) {
|
|
}
|
});
|
outAnima.setAnimationListener(new Animation.AnimationListener() {
|
@Override
|
public void onAnimationStart(Animation animation) {
|
ll_notification.setVisibility(View.VISIBLE);
|
}
|
|
@Override
|
public void onAnimationEnd(Animation animation) {
|
ll_notification.setVisibility(View.GONE);
|
if (couponUsers.size() > 0)
|
couponUsers.remove(0);
|
if (couponUsers.size() > 0) {
|
ll_notification.postDelayed(new Runnable() {
|
@Override
|
public void run() {
|
handler.sendEmptyMessage(1);
|
}
|
}, 1000);
|
}
|
|
}
|
|
@Override
|
public void onAnimationRepeat(Animation animation) {
|
|
}
|
});
|
|
tv_notice_content = findViewById(R.id.tv_notice_content);
|
ll_notice = findViewById(R.id.ll_notice);
|
iv_close = findViewById(R.id.iv_close);
|
iv_doubt = findViewById(R.id.iv_doubt);
|
getAppPageNotification();
|
|
fl_content = findViewById(R.id.fl_content);
|
ll_no_net = findViewById(R.id.ll_no_net);
|
ll_no_data = findViewById(R.id.ll_no_data);
|
ll_request_failture = findViewById(R.id.ll_request_failture);
|
}
|
|
private void initListener() {
|
findViewById(R.id.tv_net_setting).setOnClickListener(this);
|
findViewById(R.id.tv_refresh).setOnClickListener(this);
|
findViewById(R.id.fl_goods_detail).setOnClickListener(this);
|
|
iv_top_left.setOnClickListener(this);
|
iv_back.setOnClickListener(this);
|
tv_top_title1.setOnClickListener(this);
|
tv_top_title2.setOnClickListener(this);
|
tv_top_title3.setOnClickListener(this);
|
tv_top_title4.setOnClickListener(this);
|
ll_add_collect.setOnClickListener(this);
|
ll_add_share_house.setOnClickListener(this);
|
ll_share_gain.setOnClickListener(this);
|
fl_back_face.setOnClickListener(this);
|
fl_buy.setOnClickListener(this);
|
iv_footermark.setOnClickListener(this);
|
// iv_like.setOnClickListener(this);
|
ll_top_title.setVisibility(View.GONE);
|
iv_share.setOnClickListener(this);
|
iv_top_right.setOnClickListener(this);
|
tv_shop_see.setOnClickListener(this);
|
fl_command_copy.setOnClickListener(this);
|
iv_doubt.setOnClickListener(this);
|
v_cover2.setOnClickListener(this);
|
findViewById(R.id.iv_doubt_no_rebate).setOnClickListener(this);
|
//相似搜索点击
|
ll_same.setOnClickListener(this);
|
|
mChangeHelper = new ConnectivityChangeHelper(this,
|
new ConnectivityChangeHelper.OnConnectivityChangeListener() {
|
|
@Override
|
public void onNetworkUnAvailable() {
|
if (mInfo == null)
|
requestState(3);
|
}
|
|
@Override
|
public void onNetworkAvailable() {
|
requestState(0);
|
if (mInfo == null) {
|
getGoodsDetail();
|
|
}
|
}
|
});
|
if (getSharedPreferences("user", MODE_PRIVATE).getString("is_goods_web_detail", "0").equalsIgnoreCase("1")) {
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, GoodsDetailBrowerActivity.class);
|
intent.putExtra("id", goodsId);
|
startActivity(intent);
|
finish();
|
}
|
|
vp_goods_detail.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
@Override
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
}
|
|
@Override
|
public void onPageSelected(int position) {
|
tv_currunt_page.setText((position + 1) + "/" + picNum);
|
}
|
|
@Override
|
public void onPageScrollStateChanged(int state) {
|
|
}
|
});
|
|
lv_goods_pic.setOnScrollListener(new MyScrollView.OnScrollListener() {
|
@Override
|
public void onScroll(int scrollY) {
|
int titleHeight = DimenUtils.dip2px(ShareExplosionsGoodsDetailActivity.this, 48);
|
int marginTopHeight = DimenUtils.dip2px(ShareExplosionsGoodsDetailActivity.this, 8);
|
if (scrollY < (ll_goods_detail_transition_top.getHeight() - titleHeight * 2)) {//头部
|
setPosition(1);
|
} else if (scrollY >= ll_goods_detail_transition_top.getHeight() - titleHeight * 2
|
&& scrollY < (ll_goods_detail_transition_top.getHeight() + webView.getHeight() - titleHeight)) {//详情图片
|
setPosition(2);
|
} else if (scrollY >= (ll_goods_detail_transition_top.getHeight()
|
+ webView.getHeight() - titleHeight + marginTopHeight) && scrollY < (ll_goods_detail_transition_top.getHeight()
|
+ webView.getHeight() + ll_guess_like.getHeight() - titleHeight + marginTopHeight)) {//猜你喜欢
|
setPosition(3);
|
} else if (scrollY >= (ll_goods_detail_transition_top.getHeight() + webView.getHeight()
|
+ ll_guess_like.getHeight() - titleHeight + marginTopHeight)) {//推荐
|
setPosition(4);
|
}
|
float baseHeight = ll_goods_detail_transition_top.getHeight() / 4;
|
if (scrollY >= 1
|
&& scrollY < baseHeight) {
|
if (scrollY / baseHeight < 0.1) {
|
ll_top_title.setVisibility(View.GONE);
|
iv_back.setVisibility(View.VISIBLE);
|
} else if (baseHeight / scrollY < 0.1) {
|
ll_top_title.setVisibility(View.VISIBLE);
|
iv_back.setVisibility(View.GONE);
|
} else {
|
ll_top_title.setVisibility(View.VISIBLE);
|
iv_back.setVisibility(View.VISIBLE);
|
}
|
ll_top_title.setAlpha(scrollY / baseHeight);
|
iv_back.setAlpha(baseHeight / scrollY);
|
|
isScroll = true;
|
Log.i("mResult", "沿Y轴滑动的距离" + scrollY);
|
} else if (scrollY > baseHeight) {
|
ll_top_title.setVisibility(View.VISIBLE);
|
iv_back.setVisibility(View.GONE);
|
ll_top_title.setAlpha(1.0f);
|
isScroll = true;
|
} else if (scrollY < 1) {
|
ll_top_title.setVisibility(View.GONE);
|
iv_back.setVisibility(View.VISIBLE);
|
iv_back.setAlpha(1.0f);
|
}
|
}
|
});
|
|
gv_relative.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
@Override
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
TaoBaoGoodsBrief info = (TaoBaoGoodsBrief) adapterView.getAdapter().getItem(position);
|
goodsId = info.getGoodsId();
|
getGoodsDetail();
|
}
|
});
|
gv_guess.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
@Override
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
TaoBaoGoodsBrief info = (TaoBaoGoodsBrief) adapterView.getAdapter().getItem(position);
|
goodsId = info.getGoodsId();
|
getGoodsDetail();
|
}
|
});
|
|
try {
|
ll_share_gain.setVisibility(from.equalsIgnoreCase("miandan") ? View.INVISIBLE : View.VISIBLE);
|
// iv_doubt.setVisibility(from.equalsIgnoreCase("miandan") ? View.INVISIBLE : View.VISIBLE);
|
} catch (NullPointerException e) {
|
e.printStackTrace();
|
}
|
initTopRightPopupWindow();
|
toast_dialog = new Toast_Dialog(this);
|
tv_goods_des.setOnLongClickListener(new View.OnLongClickListener() {
|
@Override
|
public boolean onLongClick(View v) {
|
if (tv_goods_des.getText() != null && !StringUtils.isEmpty(tv_goods_des.getText().toString())) {
|
String str1 = tv_goods_des.getText().toString();
|
String substr1 = str1.replaceFirst("## ", "");
|
ClipboardUtil.copy(getApplicationContext(),substr1);
|
// SingleToast.showToast(ll_novice.getContext(), "复制成功");
|
|
toast_dialog.MyDialog("标题复制成功", false);
|
}
|
return false;
|
}
|
});
|
tv_buy.postDelayed(new Runnable() {
|
@Override
|
public void run() {
|
if ((!isDestroyed()) && isVisible && isScroll) {
|
PushEventData info = new PushEventData();
|
info.setGoodsId(goodsId);
|
info.setGoodsType("2");
|
Gson gson = new GsonBuilder().serializeNulls().create();
|
String data = gson.toJson(info);
|
}
|
}
|
}, 15 * 1000);
|
}
|
|
@Override
|
protected void onCreate(Bundle arg0) {
|
super.onCreate(arg0);
|
setContentView(R.layout.activity_share_explosions_goods_detail);
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
from = getIntent().getStringExtra("from");
|
if (StringUtils.isEmpty(from))
|
from = "";
|
if (from.equalsIgnoreCase("zigoulijian")) {
|
fromType = FROM_TYPE_ZIGOULIJIAN;
|
TYPE = "tlj_buy";
|
} else if (from.equalsIgnoreCase("taolijin_free_buy")) {
|
TYPE = "taolijin_free_buy";
|
fromType = FROM_TYPE_NEWER_MIANDAN;
|
}
|
GoodsCustomEvent.goodsDetail(this, from);
|
initView();
|
initListener();
|
}
|
|
/**
|
* 初始化新人免单
|
*/
|
private void initNewerMianDan() {
|
//底部按钮初始化
|
ll_no_rebate.setVisibility(View.GONE);
|
findViewById(R.id.iv_doubt_no_rebatetxt).setVisibility(View.GONE);
|
findViewById(R.id.iv_doubt_no_rebate).setVisibility(View.GONE);
|
ll_share_gain.setVisibility(View.GONE);
|
iv_doubt.setVisibility(View.GONE);
|
fl_buy.setVisibility(View.VISIBLE);
|
|
if (mInfo != null && mInfo.getGoods() != null)
|
if (mInfo.getGoods().isHasCoupon())
|
tv_buy.setText("点击领券0元购");
|
else
|
tv_buy.setText("点击0元购");
|
else
|
tv_buy.setText("点击领券0元购");
|
iv_doubt_no_rebateview.setVisibility(View.GONE);
|
//券后价/福利价-价格类型初始化
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) fl_buy.getLayoutParams();
|
params.setMargins(DimenUtils.dip2px(this, 25), 0, DimenUtils.dip2px(this, 25), 0);
|
fl_buy.requestLayout();
|
//隐藏进度条
|
progress_share_packet_view.setVisibility(View.GONE);
|
}
|
|
/**
|
* 初始化右上角提示
|
*/
|
private void initTopRightPopupWindow() {
|
View view = getLayoutInflater().inflate(R.layout.item_share_from_filter,
|
null, false);
|
// 创建PopupWindow实例,200,150分别是宽度和高度
|
mTopRightPopupWindow = new PopupWindow(view, (int) (SystemCommon.getScreenWidth(this) / 2), ViewGroup.LayoutParams.WRAP_CONTENT, true);
|
// 设置动画效果 [R.style.AnimationFade 是自己事先定义好的]
|
// pw_filter.setAnimationStyle(R.style.pop_multiple);
|
mTopRightPopupWindow.setTouchable(true);
|
mTopRightPopupWindow.setOutsideTouchable(false);
|
mTopRightPopupWindow.setFocusable(false);
|
ListView lv = view.findViewById(R.id.lv_filter_pw);
|
// mulList.add(new TopMenuRightPopContent("复制链接", R.drawable.ic_goods_detail_copy_link));
|
mulList.add(new TopMenuRightPopContent("帮助中心", R.drawable.ic_goods_detail_help_center));
|
mulList.add(new TopMenuRightPopContent("新手攻略", R.drawable.ic_goods_detail_novice));
|
mulList.add(new TopMenuRightPopContent("联系客服", R.drawable.ic_goods_detail_contact_kefu));
|
mulList.add(new TopMenuRightPopContent("我要吐槽", R.drawable.ic_goods_detail_criticism));
|
shareFromAdapter = new TopMenuRightPopContentAdapter(this, mulList);
|
lv.setAdapter(shareFromAdapter);
|
|
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
@Override
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
mTopRightPopupWindow.dismiss();
|
v_cover.setVisibility(View.GONE);
|
GoodsCustomEvent.goodsDetailMoreBtn(ShareExplosionsGoodsDetailActivity.this, mulList.get(position).getName());
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
// if (position == 0) {
|
// ClipboardManager manager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
// ClipData myClip = ClipData.newPlainText("text", h5Url);
|
// manager.setPrimaryClip(myClip);
|
// Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "链接复制成功", Toast.LENGTH_LONG).show();
|
// } else
|
|
if (position == 0) {
|
Intent intent1 = new Intent(ShareExplosionsGoodsDetailActivity.this, ShareBrowserActivity.class);
|
intent1.putExtra("title", "帮助中心");
|
intent1.putExtra("url", sp.getString("help", ""));
|
startActivity(intent1);
|
} else if (position == 1) {
|
RecordImageTextVideo textVideo = new RecordImageTextVideo(ShareExplosionsGoodsDetailActivity.this);
|
String url = textVideo.getvideoMoreUrl();
|
if (StringUtils.isEmpty(url)) {
|
url = textVideo.gettxtImgUtl();
|
}
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", url);
|
startActivity(intent);
|
} else if (position == 2) {
|
// startActivity(new Intent(GoodsDetailActivityTB.this, ContactUsActivity.class));
|
KeFuUtil.jumpKeFu(ShareExplosionsGoodsDetailActivity.this, "商品详情");
|
} else if (position == 3) {
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.this, GoComplainActivity.class));
|
}
|
}
|
});
|
mTopRightPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
@Override
|
public void onDismiss() {
|
v_cover2.setVisibility(View.GONE);
|
}
|
});
|
}
|
|
Handler handler = new Handler() {
|
@Override
|
public void handleMessage(Message msg) {
|
super.handleMessage(msg);
|
if (msg.what == 0) {
|
outAnima.setInterpolator(new AccelerateInterpolator());
|
ll_notification.setAnimation(outAnima);
|
ll_notification.startAnimation(outAnima);
|
} else if (msg.what == 1) {
|
inAnima.setInterpolator(new DecelerateInterpolator());
|
ll_notification.setAnimation(inAnima);
|
ll_notification.startAnimation(inAnima);
|
// inAnima.start();
|
} else if (msg.what == 2) {
|
lv_share_des.setSelection(0);
|
}
|
}
|
};
|
|
|
class MWebviewClient extends WebViewClient {
|
@Override
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
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, url);
|
}
|
|
@Override
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
super.onPageStarted(view, url, favicon);
|
webView.postDelayed(new Runnable() {
|
@Override
|
public void run() {
|
ll_loading.setVisibility(View.GONE);
|
}
|
}, 3000);
|
}
|
}
|
|
private void getAppPageNotification() {
|
ShoppingApi.getAppPageNotification(this, TYPE, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optInt("code") == 0) {
|
boolean isClose = jsonObject.optJSONObject("data").optBoolean("canClose");
|
String content = jsonObject.optJSONObject("data").optString("content");
|
final String contentUrl = jsonObject.optJSONObject("data").optString("contentUrl");
|
final String md5 = jsonObject.optJSONObject("data").optString("md5");
|
|
tv_notice_content.setText(content);
|
final SharedPreferences sp = getSharedPreferences("notice", Context.MODE_PRIVATE);
|
if (!sp.getBoolean(md5, false)) {//false 展示,true不展示
|
ll_notice.setVisibility(View.VISIBLE);
|
} else {
|
ll_notice.setVisibility(View.GONE);
|
}
|
|
if (isClose) {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_close));
|
iv_close.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
ll_notice.setVisibility(View.GONE);
|
SharedPreferences.Editor editor = sp.edit();
|
editor.putBoolean(md5, true);
|
editor.commit();
|
}
|
});
|
} else {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_input));
|
}
|
ll_notice.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", contentUrl);
|
startActivity(intent);
|
}
|
});
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
if (!isQuestDetail && avLoadingIndicatorView.isShown())
|
avLoadingIndicatorView.hide();
|
}
|
});
|
}
|
|
|
GoodsDetail mInfo;
|
boolean isNative = true;
|
TbPidInfo tInfo;
|
List<CouponUser> couponUsers;
|
List<ShareUser> sList;
|
ShareExampleAdapter shareAdapter;
|
// ProgressDialog pd;
|
String from;
|
String noRebateHelpLink;
|
String userHongbao;//用户剩余红包
|
boolean isQuestDetail;
|
|
private void getGoodsDetail() {
|
isQuestDetail = true;
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.getGoodsInfoTB(this, goodsId, uid, 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(ShareExplosionsGoodsDetailActivity.this, 50);
|
lv_goods_pic.setLayoutParams(params);
|
findViewById(R.id.fl_face).setVisibility(View.GONE);
|
findViewById(R.id.ll_goods_nothing).setVisibility(View.GONE);
|
fl_content.setVisibility(View.VISIBLE);
|
|
Gson gson = new GsonBuilder().serializeNulls().create();
|
mInfo = gson.fromJson(jsonObject.optJSONObject("data").toString(), GoodsDetail.class);
|
getGoodsRecommend();
|
|
userHongbao = StringUtils.isEmpty(mInfo.getExtra().getUserTLJ())
|
? "0" : mInfo.getExtra().getUserTLJ();
|
h5Url = mInfo.getExtra().getH5Url();//产品h5 链接
|
couponUsers = mInfo.getExtra().getListCouponUser();
|
sList = mInfo.getExtra().getListShareUser();
|
noRebateHelpLink = mInfo.getExtra().getShare().getHelpLink();
|
|
if (mInfo.getGoods().getLabels() != null && mInfo.getGoods().getLabels().size() > 0)
|
SetLabels.addLabel(ShareExplosionsGoodsDetailActivity.this, ll_labels, mInfo.getGoods().getLabels());
|
|
if (sList.size() <= 0) {
|
lv_share_des.setVisibility(View.GONE);
|
} else {
|
lv_share_des.setVisibility(View.VISIBLE);
|
}
|
shareAdapter = new ShareExampleAdapter(sList);
|
lv_share_des.setAdapter(shareAdapter);
|
if (timer != null) {
|
timer.cancel();
|
timer = null;
|
index = 1;
|
}
|
startTimer(sList.size());
|
|
goodsTaoBaoId = mInfo.getGoods().getGoodsId();
|
isCollect = mInfo.getExtra().isCollected();
|
|
JSONObject object = jsonObject.optJSONObject("data").optJSONObject("ticket");
|
if (object != null) {
|
clickUrl = object.optString("clickUrl");
|
couponUrl = object.optString("couponUrl");
|
}
|
|
if (couponUsers != null && couponUsers.size() > 0) {
|
inAnima.setInterpolator(new DecelerateInterpolator());
|
ll_notification.setAnimation(inAnima);
|
ll_notification.startAnimation(inAnima);
|
}
|
ImageUtil.showImageFace(ShareExplosionsGoodsDetailActivity.this, mInfo.getGoods().getTitle(), mInfo.getGoods().getShopType(), tv_goods_des);
|
tv_goods_price_before.setText(mInfo.getGoods().getPriceName() + " ¥" + mInfo.getGoods().getZkPrice());
|
webView.loadUrl(mInfo.getExtra().getDetailUrl());
|
tv_sales_num.setText("月销 " + mInfo.getGoods().getSalesCount());
|
if (mInfo.getGoods().getMoneyInfo().getMoneyType() == 1) {
|
tv_rebate_num.setText(" 返" + mInfo.getGoods().getMoneyInfo().getFanliMoney());
|
tv_rebate_num.setBackgroundResource(R.drawable.shape_red_goods_detail_corner);
|
tv_rebate_num.setTextColor(getResources().getColor(R.color.main_text_color));
|
} else {
|
//当from 为:taolijin_buy 隐藏奖金
|
if (from.equalsIgnoreCase("taolijin_buy")) {
|
tv_rebate_num.setVisibility(View.GONE);
|
} else {
|
tv_rebate_num.setVisibility(View.VISIBLE);
|
tv_rebate_num.setText(" 奖" + mInfo.getGoods().getMoneyInfo().getFanliMoney());
|
}
|
tv_rebate_num.setBackgroundResource(R.drawable.shape_goods_list_price_reward);
|
tv_rebate_num.setTextColor(getResources().getColor(R.color.orange4));
|
}
|
|
ll_february_share_reward.setVisibility(!mInfo.getExtra().isShareValid() ? View.GONE : View.VISIBLE);
|
tv_share_money_num.setText(jsonObject.optJSONObject("data").optString("shareMoney"));
|
if (mInfo.getExtra().isShareValid()) {
|
tv_february_share_reward.setText(mInfo.getGoods().getMoneyInfo().getShareMoney());
|
tv_share_money_num.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
|
} else {
|
ll_february_share_reward.setVisibility(View.GONE);
|
}
|
|
//发货地设置
|
if (!StringUtils.isBlank(mInfo.getGoods().getProvCity())) {
|
ll_address_same.setVisibility(View.VISIBLE);
|
tv_address.setText(mInfo.getGoods().getProvCity());
|
}
|
|
Glide.with(ShareExplosionsGoodsDetailActivity.this)
|
.load(mInfo.getGoods().getShopInfo().getShopIcon())
|
.placeholder(R.drawable.ic_goods_default)
|
.error(R.drawable.ic_goods_default)
|
.transform(new GlideRoundTransform(ShareExplosionsGoodsDetailActivity.this,
|
5)).into(iv_shop_img);
|
tv_shop_name.setText(mInfo.getGoods().getShopInfo().getShopName());
|
|
tv_shop_des.setText("宝贝描述: " + mInfo.getGoods().getShopInfo().getScoreGoods());
|
tv_shop_service.setText("卖家服务: " + mInfo.getGoods().getShopInfo().getScoreSeller());
|
tv_shop_logistics.setText("物流服务: " + mInfo.getGoods().getShopInfo().getScoreLogistics());
|
tv_shop_des_grade.setText(mInfo.getGoods().getShopInfo().getScoreGoodsD() == 0 ? "低" :
|
mInfo.getGoods().getShopInfo().getScoreGoodsD() == 1 ? "平" : "高");
|
tv_shop_service_grade.setText(mInfo.getGoods().getShopInfo().getScoreSellerD() == 0 ? "低" :
|
mInfo.getGoods().getShopInfo().getScoreSellerD() == 1 ? "平" : "高");
|
tv_shop_logistics_grade.setText(mInfo.getGoods().getShopInfo()
|
.getScoreLogisticsD() == 0 ? "低" :
|
mInfo.getGoods().getShopInfo().getScoreLogisticsD() == 1 ? "平" : "高");
|
|
if (isCollect) {
|
iv_like_state.setImageResource(R.drawable.ic_like_goods_detail_light);
|
} else {
|
iv_like_state.setImageResource(R.drawable.ic_like_goods_detail);
|
}
|
if (mInfo.getExtra().isStorage()) {
|
iv_add_selection_storehouse.setImageResource(R.drawable
|
.ic_add_selection_storehouse_select);
|
} else {
|
iv_add_selection_storehouse.setImageResource(R.drawable
|
.ic_add_selection_storehouse_unselect);
|
}
|
|
if (mInfo.getGoods().isHasCoupon()) {
|
if (StringUtils.isEmpty(mInfo.getGoods().getCouponInfo().getToken())) {
|
ll_command_copy.setVisibility(View.GONE);
|
} else {
|
// ll_command_copy.setVisibility(View.VISIBLE);
|
tv_command_num.setText(mInfo.getGoods().getCouponInfo().getToken());
|
}
|
tv_buy.setText("领券返利");
|
|
if (from.equalsIgnoreCase("miandan")) {
|
// ll_command_copy.setVisibility(View.GONE);
|
ll_coupon.setVisibility(View.GONE);
|
tv_coupon_show.setVisibility(View.GONE);
|
setLl_couponGone();
|
}
|
tv_coupon_num.setText("¥ " + mInfo.getGoods().getCouponInfo().getAmount());
|
if (!StringUtils.isEmpty(mInfo.getGoods().getCouponInfo().getStartTime()))
|
tv_coupon_date.setText("使用期限:" + mInfo.getGoods().getCouponInfo().getStartTime()
|
+ "-" + mInfo.getGoods().getCouponInfo().getEndTime());
|
tv_goods_price_coupon.setText(mInfo.getGoods().getCouponPrice());
|
} else {
|
ll_command_copy.setVisibility(View.GONE);
|
tv_buy.setText("立即购买");
|
tv_coupon_show.setVisibility(View.GONE);
|
ll_coupon.setVisibility(View.GONE);
|
tv_goods_price_coupon.setText(mInfo.getGoods().getZkPrice());
|
setLl_couponGone();
|
}
|
|
ll_no_rebate.setVisibility(mInfo.getExtra().isFanliValid()
|
? View.GONE : View.VISIBLE);
|
findViewById(R.id.iv_doubt_no_rebate).setVisibility(mInfo.getExtra().isFanliValid()
|
? View.GONE : View.VISIBLE);
|
fl_buy.setVisibility(mInfo.getExtra().isFanliValid() ? View.VISIBLE : View.GONE);
|
// tv_rebate_num.setVisibility(mInfo.isFanliValid() ? View.VISIBLE : View.GONE);
|
|
Log.i("mResult", "isLike的值为" + mInfo.getGoods().getGoodsId());
|
|
picNum = mInfo.getGoods().getImgList().size();
|
tv_currunt_page.setText("1/" + picNum);
|
mBanners.clear();
|
mBanners.addAll(mInfo.getGoods().getImgList());
|
bannerAdapter.notifyDataSetChanged();
|
vp_goods_detail.setCurrentItem(0);
|
isNative = Boolean.parseBoolean(jsonObject.optJSONObject("data")
|
.optString("native"));
|
requestState(0);
|
|
//自购立减
|
if (mInfo.getGoods().getOtherInfo() != null &&
|
mInfo.getGoods().getOtherInfo().getReduceHongBao() != null) {
|
//显示进度条
|
progress_share_packet_view.setVisibility(View.VISIBLE);
|
BigDecimal apply = new BigDecimal(mInfo.getGoods().getOtherInfo().getReduceHongBao().getTotal()
|
- mInfo.getGoods().getOtherInfo().getReduceHongBao().getLeft());
|
BigDecimal total = new BigDecimal(mInfo.getGoods().getOtherInfo().getReduceHongBao().getTotal());
|
BigDecimal scale = apply.divide(total, 2, RoundingMode.HALF_UP);
|
BigDecimal value = scale.multiply(new BigDecimal(100));
|
progress_share_packet_num.setProgress(value.intValue());
|
tv_share_packet_num.setText("余 " + mInfo.getGoods().getOtherInfo().getReduceHongBao().getLeft());
|
|
tv_share_red_packet_num.setText("¥" + mInfo.getGoods().getOtherInfo().getReduceHongBao().getMoney());
|
tv_share_red_packet_date.setText(mInfo.getGoods().getOtherInfo().getReduceHongBao().getTip());
|
ll_share_gain.setVisibility(View.GONE);
|
fl_buy.setVisibility(View.VISIBLE);
|
tv_buy.setText("立即购买");
|
iv_doubt_no_rebatetxt.setVisibility(View.VISIBLE);
|
findViewById(R.id.iv_doubt_no_rebate).setVisibility(View.VISIBLE);
|
iv_doubt_no_rebateview.setVisibility(View.VISIBLE);
|
tv_share_red_packet_datetxt.setText(mInfo.getGoods().getOtherInfo().getReduceHongBao().getName());
|
} else {
|
tv_share_red_packet_num.setText("¥ " + mInfo.getGoods().getOtherInfo().getSpreadHongBao().getMoney());
|
tv_share_red_packet_date.setText(mInfo.getGoods().getOtherInfo().getSpreadHongBao().getTip());
|
progress_share_packet_view.setVisibility(View.GONE);
|
}
|
//shareValid=false fanliValid=true 隐藏分享 显示立即购买
|
|
|
} else if (jsonObject.optString("code").equalsIgnoreCase("2")) {
|
fl_content.setVisibility(View.GONE);
|
findViewById(R.id.ll_goods_nothing).setVisibility(View.VISIBLE);
|
findViewById(R.id.fl_face).setVisibility(View.VISIBLE);
|
}
|
|
//TODO 判断新人免单
|
initNewerMianDan();
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
if (NetUtils.getNetworkState(ShareExplosionsGoodsDetailActivity.this).equalsIgnoreCase(NetUtils.NETWORK_NONE)) {
|
requestState(3);
|
} else {
|
requestState(2);
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
lv_goods_pic.scrollTo(0, 0);
|
if (avLoadingIndicatorView.isShown())
|
avLoadingIndicatorView.hide();
|
}
|
|
});
|
}
|
|
/**
|
* 没有券的 情况
|
*/
|
private void setLl_couponGone() {
|
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll_share_red_packet.getLayoutParams();
|
lp.topMargin = ScreenUtils.dp2px(ShareExplosionsGoodsDetailActivity.this, 25);
|
ll_share_red_packet.setLayoutParams(lp);//(lp);
|
}
|
|
Timer timer;
|
|
/**
|
* 启动分享提示栏timer
|
*/
|
private void startTimer(final int length) {
|
timer = new Timer();
|
timer.schedule(new TimerTask() {
|
@Override
|
public void run() {
|
if (index <= length) {
|
lv_share_des.smoothScrollBy(DimenUtils.dip2px(ShareExplosionsGoodsDetailActivity.this, 62), 1000);
|
index++;
|
} else {
|
index = 1;
|
handler.sendEmptyMessage(2);
|
}
|
}
|
}, 2000, 3000);
|
}
|
|
private void getGoodsRecommend() {
|
ShoppingApi.getGuessAndRecommend(this, goodsId, mInfo.getGoods().getGoodsType() + "", 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) {
|
rList.addAll(list2);
|
rAdapter.notifyDataSetChanged();
|
}
|
|
if (gList.size() == 0) {
|
findViewById(R.id.fl_top_title3).setVisibility(View.GONE);
|
ll_guess_like.setVisibility(View.GONE);
|
}
|
if (rList.size() == 0) {
|
findViewById(R.id.fl_top_title4).setVisibility(View.GONE);
|
findViewById(R.id.ll_relative_goods).setVisibility(View.GONE);
|
}
|
}
|
}
|
|
});
|
}
|
|
JumpTaoBaoDialog dialog;
|
boolean isFirst = true;
|
|
@Override
|
protected void onResume() {
|
super.onResume();
|
isVisible = true;
|
mChangeHelper.registerReceiver();
|
// vp_goods_detail.postDelayed(mAutoScroller, 5000);
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
boolean isLogin = sp.getBoolean("isLogin", false);
|
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(ShareExplosionsGoodsDetailActivity.this, "暂未获取到分享返利,请稍等", Toast.LENGTH_LONG).show();
|
isClick = 0;
|
}
|
|
} else if (isClick == 3) {
|
if (isCollect) {
|
iv_like_state.setImageResource(R.drawable.ic_like_goods_detail_light);
|
} else {
|
collection();
|
}
|
isClick = 0;
|
} else if (isClick == 4) {
|
if (AlibcLogin.getInstance().isLogin()) {
|
isClick = 0;
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.this, ShoppingTrolleyActivity.class));
|
}
|
// else {
|
// tbLogin();
|
// }
|
} else if (isClick == 5) {
|
isClick = 0;
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.this, Collect28Activity.class));
|
} else if (isClick == 7) {
|
if (isCollect) {
|
iv_like_state.setImageResource(R.drawable.ic_add_selection_storehouse_select);
|
} else {
|
addSelectionStorehouse();
|
}
|
isClick = 0;
|
} else if (isClick == 8) {//复制淘口令
|
commandCopy();
|
isClick = 0;
|
}
|
}
|
|
if (dialog != null && dialog.isShowing())
|
dialog.dismiss();
|
}
|
|
@Override
|
protected void onPause() {
|
super.onPause();
|
isVisible = false;
|
mChangeHelper.unregisterReceiver();
|
timer();
|
}
|
|
|
String clickUrl = "";
|
String couponUrl = "";
|
private String h5Url = "";//产品链接
|
int type = 0;
|
|
/**
|
* 获取PID 信息
|
*/
|
private void getTBLinkInfo(String uid) {
|
|
if (shapeLoadingDialog == null) {
|
shapeLoadingDialog = new ShapeLoadingDialog.Builder(this).build();
|
}
|
if (!shapeLoadingDialog.isShowing())
|
shapeLoadingDialog.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 (type == 2)
|
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());
|
if ((!StringUtils.isEmpty(from)) && from.equalsIgnoreCase("miandan")) {
|
getGoodsCouponList();
|
} else {
|
goBuy();
|
}
|
} else {
|
isClick = 0;
|
if (fromType == FROM_TYPE_NEWER_MIANDAN && jsonObject.optInt("code") == 1001) {
|
AddZFBInfoDialog2.Builder builder = new AddZFBInfoDialog2.Builder(ShareExplosionsGoodsDetailActivity.this);
|
builder.setTitle("温馨提示").setMessage(jsonObject.optString("msg")).setMessageTextAligin(AddZFBInfoDialog2.Builder.TEXT_ALIGIN_MIDDLE)
|
.setPositiveButton("知道了", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).setNegativeButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
dialog.dismiss();
|
}
|
}).create().show();
|
} else if (fromType == FROM_TYPE_NEWER_MIANDAN && jsonObject.optInt("code") == 1002) {
|
AddZFBInfoDialog2.Builder builder = new AddZFBInfoDialog2.Builder(ShareExplosionsGoodsDetailActivity.this);
|
builder.setTitle("温馨提示").setMessage(jsonObject.optString("msg")).setMessageTextAligin(AddZFBInfoDialog2.Builder.TEXT_ALIGIN_MIDDLE)
|
.setPositiveButton("去激活", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
//去激活
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.this, ActivationInviteCodeAcitvity.class));
|
}
|
}).setNegativeButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
dialog.dismiss();
|
}
|
}).create().show();
|
|
} else {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this,
|
jsonObject.optString("msg"), Toast.LENGTH_LONG).show();
|
}
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
if (shapeLoadingDialog.isShowing())
|
shapeLoadingDialog.dismiss();
|
}
|
});
|
}
|
|
private boolean isCollect = false;
|
private int isClick = 0;
|
private boolean isSpread = false;//图文是否展开
|
|
List<TaoBaoGoodsBrief> gList = new ArrayList<>();
|
RelativeGoodsAdapter gAdapter;
|
List<TaoBaoGoodsBrief> rList = new ArrayList<>();
|
RelativeGoodsAdapter rAdapter;
|
long lastShareTimeClick = 0;
|
long lastBuyTimeClick = 0;
|
|
@Override
|
public void onClick(View v) {
|
int titleHeight = DimenUtils.dip2px(ShareExplosionsGoodsDetailActivity.this, 48);
|
int marginTopHeight = DimenUtils.dip2px(ShareExplosionsGoodsDetailActivity.this, 8);
|
boolean isLogin = getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false);
|
switch (v.getId()) {
|
case R.id.iv_back:
|
finish();
|
break;
|
case R.id.iv_top_bar_left1:
|
finish();
|
break;
|
case R.id.iv_share:
|
case R.id.iv_top_bar_right:
|
if (mTopRightPopupWindow.isShowing()) {
|
mTopRightPopupWindow.dismiss();
|
} else {
|
v_cover2.setVisibility(View.VISIBLE);
|
mTopRightPopupWindow.showAsDropDown(iv_share);
|
}
|
break;
|
case R.id.v_cover2:
|
mTopRightPopupWindow.dismiss();
|
break;
|
case R.id.tv_top_title1:
|
lv_goods_pic.scrollTo(0, 0);
|
setPosition(1);
|
break;
|
case R.id.tv_top_title2:
|
lv_goods_pic.scrollTo(0, ll_goods_detail_transition_top.getHeight() - titleHeight * 2);
|
setPosition(2);
|
break;
|
case R.id.tv_top_title3:
|
lv_goods_pic.scrollTo(0, ll_goods_detail_transition_top.getHeight() + webView.getHeight() - titleHeight + marginTopHeight);
|
setPosition(3);
|
break;
|
case R.id.tv_top_title4:
|
lv_goods_pic.scrollTo(0, ll_goods_detail_transition_top.getHeight() + webView.getHeight() + ll_guess_like.getHeight() - titleHeight + marginTopHeight);
|
setPosition(4);
|
break;
|
case R.id.ll_add_share_house:
|
ll_add_share_house.setEnabled(false);
|
if (mInfo == null) {
|
// SingleToast.showToast(GoodsDetailActivityTB.this, "没有获取到商品收藏状态,请稍等!");
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "没有获取到商品收藏状态,请稍等", Toast.LENGTH_SHORT).show();
|
ll_add_share_house.setEnabled(true);
|
break;
|
}
|
if (isLogin) {
|
addSelectionStorehouse();
|
} else {
|
ll_add_share_house.setEnabled(true);
|
isClick = 7;
|
UserUtil.jumpLogin(ShareExplosionsGoodsDetailActivity.this);
|
}
|
break;
|
case R.id.ll_add_collect:
|
ll_add_collect.setEnabled(false);
|
if (mInfo == null) {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "没有获取到商品收藏状态,请稍等", Toast.LENGTH_SHORT).show();
|
ll_add_collect.setEnabled(true);
|
break;
|
}
|
if (isLogin) {
|
collection();
|
} else {
|
ll_add_collect.setEnabled(true);
|
isClick = 3;
|
UserUtil.jumpLogin(ShareExplosionsGoodsDetailActivity.this);
|
}
|
break;
|
//分享奖金
|
case R.id.ll_share_gain:
|
long cTime = System.currentTimeMillis();
|
if (cTime - lastShareTimeClick < 500) {
|
lastShareTimeClick = cTime;
|
break;
|
}
|
lastShareTimeClick = cTime;
|
isTBStartBind = false;
|
GoodsCustomEvent.goodsDetailShare(ShareExplosionsGoodsDetailActivity.this);
|
if (isLogin) {
|
if (mInfo != null) {
|
getTaoBaoH5AuthInfo("share");
|
} else {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "暂未获取到分享返利,请稍等", Toast.LENGTH_LONG).show();
|
}
|
} else {
|
isClick = 2;
|
UserUtil.jumpLogin(ShareExplosionsGoodsDetailActivity.this);
|
}
|
break;
|
// case R.id.fl_receive_coupon:
|
// long cTime1 = System.currentTimeMillis();
|
// if (cTime1 - lastBuyTimeClick < 500) {
|
// lastBuyTimeClick = cTime1;
|
// break;
|
// }
|
// lastBuyTimeClick = cTime1;
|
// GoodsCustomEvent.goodsDetailCouponClick(this);
|
// if (invalid)
|
// break;
|
// if (!isLogin) {
|
// receiveCouponHint();
|
// } else {
|
// buyOrGainCoupon(isLogin);
|
// }
|
// break;
|
case R.id.fl_buy:
|
long cTime2 = System.currentTimeMillis();
|
if (cTime2 - lastBuyTimeClick < 500) {
|
lastBuyTimeClick = cTime2;
|
break;
|
}
|
lastBuyTimeClick = cTime2;
|
GoodsCustomEvent.goodsDetailBuyCommon(this);
|
buyOrGainCoupon(isLogin);
|
|
break;
|
case R.id.fl_back_face:
|
finish();
|
break;
|
case R.id.tv_net_setting:
|
startActivity(new Intent(Settings.ACTION_SETTINGS));
|
break;
|
case R.id.tv_refresh:
|
startActivity(new Intent(Settings.ACTION_SETTINGS));
|
break;
|
// case R.id.fl_goods_detail:
|
// 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;
|
case R.id.tv_shop_see:
|
GoodsCustomEvent.goodsDetailShopDetail(ShareExplosionsGoodsDetailActivity.this);
|
if (mInfo != null && (!StringUtils.isEmpty(mInfo.getGoods().getShopInfo().getShopLink()))) {
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", mInfo.getGoods().getShopInfo().getShopLink());
|
intent.putExtra("title", mInfo.getGoods().getShopInfo().getShopName());
|
startActivity(intent);
|
}
|
PushEventData info = new PushEventData();
|
info.setShopUrl(mInfo.getGoods().getShopInfo().getShopLink());
|
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_doubt: {
|
AddZFBInfoDialog.Builder builder = new AddZFBInfoDialog.Builder(ShareExplosionsGoodsDetailActivity.this);
|
builder.setTitle("分享奖金").setMessage("1.分享给好友他能免费领隐藏优惠券,你也能获得推广奖励;\n\n" +
|
"2.为了让分享奖金安全进入到你的账户,此处必须登录;\n\n" +
|
"3.登录后选择图文和链接分享也可保存分享图至本地相册。\n")
|
.setPositiveButton("知道了", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialogInterface, int i) {
|
dialogInterface.dismiss();
|
}
|
}).create().show();
|
break;
|
}
|
|
case R.id.iv_doubt_no_rebate: {
|
if (!StringUtils.isEmpty(noRebateHelpLink)) {
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", noRebateHelpLink);
|
// intent.putExtra("title", "推广红包如何使用?");
|
startActivity(intent);
|
}
|
break;
|
}
|
|
case R.id.iv_footermark:
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.this, MyFootmarkActivity.class));
|
break;
|
|
case R.id.ll_same:
|
Intent intent = new Intent(this, SearchResultActivity.class);
|
intent.putExtra("content", mInfo.getGoods().getTitle());
|
startActivity(intent);
|
break;
|
}
|
}
|
|
/*
|
*领券提示
|
*/
|
private void commandCopyHint() {
|
final SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
boolean commandHint = sp.getBoolean("receiveCouponHint", true);
|
commandHint=false;
|
if (!commandHint) {
|
commandCopy();
|
} else {
|
ReceiveCouponHintDialog.Builder builder = new ReceiveCouponHintDialog.Builder(ShareExplosionsGoodsDetailActivity.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) {
|
UserUtil.jumpLogin(ShareExplosionsGoodsDetailActivity.this);
|
dialog.dismiss();
|
isClick = 8;
|
}
|
}).create().show();
|
}
|
}
|
|
private void commandCopy() {
|
ClipboardUtil.copy(getApplicationContext(), mInfo.getGoods().getCouponInfo().getToken());
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "淘口令复制成功",
|
Toast.LENGTH_SHORT).show();
|
}
|
|
private void setPosition(int position) {
|
tv_top_title1.setTextColor(position == 1 ? getResources().getColor(R.color.theme) : getResources().getColor(R.color.black2));
|
tv_top_title1.setTypeface(position == 1 ? Typeface.defaultFromStyle(Typeface.BOLD) : Typeface.defaultFromStyle(Typeface.NORMAL));
|
v_1.setVisibility(position == 1 ? View.VISIBLE : View.GONE);
|
tv_top_title2.setTextColor(position == 2 ? getResources().getColor(R.color.theme) : getResources().getColor(R.color.black2));
|
tv_top_title2.setTypeface(position == 2 ? Typeface.defaultFromStyle(Typeface.BOLD) : Typeface.defaultFromStyle(Typeface.NORMAL));
|
v_2.setVisibility(position == 2 ? View.VISIBLE : View.GONE);
|
tv_top_title3.setTextColor(position == 3 ? getResources().getColor(R.color.theme) : getResources().getColor(R.color.black2));
|
tv_top_title3.setTypeface(position == 3 ? Typeface.defaultFromStyle(Typeface.BOLD) : Typeface.defaultFromStyle(Typeface.NORMAL));
|
v_3.setVisibility(position == 3 ? View.VISIBLE : View.GONE);
|
tv_top_title4.setTextColor(position == 4 ? getResources().getColor(R.color.theme) : getResources().getColor(R.color.black2));
|
tv_top_title4.setTypeface(position == 4 ? Typeface.defaultFromStyle(Typeface.BOLD) : Typeface.defaultFromStyle(Typeface.NORMAL));
|
v_4.setVisibility(position == 4 ? View.VISIBLE : View.GONE);
|
}
|
|
private void buyOrGainCoupon(boolean isLogin) {
|
isClick = 1;
|
isTBStartBind = false;
|
if (!isLogin) {
|
UserUtil.jumpLogin(ShareExplosionsGoodsDetailActivity.this);
|
return;
|
}
|
// if (!AlibcLogin.getInstance().isLogin()) {
|
// tbLogin();
|
// return;
|
// }
|
getTaoBaoH5AuthInfo("zigou");
|
// getTBLinkInfo(getSharedPreferences("user", MODE_PRIVATE).getString("uid", ""));
|
}
|
|
private void goBuy() {
|
Log.e("mResult", "goBuy():type---" + type);
|
Log.e("mResult", "isNative:" + isNative);
|
isClick = 0;
|
if (mInfo != null) {
|
GoodsCustomEvent.goodsDetailBuyToTaobao(ShareExplosionsGoodsDetailActivity.this, mInfo.getGoods().isHasCoupon() ? "有券" : "无券");
|
if (mInfo.getGoods().isHasCoupon()) {
|
mInfo.getGoods().getCouponInfo().setLink(couponUrl);
|
}
|
showGoods();
|
}
|
}
|
|
/**
|
* 打开指定链接
|
*/
|
public void showGoods() {
|
// Log.e("mResult", "showGoods():type---" + type);
|
if (TextUtils.isEmpty(goodsId)) {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "暂未获取到商品信息",
|
Toast.LENGTH_SHORT).show();
|
return;
|
}
|
|
alibcShowParams = new AlibcShowParams();
|
if (!isNative) {
|
alibcShowParams.setOpenType(OpenType.Auto);
|
} else if (ApkUtil.checkAPP(ShareExplosionsGoodsDetailActivity.this, "com.taobao.taobao")) {
|
alibcShowParams.setOpenType(OpenType.Native);
|
} else {
|
alibcShowParams.setOpenType(OpenType.Auto);
|
}
|
alibcTaokeParams = new AlibcTaokeParams("", "", "");
|
alibcTaokeParams.setPid(BuXinConstant.BAICHUAN_PID);
|
exParams = new HashMap<>();
|
exParams.put(AlibcConstants.ISV_CODE, "appisvcode");
|
exParams.put("alibaba", "阿里巴巴");//自定义参数部分,可任意增删改
|
|
if (type == 1) {
|
if (!StringUtils.isEmpty(clickUrl) || !StringUtils.isEmpty(couponUrl)) {
|
String url = (!StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl;
|
jumpWeb(url);
|
}
|
} else {
|
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());
|
|
if (!StringUtils.isEmpty(clickUrl) || !StringUtils.isEmpty(couponUrl)) {
|
String url = (!StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl;
|
jumpWeb(url);
|
} else {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "进入详情", Toast.LENGTH_LONG).show();
|
AlibcDetailPage basePage = new AlibcDetailPage(goodsId);
|
jumpNoLink(basePage);
|
}
|
}
|
showJumpDialog();
|
}
|
|
private void showJumpDialog() {
|
boolean isLogin = getSharedPreferences("user", MODE_PRIVATE)
|
.getBoolean("isLogin", false);
|
String msg = "购买后有返利,分享后有奖金";
|
if (!isLogin) {
|
msg = "未登录,无返利";
|
}
|
if (dialog == null) {
|
JumpTaoBaoDialog.Builder builder = new JumpTaoBaoDialog.Builder(ShareExplosionsGoodsDetailActivity.this);
|
builder.setPlatform(1).setMessage(msg);
|
builder.setMessage("");
|
dialog = builder.create();
|
} else {
|
dialog.dismiss();
|
}
|
dialog.show();
|
Log.e("mResult", "dialog开始展示了");
|
isClick = 0;
|
timer();
|
}
|
|
/**
|
* 主要是用于 弹窗拉起淘宝弹窗卡死延时关闭 5秒超时
|
*/
|
private void timer() {
|
new Thread(new Runnable() {
|
public void run() {
|
try {
|
Thread.sleep(5000);
|
handler1.sendEmptyMessage(0);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
}
|
}).start();
|
}
|
|
Handler handler1 = new Handler() {
|
@Override
|
public void handleMessage(Message msg) {
|
super.handleMessage(msg);
|
if (dialog != null) {
|
if (dialog.isShowing()) {
|
dialog.dismiss();
|
} else {
|
dialog.cancel();
|
dialog = null;
|
}
|
} else {
|
dialog = null;
|
}
|
}
|
};
|
|
private void getTaobaoShareLink(String num) {
|
final ShapeLoadingDialog pb = new ShapeLoadingDialog.Builder(this).build();
|
pb.show();
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.createShareLink(this, uid, mInfo.getGoods().getGoodsId(), mInfo.getGoods().getGoodsType() + "", from, num, 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(ShareExplosionsGoodsDetailActivity.this, ShareGoodsImageActivity31.class);
|
intent.putExtra("shareInfo", shareInfo);
|
startActivity(intent);
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
pb.dismiss();
|
}
|
});
|
}
|
|
/**
|
* 添加到收藏
|
*/
|
private void collection() {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.collectionGoods(ShareExplosionsGoodsDetailActivity.this, goodsId, uid, isCollect ? "2" : "1", mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
isCollect = !isCollect;
|
if (isCollect) {
|
GoodsCustomEvent.goodsDetailCollect(ShareExplosionsGoodsDetailActivity.this);
|
iv_like_state.setImageResource(R.drawable.ic_like_goods_detail_light);
|
} else {
|
GoodsCustomEvent.goodsDetailCollectCancel(ShareExplosionsGoodsDetailActivity.this);
|
iv_like_state.setImageResource(R.drawable.ic_like_goods_detail);
|
}
|
// SingleToast.showToast(GoodsDetailActivityTB.this, jsonObject.optString("data"));
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, jsonObject.optString("data"), Toast.LENGTH_SHORT).show();
|
} else {
|
// SingleToast.showToast(GoodsDetailActivityTB.this, jsonObject.optString("msg"));
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
ll_add_collect.setEnabled(true);
|
}
|
});
|
}
|
|
/**
|
* 添加到分享库
|
*/
|
private void addSelectionStorehouse() {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "0");
|
ShoppingApi.addSelectionStoreHouse(ShareExplosionsGoodsDetailActivity.this, goodsId, uid, mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
String hint;
|
if (jsonObject.optJSONObject("data").optBoolean("storageState")) {
|
iv_add_selection_storehouse.setImageResource(R.drawable.ic_add_selection_storehouse_select);
|
hint = "添加至分享库成功";
|
GoodsCustomEvent.goodsDetailXpk(ShareExplosionsGoodsDetailActivity.this);
|
} else {
|
iv_add_selection_storehouse.setImageResource(R.drawable.ic_add_selection_storehouse_unselect);
|
hint = "已从分享库中删除";
|
GoodsCustomEvent.goodsDetailXpkCancel(ShareExplosionsGoodsDetailActivity.this);
|
}
|
// SingleToast.showToast(GoodsDetailActivityTB.this, hint);
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, hint, Toast.LENGTH_SHORT).show();
|
} else {
|
// SingleToast.showToast(GoodsDetailActivityTB.this, jsonObject.optString("msg"));
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show();
|
}
|
}
|
|
@Override
|
public void
|
onFinish() {
|
super.onFinish();
|
ll_add_share_house.setEnabled(true);
|
}
|
});
|
}
|
|
private boolean isFirstLogin = true;
|
|
private void tbLogin() {
|
final AlibcLogin alibcLogin = AlibcLogin.getInstance();
|
Log.e("detail", "tbLogin--" + alibcLogin.isLogin());
|
// if (!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();
|
// boolean isLogin = sp.getBoolean("isLogin", false);
|
// if (isLogin) {
|
// if (AlibcLogin.getInstance().isLogin()) {
|
// TrolleyTransformationLink transformationLink = new TrolleyTransformationLink(ShareExplosionsGoodsDetailActivity.this);
|
// transformationLink.getTaoBaoCartConfig("login");
|
// }
|
// }
|
if (isClick == 4) {
|
startActivity(new Intent(ShareExplosionsGoodsDetailActivity.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(ShareExplosionsGoodsDetailActivity.this, "登录失败,请稍候再试",
|
Toast.LENGTH_LONG).show();
|
MobclickAgent.reportError(ShareExplosionsGoodsDetailActivity.this, "GoodsDetailActivityTB---code:" + code + "---msg:" + msg);
|
}
|
});
|
// }
|
}
|
|
/**
|
* 绑定淘宝账号
|
*
|
* @param uid
|
*/
|
boolean isTBStartBind = false;
|
|
private void bindInfo() {
|
OrderTransformationLink order = new OrderTransformationLink(ShareExplosionsGoodsDetailActivity.this, orderJS, orderUrl);
|
order.showOrder();
|
if (isClick == 1 || isClick == 2) {
|
Log.e("detail", authLink);
|
if (!StringUtils.isEmpty(authLink)) {
|
GoodsCustomEvent.goodsDetailTaobaoAuth(ShareExplosionsGoodsDetailActivity.this, isClick == 1 ? "购买" : "分享");
|
// Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, BrowserActivity.class);
|
// intent.putExtra("url", authLink);
|
// startActivity(intent);
|
// AlibcTrade.openByUrl(ShareExplosionsGoodsDetailActivity.this, "", authLink, webView, new WebViewClient(),
|
// new WebChromeClient(), alibcShowParams, alibcTaokeParams, exParams,
|
// new MiDuoTradeCallback(""));
|
|
// AlibcTradeUtil.openByUrl(ShareExplosionsGoodsDetailActivity.this, authLink, webView, new WebViewClient(),
|
// new WebChromeClient(), alibcShowParams, alibcTaokeParams, null);
|
|
AlibcTradeUtil.openAuthLink(ShareExplosionsGoodsDetailActivity.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;
|
|
private void getTaoBaoH5AuthInfo(final String source) {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", null);
|
ShoppingApi.getTaoBaoAuthInfo(ShareExplosionsGoodsDetailActivity.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");
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
Log.e("detail", "authLink--" + authLink);
|
if (!StringUtils.isEmpty(authLink)) {
|
if (AlibcLogin.getInstance().isLogin()) {
|
bindInfo();
|
} else {
|
tbLogin();
|
}
|
}
|
} else if (jsonObject.optInt("code") == 1) {
|
if (source.equalsIgnoreCase("share")) {
|
CustomGoodsDetailBottomDialog.Builder builder = new
|
CustomGoodsDetailBottomDialog.Builder(ShareExplosionsGoodsDetailActivity.this);
|
builder.setInfo(mInfo.getGoods()).setSurplus(userHongbao)
|
.setNegativeButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, PromotionRedenvelopeActivity.class);
|
startActivity(intent);
|
}
|
}).setPositiveButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
getTaobaoShareLink(which + "");
|
dialog.dismiss();
|
}
|
}).create().show();
|
// getTaobaoShareLink();
|
} else if (source.equalsIgnoreCase("zigou")) {
|
getTBLinkInfo(getSharedPreferences("user", MODE_PRIVATE).getString("uid", ""));
|
}
|
}
|
}
|
|
@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(GoodsDetailActivityTB.this, "请求失败");
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "请求失败", Toast.LENGTH_SHORT).show();
|
}
|
|
});
|
}
|
|
private void getTaoBaoH5AuthInfo2(final String source) {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", null);
|
ShoppingApi.getTaoBaoAuthInfo(ShareExplosionsGoodsDetailActivity.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(null);
|
} 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(GoodsDetailActivityTB.this, msg);
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.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;
|
// Log.e("mResult", "开始登录");
|
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;
|
// Log.e("mResult", "登录失败");
|
runOnUiThread(new Runnable() {
|
@Override
|
public void run() {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this, "登录失败,请稍候再试",
|
Toast.LENGTH_LONG).show();
|
}
|
});
|
}
|
});
|
}
|
|
class ImageAdapter extends PagerAdapter {
|
|
private List<String> cList;
|
|
public ImageAdapter(List<String> list, Context context) {
|
super();
|
this.cList = list;
|
}
|
|
@Override
|
public int getCount() {
|
return cList == null ? 0 : cList.size();
|
}
|
|
@Override
|
public Object instantiateItem(ViewGroup container, final int position) {
|
View view = LayoutInflater.from(ShareExplosionsGoodsDetailActivity.this)
|
.inflate(R.layout.item_goods_detail_top_img, null);
|
ImageView iv = view.findViewById(R.id.iv_goods_img);
|
// Glide.with(mContext).load(cList.get(position)).error(R.drawable.ic_goods_default).placeholder(R.drawable.ic_goods_default).into(iv);
|
ImageLoader.getInstance().displayImage(cList.get(position), iv, options);//暂时注释
|
iv.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
GoodsCustomEvent.goodsDetailDetailImgs(ShareExplosionsGoodsDetailActivity.this);
|
enlargeImage(position, cList);
|
}
|
});
|
container.addView(view);
|
return view;
|
}
|
|
@Override
|
public void destroyItem(ViewGroup container, int position, Object object) {
|
container.removeView((View) object);
|
}
|
|
@Override
|
public boolean isViewFromObject(View view, Object object) {
|
return view == object;
|
}
|
|
@Override
|
public CharSequence getPageTitle(int position) {
|
return cList.get(position) + "";
|
}
|
|
private void enlargeImage(int position, final List<String> list) {
|
ArrayList<String> cList = (ArrayList<String>) list;
|
Intent intent = new Intent(ShareExplosionsGoodsDetailActivity.this, BigImageActivity.class);
|
intent.putExtra("position", position);
|
intent.putExtra("imgList",new Gson().toJson(ImageShowEntity.create(cList)));
|
startActivityForResult(intent, 0);
|
// v_cover.setVisibility(View.VISIBLE);
|
// //透明动画
|
// ObjectAnimator animator = ObjectAnimator.ofFloat(v_cover, "alpha", 0F, 1F);
|
// animator.setDuration(150);//400
|
// //为动画设置监听
|
// animator.addListener(new AnimatorListenerAdapter() {
|
// @Override
|
// public void onAnimationEnd(Animator animation) {
|
// super.onAnimationEnd(animation);
|
// v_cover.setVisibility(View.GONE);
|
// }
|
// });
|
// animator.start();
|
}
|
}
|
|
/**
|
* 请求状态 0 数据正常展示;1 返回数据为空;2 网络请求失败;3 没有连接网络
|
*
|
* @param state
|
*/
|
private void requestState(int state) {
|
fl_content.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);
|
}
|
|
class ShareExampleAdapter extends BaseAdapter {
|
|
List<ShareUser> mList;
|
|
public ShareExampleAdapter(List<ShareUser> list) {
|
mList = list;
|
}
|
|
@Override
|
public int getCount() {
|
return mList == null ? 0 : mList.size();
|
}
|
|
@Override
|
public Object getItem(int position) {
|
return mList.get(position);
|
}
|
|
@Override
|
public long getItemId(int position) {
|
return position;
|
}
|
|
@Override
|
public View getView(int position, View view, ViewGroup parent) {
|
Holder holder = null;
|
if (view == null) {
|
holder = new Holder();
|
view = LayoutInflater.from(ShareExplosionsGoodsDetailActivity.this).inflate(R.layout.item_share_example, null);
|
holder.iv_portrait = view.findViewById(R.id.iv_portrait);
|
holder.tv_name = view.findViewById(R.id.tv_name);
|
holder.tv_des = view.findViewById(R.id.tv_des);
|
holder.iv_gift_img = view.findViewById(R.id.iv_gift_img);
|
view.setTag(holder);
|
} else {
|
holder = (Holder) view.getTag();
|
}
|
|
Glide.with(ShareExplosionsGoodsDetailActivity.this).load(mList.get(position).getPicUrl()).placeholder(R.drawable.ic_default_portrait_light)
|
.error(R.drawable.ic_default_portrait_light)
|
.transform(new GlideCircleTransform(ShareExplosionsGoodsDetailActivity.this)).into(holder.iv_portrait);
|
Glide.with(ShareExplosionsGoodsDetailActivity.this).load(mList.get(position).getShareBonusPic()).into(holder.iv_gift_img);
|
|
holder.tv_name.setText(mList.get(position).getName());
|
|
String str = mList.get(position).getMsg();
|
int count = str.indexOf("奖金");
|
SpannableStringBuilder builder = new SpannableStringBuilder(str);
|
builder.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.detail_sharelist_reward_num))
|
, count, str.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
|
holder.tv_des.setText(builder);
|
|
return view;
|
}
|
|
class Holder {
|
ImageView iv_portrait;
|
TextView tv_name;
|
TextView tv_des;
|
ImageView iv_gift_img;
|
}
|
}
|
|
|
/*
|
商品详情免单券弹框接口
|
*/
|
private void getGoodsCouponList() {
|
final ShapeLoadingDialog pd = new ShapeLoadingDialog.Builder(this).build();
|
pd.show();
|
String uid = getSharedPreferences("user", MODE_PRIVATE)
|
.getString("uid", "");
|
ShoppingApi.getGoodsCouponList(this, uid, Constant.GOODS_TYPE_TB, goodsId, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optString("code").equalsIgnoreCase("0")) {
|
initPopubWindow(jsonObject.optJSONObject("data"));
|
} else {
|
Toast.makeText(ShareExplosionsGoodsDetailActivity.this,
|
jsonObject.optString("msg"), Toast.LENGTH_LONG).show();
|
}
|
}
|
|
@Override
|
public void onFinish() {
|
super.onFinish();
|
pd.dismiss();
|
}
|
});
|
}
|
|
|
private void initPopubWindow(JSONObject jsonObject) {
|
final String helpLink = jsonObject.optString("helpLink");
|
View customView = getLayoutInflater().inflate(R.layout.item_show_free_single_coupon,
|
null, false);
|
// 创建PopupWindow实例,200,150分别是宽度和高度
|
float height = SystemCommon.getScreenHeight(this);
|
final PopupWindow pw_free_single_ticket = new PopupWindow(customView, ViewGroup.LayoutParams.MATCH_PARENT, (int) (height * 0.75), true);
|
// 设置动画效果 [R.style.AnimationFade 是自己事先定义好的]
|
// pw_filter.setAnimationStyle(R.style.pop_multiple);
|
pw_free_single_ticket.setTouchable(true);
|
pw_free_single_ticket.setOutsideTouchable(true);
|
pw_free_single_ticket.setFocusable(false);
|
pw_free_single_ticket.setAnimationStyle(R.style.bottomstyle);
|
TextView tv_free_single_coupon_num = customView.findViewById(R.id.tv_free_single_ticket_num);
|
LinearLayout ll_no_ticket = customView.findViewById(R.id.ll_no_ticket);
|
TextView tv_confirm = customView.findViewById(R.id.tv_confirm);
|
RecyclerView rv_free_single_ticket = customView.findViewById(R.id.rv_free_single_ticket);
|
|
TextView tv_limit = new TextView(this);
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
|
FrameLayout.LayoutParams.WRAP_CONTENT);
|
tv_limit.setLayoutParams(params);
|
tv_limit.setTextColor(Color.parseColor(jsonObject.optJSONObject("tip").optString("fontColor")));
|
tv_limit.setTextSize(14);
|
tv_limit.setGravity(Gravity.CENTER);
|
tv_limit.setText(jsonObject.optJSONObject("tip").optString("content"));
|
tv_limit.setPadding(0, DimenUtils.dip2px(this, 16), 0, 0);
|
tv_free_single_coupon_num.setText("剩余" + jsonObject.optString("count") + "张免单券");
|
|
LinearLayoutManager manager = new LinearLayoutManager(this);
|
rv_free_single_ticket.setLayoutManager(manager);
|
DividerItemDecoration decoration = new DividerItemDecoration();
|
decoration.setSize(DimenUtils.dip2px(this, 8));
|
rv_free_single_ticket.addItemDecoration(decoration);
|
Gson gson = new GsonBuilder().serializeNulls().create();
|
final List<FreeSingleTicket> fList = gson.fromJson(jsonObject.optJSONArray(
|
"result_list").toString(),
|
new TypeToken<List<FreeSingleTicket>>() {
|
}.getType());
|
if (fList == null || fList.size() == 0) {
|
rv_free_single_ticket.setVisibility(View.GONE);
|
ll_no_ticket.setVisibility(View.VISIBLE);
|
} else {
|
rv_free_single_ticket.setVisibility(View.VISIBLE);
|
ll_no_ticket.setVisibility(View.GONE);
|
}
|
final FreeSingleTicketAdapter adapter = new FreeSingleTicketAdapter(this, fList, helpLink);
|
rv_free_single_ticket.setAdapter(adapter);
|
adapter.addHeaderView(tv_limit);
|
tv_confirm.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
pw_free_single_ticket.dismiss();
|
v_cover1.setVisibility(View.GONE);
|
FreeSingleTicket info = null;//选中的免单券
|
for (int i = 0; i < adapter.mCBFlag.size(); i++) {
|
if (adapter.mCBFlag.get(i)) {
|
info = fList.get(i);
|
}
|
}
|
if (info != null) {
|
useFreeSingleTicket(info);
|
}
|
}
|
});
|
v_cover1.setOnClickListener(new View.OnClickListener() {//设置背景空点击事件
|
@Override
|
public void onClick(View v) {
|
v_cover1.setVisibility(View.GONE);
|
}
|
});
|
pw_free_single_ticket.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
|
v_cover1.setVisibility(View.VISIBLE);
|
isClick = 0;
|
}
|
|
/**
|
* 使用免单券
|
*
|
* @param info
|
*/
|
private void useFreeSingleTicket(FreeSingleTicket info) {
|
String uid = getSharedPreferences("user", MODE_PRIVATE).getString("uid", "");
|
ShoppingApi.useFreeSingleTicket(ShareExplosionsGoodsDetailActivity.this, uid, info.getId(), goodsId, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optInt("code") == 0) {
|
goBuy();
|
}
|
}
|
});
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
if (timer != null) {
|
timer.cancel();
|
timer = null;
|
}
|
handler1.sendEmptyMessage(0);
|
toast_dialog.dialog_dismiss();
|
}
|
|
@Override
|
protected void onNewIntent(Intent intent) {
|
super.onNewIntent(intent);
|
}
|
|
|
|
/**
|
* 百川详情页跳转网页
|
*/
|
private void jumpWeb(String url) {
|
alibcShowParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpH5);
|
// AlibcTrade.openByUrl(ShareExplosionsGoodsDetailActivity.this, "webDetail",
|
// url, null, new WebViewClient(), new WebChromeClient(),
|
// alibcShowParams, alibcTaokeParams, null, new MiDuoTradeCallback(""));
|
|
AlibcTradeUtil.openByUrl(ShareExplosionsGoodsDetailActivity.this,
|
url, null, new WebViewClient(), new WebChromeClient(),
|
alibcShowParams, alibcTaokeParams, null);
|
}
|
|
/**
|
* 百川非link跳转
|
*/
|
private void jumpNoLink(AlibcBasePage basePage) {
|
AlibcTrade.openByBizCode(ShareExplosionsGoodsDetailActivity.this, basePage, null,
|
new WebViewClient(), new WebChromeClient(), "nativeDetail", alibcShowParams,
|
alibcTaokeParams, null, new MiDuoTradeCallback(""));
|
}
|
}
|