package com.key.vibekeyboard.Room;

import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.util.Objects;

@Entity(tableName = "wallpaper_info")
public class WallpaperInfo implements Parcelable {

    @PrimaryKey(autoGenerate = true)
    public int id;
    public String preview;
    public String thumb;
    public String className;
    public String title;
    public String zipUrl;
    public Boolean islike;
    public Boolean isDownloaded;
    public String path;

    // Default constructor
    public WallpaperInfo() {
    }

    // Constructor for Parcelable
    protected WallpaperInfo(Parcel in) {
        id = in.readInt();
        preview = in.readString();
        thumb = in.readString();
        className = in.readString();
        title = in.readString();
        zipUrl = in.readString();
        islike = in.readByte() != 0;
        isDownloaded = in.readByte() != 0;
        path = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(preview);
        dest.writeString(thumb);
        dest.writeString(className);
        dest.writeString(title);
        dest.writeString(zipUrl);
        dest.writeByte((byte) (islike ? 1 : 0));
        dest.writeByte((byte) (isDownloaded ? 1 : 0));
        dest.writeString(path);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<WallpaperInfo> CREATOR = new Creator<WallpaperInfo>() {
        @Override
        public WallpaperInfo createFromParcel(Parcel in) {
            return new WallpaperInfo(in);
        }

        @Override
        public WallpaperInfo[] newArray(int size) {
            return new WallpaperInfo[size];
        }
    };

    // Getters and setters

    public int getId() {
        return id;
    }

    public String getPreview() {
        return preview;
    }

    public void setPreview(String preview) {
        this.preview = preview;
    }

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getZipUrl() {
        return zipUrl;
    }

    public void setZipUrl(String zipUrl) {
        this.zipUrl = zipUrl;
    }

    public Boolean getIslike() {
        return islike;
    }

    public void setIslike(Boolean islike) {
        this.islike = islike;
    }

    public Boolean getDownloaded() {
        return isDownloaded;
    }

    public void setDownloaded(Boolean downloaded) {
        isDownloaded = downloaded;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WallpaperInfo that = (WallpaperInfo) o;
        return id == that.id &&
                Objects.equals(title, that.title) &&
                Objects.equals(preview, that.preview) &&
                islike == that.islike;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, title, preview, islike);
    }

}
