111 lines
2.4 KiB
Java
111 lines
2.4 KiB
Java
package com.example.livestreaming;
|
||
|
||
/**
|
||
* 礼物数据模型
|
||
*/
|
||
public class Gift {
|
||
private String id;
|
||
private String name;
|
||
private int price; // 价格(金币数量)
|
||
private int iconResId; // 礼物图标资源ID
|
||
private String iconUrl; // 礼物图标URL(从服务器加载)
|
||
private String description; // 礼物描述
|
||
private int level; // 礼物等级(1-5星)
|
||
|
||
public Gift(String id, String name, int price, int iconResId) {
|
||
this.id = id;
|
||
this.name = name;
|
||
this.price = price;
|
||
this.iconResId = iconResId;
|
||
this.level = 1;
|
||
}
|
||
|
||
public Gift(String id, String name, int price, int iconResId, int level) {
|
||
this.id = id;
|
||
this.name = name;
|
||
this.price = price;
|
||
this.iconResId = iconResId;
|
||
this.level = level;
|
||
}
|
||
|
||
// 新增构造函数 - 支持URL
|
||
public Gift(String id, String name, int price, String iconUrl, int level) {
|
||
this.id = id;
|
||
this.name = name;
|
||
this.price = price;
|
||
this.iconUrl = iconUrl;
|
||
this.iconResId = R.drawable.ic_gift_24; // 默认占位图
|
||
this.level = level;
|
||
}
|
||
|
||
public String getId() {
|
||
return id;
|
||
}
|
||
|
||
public void setId(String id) {
|
||
this.id = id;
|
||
}
|
||
|
||
public String getName() {
|
||
return name;
|
||
}
|
||
|
||
public void setName(String name) {
|
||
this.name = name;
|
||
}
|
||
|
||
public int getPrice() {
|
||
return price;
|
||
}
|
||
|
||
public void setPrice(int price) {
|
||
this.price = price;
|
||
}
|
||
|
||
public int getIconResId() {
|
||
return iconResId;
|
||
}
|
||
|
||
public void setIconResId(int iconResId) {
|
||
this.iconResId = iconResId;
|
||
}
|
||
|
||
public String getIconUrl() {
|
||
return iconUrl;
|
||
}
|
||
|
||
public void setIconUrl(String iconUrl) {
|
||
this.iconUrl = iconUrl;
|
||
}
|
||
|
||
public String getDescription() {
|
||
return description;
|
||
}
|
||
|
||
public void setDescription(String description) {
|
||
this.description = description;
|
||
}
|
||
|
||
public int getLevel() {
|
||
return level;
|
||
}
|
||
|
||
public void setLevel(int level) {
|
||
this.level = level;
|
||
}
|
||
|
||
/**
|
||
* 获取格式化的价格字符串
|
||
*/
|
||
public String getFormattedPrice() {
|
||
return price + " 金币";
|
||
}
|
||
|
||
/**
|
||
* 判断是否有图标URL
|
||
*/
|
||
public boolean hasIconUrl() {
|
||
return iconUrl != null && !iconUrl.isEmpty();
|
||
}
|
||
}
|