package com.duolebo.blyrobot.data

import com.duolebo.appbase.prj.XMLHelper
import com.duolebo.appbase.prj.bmtv.model.ModelBase
import org.json.JSONArray
import org.json.JSONObject

class AppInfoData : ModelBase() {
    val apkInfos = ArrayList<ApkInfo>()
    var result = -1

    override fun from(json: JSONObject): Boolean {
        val data = json.optJSONArray("data")
        if (data != null) {
            for (i in 0 until data.length()) {
                val apkInfo = ApkInfo()
                apkInfo.from(data.getJSONObject(i))
                apkInfos.add(apkInfo)
            }
        }
        result = 0

        return true
    }

    override fun from(json: JSONArray?): Boolean {
        return true
    }

    override fun from(p0: XMLHelper?): Boolean {
        return false
    }

    override fun getCode(): Int {
        return result
    }
}