基线备份:thirdparty 变体完成 + Android 4.2 兼容改造前
包含内容: - thirdparty flavor 独立 applicationId + Intent 入口(ThirdPartyEntryActivity) - 58 后端接口适配(单 /api 路径、code 0/200、camelCase 字段、UNBOUND 轮询) - MAC 硬件锚定校验(防一凭证多设备共用) - EPG mac 覆盖 SDK init(sMacOverride)+ ChannelManger 初始化对齐 - 提示文案优化(设备未注册/权益未绑定)
This commit is contained in:
87
app/src/main/java/com/pukka/jiecheng/utils/UiUtils.java
Executable file
87
app/src/main/java/com/pukka/jiecheng/utils/UiUtils.java
Executable file
@@ -0,0 +1,87 @@
|
||||
package com.pukka.jiecheng.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class UiUtils {
|
||||
|
||||
/**
|
||||
* 赛事卡片推荐位类型
|
||||
*/
|
||||
public static int POSITION_TYPE_SPORT_CARD = 1;
|
||||
|
||||
/**
|
||||
* 把数字转化成Dimen文件里对应的值
|
||||
*
|
||||
* @param mContext
|
||||
* @param number 原始数值
|
||||
* @return
|
||||
*/
|
||||
public static int numberConvertDimenValue(Context mContext, int number) {
|
||||
int dimenId = mContext.getResources().getIdentifier("qb_px_" + number, "dimen", mContext.getPackageName());
|
||||
int value = mContext.getResources().getDimensionPixelSize(dimenId);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重新设置宽高
|
||||
*
|
||||
* @param mContext
|
||||
* @param width
|
||||
* @param height
|
||||
* @param params
|
||||
*/
|
||||
public static void resetLayoutParams(Context mContext, int width, int height, ViewGroup.LayoutParams params) {
|
||||
resetLayoutParams(mContext,width,height,0,params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重新设置宽高
|
||||
*
|
||||
* @param mContext
|
||||
* @param width
|
||||
* @param height
|
||||
* @param recommendedPositionType 推荐位类型 1赛事卡片 0 其他类型
|
||||
* @param params
|
||||
*/
|
||||
public static void resetLayoutParams(Context mContext, int width, int height, int recommendedPositionType,ViewGroup.LayoutParams params) {
|
||||
int realWith = UiUtils.numberConvertDimenValue(mContext, width);
|
||||
int realHeight = UiUtils.numberConvertDimenValue(mContext, height);
|
||||
double rate = UiUtils.divNum(realWith, realHeight);
|
||||
//1赛事卡片推荐位固定高度22 其他类型23
|
||||
int showHeight = mContext.getResources().getDimensionPixelSize(recommendedPositionType == POSITION_TYPE_SPORT_CARD ? R.dimen.qb_px_22 : R.dimen.qb_px_23);
|
||||
params.width = (int) (rate * showHeight);
|
||||
params.height = showHeight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提供精确的除法运算
|
||||
*
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @return 两个参数的商
|
||||
*/
|
||||
public static double divNum(int v1, int v2) {
|
||||
try {
|
||||
if (0 == v1 || 0 == v2) {
|
||||
return 0;
|
||||
}
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user