package com.yidian.shenghuoquan.newscontent.ui.idcard

import android.graphics.BitmapFactory
import android.os.Bundle
import com.yidian.common.base.BaseActivity
import com.yidian.common.utils.ToolsUtil
import com.yidian.shenghuoquan.newscontent.databinding.ActivityIdcardResultBinding

/**
 * Author: sym
 * Date: 2021/5/20 6:51 PM
 * Describe:
 */
class IDCardResultActivity:BaseActivity<ActivityIdcardResultBinding>() {
    override fun createViewBinding(): ActivityIdcardResultBinding {
        return ActivityIdcardResultBinding.inflate(layoutInflater)
    }

    override fun getXPageName(): String {
        return ""
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val intent = intent
        val bundle = intent.extras

        val portraitimg = bundle!!.getByteArray("portraitimg_bitmap")
        val iDCardImg = bundle.getByteArray("idcardimg_bitmap")

        if (portraitimg != null) {
            val bmpPortraitImg = BitmapFactory.decodeByteArray(portraitimg, 0, portraitimg.size)
            viewBind.resultFaceImage.setImageBitmap(bmpPortraitImg)
        }

        if (iDCardImg != null) {
            val bmpIDCardImg = BitmapFactory.decodeByteArray(iDCardImg, 0, iDCardImg.size)
            viewBind.resultIdcardImage.setImageBitmap(bmpIDCardImg)
            ToolsUtil.saveImage(bmpIDCardImg, ToolsUtil.randomName() + ".jpg", this)
        }
    }

}