package com.vpn.fastestvpnservice.beans

import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import java.text.Collator

class SelectApplicationEntry : Comparable<SelectApplicationEntry> {

    constructor(packageManager: PackageManager?, info: ApplicationInfo) {
        mInfo = info
        val name = info.loadLabel(packageManager!!)
        mName = name.toString()
        mIcon = info.loadIcon(packageManager)
    }

    private var mInfo: ApplicationInfo? = null
    private var mIcon: Drawable? = null
    private var mName: String? = null
    private var mSelected = false

    fun setSelected(selected: Boolean) {
        mSelected = selected
    }

    fun isSelected(): Boolean {
        return mSelected
    }

    fun getInfo(): ApplicationInfo? {
        return mInfo
    }

    fun getIcon(): Drawable? {
        return mIcon
    }

    override fun toString(): String {
        return mName!!
    }

    override fun compareTo(another: SelectApplicationEntry): Int {
        return Collator.getInstance().compare(toString(), another.toString())
    }
}

