package com.ss.android.ugc.aweme.im.sdk.chat.data.model;

import X.4Qu;
import X.4RA;
import X.4RF;
import X.86a;
import X.9EH;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.google.gson.a.c;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.im.sdk.share.data.model.PureDataSharePackage;
import com.ss.android.ugc.aweme.sharer.ui.SharePackage;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class EmojiContent extends BaseContent {
    public static String bigEmojiMessageHint = "";
    @c(LIZ = "display_name")
    public String displayName;
    @c(LIZ = "height")
    public int height;
    @c(LIZ = "image_id")
    public long imageId;
    @c(LIZ = "image_type")
    public String imageType;
    @c(LIZ = "package_id")
    public long packageId;
    @c(LIZ = "sticker_id")
    public String stickerId;
    public boolean updateConversationTime = true;
    @c(LIZ = "url")
    public UrlModel url;
    @c(LIZ = "version")
    public String version;
    @c(LIZ = "width")
    public int width;

    public String getDisplayName() {
        return this.displayName;
    }

    public int getHeight() {
        return this.height;
    }

    public long getImageId() {
        return this.imageId;
    }

    public String getImageType() {
        return this.imageType;
    }

    public long getPackageId() {
        return this.packageId;
    }

    public String getStickerId() {
        return this.stickerId;
    }

    public UrlModel getUrl() {
        return this.url;
    }

    public String getVersion() {
        return this.version;
    }

    public int getWidth() {
        return this.width;
    }

    public boolean isUpdateConversationTime() {
        return this.updateConversationTime;
    }

    static {
        Covode.recordClassIndex(84088);
    }

    public List<UrlModel> fetchPreload() {
        UrlModel urlModel = this.url;
        if (urlModel == null) {
            return null;
        }
        return Collections.singletonList(urlModel);
    }

    public SharePackage generateSharePackage() {
        SharePackage LIZ = PureDataSharePackage.LIZ.LIZ("gif");
        Bundle bundle = LIZ.LJIILJJIL;
        bundle.putSerializable("video_cover", getUrl());
        bundle.putInt("aweme_type", getType());
        return LIZ;
    }

    public void tryInit() {
        Context LIZ;
        if (TextUtils.isEmpty(bigEmojiMessageHint) && (LIZ = 9EH.LJJIFFI.LIZ()) != null) {
            bigEmojiMessageHint = LIZ.getString(2131825795);
        }
    }

    public UrlModel getLocalUrl() {
        String LIZ;
        if (getType() == 502) {
            return null;
        }
        if (getType() == 501) {
            LIZ = 4RA.LIZ(0, "0", this.imageId, this.imageType);
        } else {
            LIZ = 4RA.LIZ(this.packageId, this.version, this.imageId, this.imageType);
        }
        if (!new File(LIZ).exists()) {
            return null;
        }
        UrlModel urlModel = new UrlModel();
        ArrayList arrayList = new ArrayList();
        arrayList.add("file://".concat(String.valueOf(LIZ)));
        urlModel.setUrlList(arrayList);
        urlModel.setUri("file://".concat(String.valueOf(LIZ)));
        return urlModel;
    }

    public String getMsgHint() {
        int type = getType();
        if (501 == type || 505 == type) {
            return "[" + 9EH.LJJIFFI.LIZ().getString(2131825843) + "]";
        } else if (!86a.LIZ(getDisplayName())) {
            return "[" + getDisplayName() + "]";
        } else {
            super.getMsgHint();
            return bigEmojiMessageHint;
        }
    }

    public void setDisplayName(String str) {
        this.displayName = str;
    }

    public void setHeight(int i) {
        this.height = i;
    }

    public void setImageId(long j) {
        this.imageId = j;
    }

    public void setImageType(String str) {
        this.imageType = str;
    }

    public void setPackageId(long j) {
        this.packageId = j;
    }

    public void setStickerId(String str) {
        this.stickerId = str;
    }

    public void setUpdateConversationTime(boolean z) {
        this.updateConversationTime = z;
    }

    public void setUrl(UrlModel urlModel) {
        this.url = urlModel;
    }

    public void setVersion(String str) {
        this.version = str;
    }

    public void setWidth(int i) {
        this.width = i;
    }

    public String getQuoteHint(Context context) {
        if (this.type == 502) {
            return context.getResources().getString(2131825933);
        }
        return context.getResources().getString(2131825941);
    }

    public static EmojiContent obtain(4Qu r3) {
        EmojiContent emojiContent = new EmojiContent();
        emojiContent.setUrl(r3.getAnimateUrl());
        emojiContent.setImageId(r3.getId());
        emojiContent.setDisplayName(4RF.LIZIZ(r3));
        emojiContent.setImageType(r3.getAnimateType());
        emojiContent.setPackageId(r3.getResourcesId());
        emojiContent.setVersion(r3.getVersion());
        emojiContent.setWidth(r3.getWidth());
        emojiContent.setHeight(r3.getHeight());
        if (r3.getStickerType() == 2) {
            emojiContent.setType(501);
        } else if (r3.getStickerType() == 3) {
            emojiContent.setType(502);
            emojiContent.setStickerId(r3.getStickerId());
        } else if (r3.getStickerType() == 4) {
            emojiContent.setType(505);
        } else {
            emojiContent.setType(500);
        }
        return emojiContent;
    }

    public static EmojiContent obtain(4Qu r0, int i) {
        EmojiContent obtain = obtain(r0);
        obtain.setType(i);
        return obtain;
    }

    public String wrapMsgHint(boolean z, boolean z2, String str) {
        boolean z3;
        Context LIZ = 9EH.LJJIFFI.LIZ();
        int type = getType();
        if (500 == type || 501 == type || 504 == type || 505 == type) {
            z3 = true;
        } else {
            z3 = false;
        }
        if (z2) {
            if (z3) {
                return LIZ.getString(2131821928);
            }
            return LIZ.getString(2131822395);
        } else if (z) {
            if (z3) {
                return LIZ.getString(2131821928);
            }
            return LIZ.getString(2131822395);
        } else if (z3) {
            return LIZ.getString(2131821929);
        } else {
            return LIZ.getString(2131832091);
        }
    }
}
