170 lines
4.5 KiB
Java
170 lines
4.5 KiB
Java
package com.ubt.jimu.controller.data.widget;
|
|
|
|
import android.content.Context;
|
|
import android.util.Size;
|
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
|
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
|
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
|
import com.ubt.jimu.controller.util.IDGenerator;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class ItemBaseData {
|
|
static final String ALIAS_POS_X = "pos_x";
|
|
static final String ALIAS_POS_Y = "pos_y";
|
|
static final String ALIAS_WIDGET_ID = "widgetId";
|
|
|
|
@XStreamOmitField
|
|
private int ImageViewId;
|
|
|
|
@XStreamOmitField
|
|
private float currentX;
|
|
|
|
@XStreamOmitField
|
|
private float currentY;
|
|
|
|
@XStreamOmitField
|
|
private Size displaySize;
|
|
|
|
@XStreamAlias(ALIAS_POS_X)
|
|
private float posX;
|
|
|
|
@XStreamAlias(ALIAS_POS_Y)
|
|
private float posY;
|
|
|
|
@XStreamOmitField
|
|
private String showName;
|
|
|
|
@XStreamAsAttribute
|
|
private String widgetId;
|
|
|
|
@XStreamOmitField
|
|
private Size xmlSize;
|
|
|
|
public ItemBaseData() {
|
|
this.widgetId = IDGenerator.a(System.currentTimeMillis());
|
|
}
|
|
|
|
private float getDisplayRatio() {
|
|
float height = this.displaySize.getHeight() / this.xmlSize.getHeight();
|
|
float width = this.displaySize.getWidth() / this.xmlSize.getWidth();
|
|
return width > height ? height : width;
|
|
}
|
|
|
|
private float getSaveRatio() {
|
|
float height = this.xmlSize.getHeight() / this.displaySize.getHeight();
|
|
float width = this.xmlSize.getWidth() / this.displaySize.getWidth();
|
|
return width < height ? height : width;
|
|
}
|
|
|
|
private void transformX(float f) {
|
|
if (Math.abs(f) > 1.0E-6f) {
|
|
if (this.displaySize == null || this.xmlSize == null) {
|
|
this.posX = f;
|
|
} else {
|
|
this.posX = (f - (r0.getWidth() / 2.0f)) * getSaveRatio();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void transformY(float f) {
|
|
if (Math.abs(f) > 1.0E-6f) {
|
|
if (this.displaySize == null || this.xmlSize == null) {
|
|
this.posY = f;
|
|
} else {
|
|
this.posY = ((r0.getHeight() / 2.0f) - f) * getSaveRatio();
|
|
}
|
|
}
|
|
}
|
|
|
|
public float getCurrentX() {
|
|
if (Math.abs(this.currentX) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
|
this.currentX = (this.posX * getDisplayRatio()) + (this.displaySize.getWidth() / 2.0f);
|
|
}
|
|
return this.currentX;
|
|
}
|
|
|
|
public float getCurrentY() {
|
|
if (Math.abs(this.currentY) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
|
this.currentY = (this.displaySize.getHeight() / 2.0f) - (this.posY * getDisplayRatio());
|
|
}
|
|
return this.currentY;
|
|
}
|
|
|
|
public int getImageViewId() {
|
|
return this.ImageViewId;
|
|
}
|
|
|
|
public float getPosX() {
|
|
return this.posX;
|
|
}
|
|
|
|
public float getPosY() {
|
|
return this.posY;
|
|
}
|
|
|
|
public String getShowName(String str) {
|
|
return this.showName;
|
|
}
|
|
|
|
public String getWidgetId() {
|
|
return this.widgetId;
|
|
}
|
|
|
|
public abstract String getWidgetInfo(Context context);
|
|
|
|
public abstract boolean isOfficial();
|
|
|
|
public void setCurrentPos(float f, float f2) {
|
|
setCurrentX(f);
|
|
setCurrentY(f2);
|
|
}
|
|
|
|
public void setCurrentX(float f) {
|
|
this.currentX = f;
|
|
}
|
|
|
|
public void setCurrentY(float f) {
|
|
this.currentY = f;
|
|
}
|
|
|
|
protected void setDisplaySize(Size size, Size size2) {
|
|
this.displaySize = size;
|
|
this.xmlSize = size2;
|
|
}
|
|
|
|
public void setImageViewId(int i) {
|
|
this.ImageViewId = i;
|
|
}
|
|
|
|
protected void setPosX(float f) {
|
|
this.posX = f;
|
|
}
|
|
|
|
protected void setPosY(float f) {
|
|
this.posY = f;
|
|
}
|
|
|
|
public void setShowName(String str) {
|
|
this.showName = str;
|
|
}
|
|
|
|
public String toString() {
|
|
return "ItemBaseData{widgetId='" + this.widgetId + "', posX=" + this.posX + ", posY=" + this.posY + ", ImageViewId=" + getImageViewId() + ", showName='" + this.showName + "', displaySize=" + this.displaySize + ", xmlSize=" + this.xmlSize + ", currentX=" + getCurrentX() + ", currentY=" + getCurrentY() + '}';
|
|
}
|
|
|
|
protected void transform() {
|
|
transformX(this.currentX);
|
|
transformY(this.currentY);
|
|
}
|
|
|
|
public ItemBaseData(String str) {
|
|
this.widgetId = str;
|
|
}
|
|
|
|
public ItemBaseData(String str, float f, float f2) {
|
|
this(str);
|
|
this.posX = f;
|
|
this.posY = f2;
|
|
}
|
|
}
|