| | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | import android.os.Handler; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.webkit.WebChromeClient; |
| | |
| | | import com.kepler.jd.sdk.bean.KeplerAttachParameter; |
| | | import com.tejia.lijin.app.entity.TbPidInfo; |
| | | import com.tejia.lijin.app.entity.common.GoodsConvertLinkJumpLink; |
| | | import com.tejia.lijin.app.entity.user.UserLijinLevelInfoVO; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailJumpLoaingDialog; |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.util.baichuan.AlibcTradeUtil; |
| | | import com.tejia.lijin.app.util.downutil.StringUtils; |
| | | import com.tejia.lijin.app.util.goods.GoodsBuyUtil; |
| | | import com.tejia.lijin.app.util.ui.dialog.DialogUtil; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | public class GoodsBuyJumpUtil { |
| | | |
| | | |
| | | public static void jumpTB(Activity activity, TbPidInfo tInfo, String clickUrl, String couponUrl, final GoodsBuyUtil.IBuyGoodsResultListener buyGoodsResultListener) { |
| | | public static void jumpTB(final Activity activity, final TbPidInfo tInfo, final String clickUrl, final String couponUrl, UserLijinLevelInfoVO userLevel, final GoodsBuyUtil.IBuyGoodsResultListener buyGoodsResultListener) { |
| | | |
| | | if (userLevel != null && userLevel.getUpgradeRights() != null) { |
| | | showADLoading(activity, Constant.GOODS_TYPE_TB, userLevel, new GoodsDetailJumpLoaingDialog.Builder.IDialogClose() { |
| | | @Override |
| | | public void onClose(boolean auto) { |
| | | jumpTB(activity, tInfo, clickUrl, couponUrl, buyGoodsResultListener); |
| | | } |
| | | }); |
| | | } else { |
| | | final Dialog dialog = getLoadingDialog(activity, Constant.GOODS_TYPE_TB); |
| | | jumpTB(activity, tInfo, clickUrl, couponUrl, new GoodsBuyUtil.IBuyGoodsResultListener() { |
| | | @Override |
| | | public void onConvertLinkStart() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkSuccess() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkFail(String msg) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onConvertLinkComplete() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppStart() { |
| | | DialogUtil.show(dialog); |
| | | new Handler().postDelayed(new Runnable() { |
| | | public void run() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | |
| | | }, 3 * 1000); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppSuccess() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | |
| | | @Override |
| | | public void onJumpThirdAppFail() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static void jumpTB(Activity activity, TbPidInfo tInfo, String clickUrl, String couponUrl, final GoodsBuyUtil.IBuyGoodsResultListener buyGoodsResultListener) { |
| | | AlibcShowParams alibcShowParams = new AlibcShowParams(); |
| | | alibcShowParams.setOpenType(OpenType.Auto); |
| | | alibcShowParams.setBackUrl("alisdk://"); |
| | |
| | | if (!com.wpc.library.util.common.StringUtils.isEmpty(clickUrl) || !com.wpc.library.util.common.StringUtils.isEmpty(couponUrl)) { |
| | | String url = (!com.wpc.library.util.common.StringUtils.isEmpty(couponUrl)) ? couponUrl : clickUrl; |
| | | AlibcTradeSDK.setTaokeParams(alibcTaokeParams); |
| | | if (buyGoodsResultListener != null) |
| | | buyGoodsResultListener.onJumpThirdAppStart(); |
| | | AlibcTradeUtil.openByUrl(activity, |
| | | url, null, new WebViewClient(), new WebChromeClient(), |
| | | alibcShowParams, alibcTaokeParams, null); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static void jumpPDD(Context context, GoodsConvertLinkJumpLink link) { |
| | | public static void jumpPDD(final Activity context, final GoodsConvertLinkJumpLink link, UserLijinLevelInfoVO userLevel) { |
| | | jumpPDD(context, link); |
| | | |
| | | |
| | | if (userLevel != null && userLevel.getUpgradeRights() != null) { |
| | | showADLoading(context, Constant.GOODS_TYPE_PDD, userLevel, new GoodsDetailJumpLoaingDialog.Builder.IDialogClose() { |
| | | @Override |
| | | public void onClose(boolean auto) { |
| | | jumpPDD(context, link); |
| | | } |
| | | }); |
| | | } else { |
| | | final Dialog dialog = getLoadingDialog(context, Constant.GOODS_TYPE_PDD); |
| | | DialogUtil.show(dialog); |
| | | jumpPDD(context, link); |
| | | new Handler().postDelayed(new Runnable() { |
| | | public void run() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | |
| | | }, 3 * 1000); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static void jumpPDD(Context context, GoodsConvertLinkJumpLink link) { |
| | | if (context == null) |
| | | return; |
| | | if (link == null) |
| | |
| | | if (dialog != null && dialog.isShowing()) |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void jumpJD(final Activity activity, final GoodsConvertLinkJumpLink link, UserLijinLevelInfoVO userLevel, final IJumpResult jumpResult) { |
| | | |
| | | if (userLevel != null && userLevel.getUpgradeRights() != null) { |
| | | showADLoading(activity, Constant.GOODS_TYPE_JD, userLevel, new GoodsDetailJumpLoaingDialog.Builder.IDialogClose() { |
| | | @Override |
| | | public void onClose(boolean auto) { |
| | | jumpJD(activity, link, null); |
| | | } |
| | | }); |
| | | } else { |
| | | final Dialog dialog = getLoadingDialog(activity, Constant.GOODS_TYPE_JD); |
| | | DialogUtil.show(dialog); |
| | | jumpJD(activity, link, new IJumpResult() { |
| | | @Override |
| | | public void onSuccess() { |
| | | } |
| | | |
| | | @Override |
| | | public void onFail(String msg) { |
| | | } |
| | | }); |
| | | new Handler().postDelayed(new Runnable() { |
| | | public void run() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | |
| | | }, 3 * 1000); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static void jumpJD(final Activity activity, GoodsConvertLinkJumpLink link, final IJumpResult jumpResult) { |
| | | private static void jumpJD(final Activity activity, GoodsConvertLinkJumpLink link, final IJumpResult jumpResult) { |
| | | if (link == null) |
| | | return; |
| | | |
| | |
| | | if (status == OpenAppAction.OpenAppAction_result_APP) { |
| | | //呼京东成功 |
| | | Log.e("mResult", "呼京东成功"); |
| | | if (jumpResult != null) |
| | | jumpResult.onSuccess(); |
| | | } else if (status == OpenAppAction.OpenAppAction_start) { |
| | | //开始状态未必一定执行, |
| | |
| | | intent.putExtra("url", url); |
| | | intent.putExtra("interceptGoodsDetail", false); |
| | | activity.startActivity(intent); |
| | | if (jumpResult != null) |
| | | jumpResult.onFail("唤起京东失败"); |
| | | } |
| | | } |
| | |
| | | intent.putExtra("interceptGoodsDetail", false); |
| | | activity.startActivity(intent); |
| | | } finally { |
| | | if (jumpResult != null) |
| | | jumpResult.onSuccess(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static void jumpVIPShop(Context context, GoodsConvertLinkJumpLink link) { |
| | | public static void jumpVIPShop(final Activity context, final GoodsConvertLinkJumpLink link, UserLijinLevelInfoVO userLevel) { |
| | | if (userLevel != null && userLevel.getUpgradeRights() != null) { |
| | | showADLoading(context, Constant.GOODS_TYPE_VIP, userLevel, new GoodsDetailJumpLoaingDialog.Builder.IDialogClose() { |
| | | @Override |
| | | public void onClose(boolean auto) { |
| | | jumpVIPShop(context, link); |
| | | } |
| | | }); |
| | | } else { |
| | | final Dialog dialog = getLoadingDialog(context, Constant.GOODS_TYPE_VIP); |
| | | DialogUtil.show(dialog); |
| | | jumpVIPShop(context, link); |
| | | new Handler().postDelayed(new Runnable() { |
| | | public void run() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | }, 3 * 1000); |
| | | } |
| | | } |
| | | |
| | | |
| | | private static void jumpVIPShop(Context context, GoodsConvertLinkJumpLink link) { |
| | | if (context == null) |
| | | return; |
| | | if (link == null) |
| | |
| | | } |
| | | |
| | | |
| | | public static void jumpSuning(Context context, GoodsConvertLinkJumpLink link) { |
| | | public static void jumpSuning(final Activity context, final GoodsConvertLinkJumpLink link, UserLijinLevelInfoVO userLevel) { |
| | | |
| | | if (userLevel != null && userLevel.getUpgradeRights() != null) { |
| | | showADLoading(context, Constant.GOODS_TYPE_SUNING, userLevel, new GoodsDetailJumpLoaingDialog.Builder.IDialogClose() { |
| | | @Override |
| | | public void onClose(boolean auto) { |
| | | jumpSuning(context, link); |
| | | } |
| | | }); |
| | | } else { |
| | | final Dialog dialog = getLoadingDialog(context, Constant.GOODS_TYPE_SUNING); |
| | | DialogUtil.show(dialog); |
| | | jumpSuning(context, link); |
| | | new Handler().postDelayed(new Runnable() { |
| | | public void run() { |
| | | DialogUtil.dismiss(dialog); |
| | | } |
| | | }, 3 * 1000); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | private static void jumpSuning(Context context, GoodsConvertLinkJumpLink link) { |
| | | if (context == null) |
| | | return; |
| | | if (link == null) |
| | |
| | | } |
| | | |
| | | |
| | | private static Dialog showADLoading(Activity activity, int platform, UserLijinLevelInfoVO userLevel, GoodsDetailJumpLoaingDialog.Builder.IDialogClose dialogCloseListener) { |
| | | |
| | | GoodsDetailJumpLoaingDialog.Builder builder = new GoodsDetailJumpLoaingDialog.Builder(activity).setPlatform(platform).setOnCloseListener(dialogCloseListener); |
| | | |
| | | if (userLevel != null) { |
| | | if (userLevel.getLoadingAdInfo() != null) { |
| | | builder = builder.setHasAd(true).setAdInfo(userLevel.getLoadingAdInfo().getType(), userLevel.getLoadingAdInfo().getPid()); |
| | | } |
| | | |
| | | if (userLevel.getUpgradeRights() != null) { |
| | | builder = builder.setNotify(userLevel.getUpgradeRights().getDesc(), userLevel.getUpgradeRights().getLink()); |
| | | } |
| | | } |
| | | Dialog dialog = builder.create(); |
| | | dialog.show(); |
| | | return dialog; |
| | | } |
| | | |
| | | private static Dialog getLoadingDialog(Activity activity, int platform) { |
| | | GoodsDetailJumpLoaingDialog.Builder builder = new GoodsDetailJumpLoaingDialog.Builder(activity).setPlatform(platform); |
| | | Dialog dialog = builder.create(); |
| | | return dialog; |
| | | } |
| | | |
| | | |
| | | public static interface IJumpResult { |
| | | public void onSuccess(); |
| | | |