admin
2021-05-17 06a80d5c4b3a971cdc1ca3d91717ec3f6e03a443
app/src/main/java/com/tejia/lijin/app/util/ui/GoodsDetailUtil.java
@@ -3,12 +3,16 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
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;
@@ -122,4 +126,61 @@
        }
    }
    public static String getSalesTypeDesc(int salesType) {
        switch (salesType) {
            case 1:
                return "月销";
            case 2:
                return "2小时销";
            case 3:
                return "今日销";
            case 4:
                return "总销";
        }
        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:
                return "京东";
            case 30:
                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);
    }
}