package cc.winboll.studio.powerbell.model;

/**
 * @Author ZhanGSKen<zhangsken@qq.com>
 * @Date 2024/07/18 11:52:28
 * @Describe 应用背景图片数据类
 */
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;

public class BackgroundBean extends BaseBean {

    public static final String TAG = "BackgroundPictureBean";

	String backgroundFileName = "";
	String backgroundFileInfo = "";
	boolean isUseBackgroundFile = false;
	String backgroundScaledCompressFileName = "";
	boolean isUseScaledCompress = false;
    int backgroundWidth = 100;
    int backgroundHeight = 100;
	// 图片拾取像素颜色
	int pixelColor = 0;

    public BackgroundBean() {
    }

	public void setBackgroundScaledCompressFileName(String backgroundScaledCompressFileName) {
		this.backgroundScaledCompressFileName = backgroundScaledCompressFileName;
	}

	public String getBackgroundScaledCompressFileName() {
		return backgroundScaledCompressFileName;
	}

	public void setIsUseScaledCompress(boolean isUseScaledCompress) {
		this.isUseScaledCompress = isUseScaledCompress;
	}

	public boolean isUseScaledCompress() {
		return isUseScaledCompress;
	}

	public void setIsUseBackgroundFile(boolean isUseBackgroundFile) {
		this.isUseBackgroundFile = isUseBackgroundFile;
	}

	public boolean isUseBackgroundFile() {
		return isUseBackgroundFile;
	}

	public void setBackgroundFileInfo(String backgroundFileInfo) {
		this.backgroundFileInfo = backgroundFileInfo;
	}

	public String getBackgroundFileInfo() {
		return backgroundFileInfo;
	}

	public void setBackgroundFileName(String backgroundFileName) {
		this.backgroundFileName = backgroundFileName;
	}

	public String getBackgroundFileName() {
		return backgroundFileName;
	}

	public void setPixelColor(int pixelColor) {
		this.pixelColor = pixelColor;
	}

	public int getPixelColor() {
		return pixelColor;
	}

    public void setBackgroundWidth(int backgroundWidth) {
        this.backgroundWidth = backgroundWidth;
    }

    public int getBackgroundWidth() {
        return backgroundWidth;
    }

    public void setBackgroundHeight(int backgroundHeight) {
        this.backgroundHeight = backgroundHeight;
    }

    public int getBackgroundHeight() {
        return backgroundHeight;
    }

    @Override
    public String getName() {
        return BackgroundBean.class.getName();
    }

    @Override
    public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
        super.writeThisToJsonWriter(jsonWriter);
        BackgroundBean bean = this;
        jsonWriter.name("backgroundFileName").value(bean.getBackgroundFileName());
		jsonWriter.name("backgroundFileInfo").value(bean.getBackgroundFileInfo());
		jsonWriter.name("isUseBackgroundFile").value(bean.isUseBackgroundFile());
		jsonWriter.name("backgroundScaledCompressFileName").value(bean.getBackgroundScaledCompressFileName());
		jsonWriter.name("isUseScaledCompress").value(bean.isUseScaledCompress());
		jsonWriter.name("backgroundWidth").value(bean.getBackgroundWidth());
        jsonWriter.name("backgroundHeight").value(bean.getBackgroundHeight());
        jsonWriter.name("pixelColor").value(bean.getPixelColor());
    }

    @Override
    public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
        BackgroundBean bean = new BackgroundBean();
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
            String name = jsonReader.nextName();
            if (name.equals("backgroundFileName")) {
                bean.setBackgroundFileName(jsonReader.nextString());
            } else if (name.equals("backgroundFileInfo")) {
                bean.setBackgroundFileInfo(jsonReader.nextString());
            } else if (name.equals("isUseBackgroundFile")) {
                bean.setIsUseBackgroundFile(jsonReader.nextBoolean());
            } else if (name.equals("backgroundScaledCompressFileName")) {
                bean.setBackgroundScaledCompressFileName(jsonReader.nextString());
            } else if (name.equals("isUseScaledCompress")) {
                bean.setIsUseScaledCompress(jsonReader.nextBoolean());
            } else if (name.equals("backgroundWidth")) {
                bean.setBackgroundWidth(jsonReader.nextInt());
            } else if (name.equals("backgroundHeight")) {
                bean.setBackgroundHeight(jsonReader.nextInt());
            } else if (name.equals("pixelColor")) {
                bean.setPixelColor(jsonReader.nextInt());
            } else {
                jsonReader.skipValue();
            }
        }
        // 结束 JSON 对象
        jsonReader.endObject();
        return bean;
    }
}
