package com.duolebo.blyrobot.ui

import android.content.Context
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.widget.RelativeLayout
import com.duolebo.blyrobot.R
import com.duolebo.blyrobot.data.ApkInfo
import com.duolebo.blyrobot.util.AppUtil
import kotlinx.android.synthetic.main.app_config_item.view.*

class AppConfigListItem(context: Context?) : RelativeLayout(context) {

    init {
        LayoutInflater.from(context).inflate(R.layout.app_config_item, this)
    }

    fun setData(apkInfo: ApkInfo) {
        var installTips = ""
        if (!AppUtil.isAppInstalled(context, apkInfo.packageName))
            installTips = "(未安装)"
        this.appName.text = apkInfo.name + installTips
        this.packageName.text = apkInfo.packageName
    }

    fun setIcon(drawable: Drawable) {
        this.appIcon.setImageDrawable(drawable)
    }
}