admin
2021-07-06 abce02c7a61820f5d580f87364d542e817be429c
app/src/main/java/com/tejia/lijin/app/util/ui/GoodsDetailUtil.java
@@ -3,11 +3,17 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.tejia.lijin.app.ShoppingApplication;
import com.wpc.library.util.common.DimenUtils;
import com.wpc.library.util.common.StringUtils;
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
import com.tejia.lijin.app.ShoppingApi;
@@ -36,7 +42,7 @@
        if (mInfo.getGoods() == null)
            return;
        if (!LoginAndInviteStatusUtil.acessNext(activity, UserUtil.getUid(activity) + "", true))
        if (!LoginAndInviteStatusUtil.acessNext(activity, UserUtil.getUid(activity), true))
            return;
        if (!DuplicateEventFilterUtil.allowEvent("sendOrder", 3000)) {
@@ -45,8 +51,7 @@
        }
        final ShapeLoadingDialog pd = new ShapeLoadingDialog.Builder(activity).build();
        String uid = activity.getSharedPreferences("user", Context.MODE_PRIVATE).getString("uid", "0");
        ShoppingApi.sendGoodsOrder(activity, goodsId, uid, mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() {
        ShoppingApi.sendGoodsOrder(activity, goodsId, UserUtil.getUid(ShoppingApplication.application), mInfo.getGoods().getGoodsType() + "", new BasicTextHttpResponseHandler() {
            @Override
            public void onStart() {
                super.onStart();
@@ -104,21 +109,138 @@
    /**
     * 设置券信息
     *
     * @param tv_coupon_amount
     * @param tv_coupon_condition
     * @param tv_coupon_date
     * @param info
     */
    public static void setCouponInfo(TextView tv_coupon_amount, TextView tv_coupon_condition, TextView tv_coupon_date, CouponInfo info){
        tv_coupon_amount.setText( info.getAmount());
    public static void setCouponInfo(TextView tv_coupon_amount, TextView tv_coupon_condition, TextView tv_coupon_date, CouponInfo info) {
        tv_coupon_amount.setText(info.getAmount());
        tv_coupon_condition.setText(String.format("满%s元可用", info.getStartFee()));
        tv_coupon_condition.setVisibility(View.VISIBLE);
        if (!StringUtils.isEmpty(info.getStartTime()) && !StringUtils.isEmpty(info.getEndTime())) {
            tv_coupon_date.setVisibility(View.VISIBLE);
            tv_coupon_date.setText("有效期: "+info.getStartTime() + "-" + info.getEndTime());
            tv_coupon_date.setText("有效期: " + info.getStartTime() + "-" + info.getEndTime());
        } else {
            tv_coupon_date.setVisibility(View.GONE);
        }
    }
    public static String getSalesTypeDesc(int salesType) {
        switch (salesType) {
            case 1:
                return "月销";
            case 2:
                return "2小时销";
            case 3:
                return "今日销";
            default:
                return "总销";
        }
    }
    /**
     * 根据商品用户类型获取店铺类型图标
     *
     * @return
     */
    private static GradientDrawable getUserTypeDrawable(Context context, int color) {
        GradientDrawable gd = new GradientDrawable();
        gd.setColor(Color.TRANSPARENT);
        gd.setCornerRadius(100);
        gd.setStroke(DimenUtils.dip2px(context, 1), color);
        return gd;
    }
    public static String getShopTypeName(int userType) {
        switch (userType) {
            case 10:
                return "淘宝";
            case 11:
                return "天猫";
            case 20:
            case 21:
                return "京东";
            case 30:
                return "拼多多";
            case 40:
                return "唯品会";
            case 50:
                return "苏宁易购";
        }
        return "";
    }
    public static void fillShopType(TextView tv_shop_type, int userType) {
        int color = Color.parseColor("#FF2C4A");
        GradientDrawable bg = getUserTypeDrawable(tv_shop_type.getContext(), color);
        tv_shop_type.setBackground(bg);
        tv_shop_type.setText(getShopTypeName(userType));
        tv_shop_type.setTextColor(color);
        tv_shop_type.setTextSize(10);
        tv_shop_type.setPadding(DimenUtils.dip2px(tv_shop_type.getContext(), 5), 2,
                DimenUtils.dip2px(tv_shop_type.getContext(), 5), 3);
    }
    /**
     * 是否展开红包/返利详情
     *
     * @param context
     * @return
     */
    public static boolean spreadHoneBaoOrFanLiDetail(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("goods", Context.MODE_PRIVATE);
        long time = sharedPreferences.getLong("installTime", 0L);
        if (System.currentTimeMillis() - time < 1000 * 60 * 60 * 24L * 3) {
            return true;
        }
        return false;
    }
    /**
     * 初始化安装时间
     *
     * @param context
     */
    public static void initInstallTime(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("goods", Context.MODE_PRIVATE);
        long installTime = sharedPreferences.getLong("installTime", 0L);
        if (installTime == 0L) {
            SharedPreferences.Editor editor = sharedPreferences.edit();
            editor.putLong("installTime", System.currentTimeMillis());
            editor.commit();
        }
    }
    /**
     * 是否需要提醒登录返利
     *
     * @param context
     * @return
     */
    public static boolean needNotifyLoginFanli(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("goods", Context.MODE_PRIVATE);
        boolean notifyLoginFanli = sharedPreferences.getBoolean("notifyLoginFanli", true);
        return notifyLoginFanli;
    }
    /**
     * 已经提醒了登录返利
     *
     * @param context
     */
    public static void alreadyNotifyLoginFanli(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("goods", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putBoolean("notifyLoginFanli", false);
        editor.commit();
    }
}