UpdateInfoBuilder.java 1.03 KB
package com.hjx.miaohongentry.builder;




import com.hjx.miaohongentry.bean.AppVersion;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by l on 2017/7/8.
 */

public class UpdateInfoBuilder extends JSONBuilder<AppVersion> {
    @Override
    public AppVersion build(JSONObject jsonObject) throws JSONException {

        try {
            AppVersion info = new AppVersion();
            info.setVersionName(jsonObject.getString(root+"version_name"));
            info.setVersionCode(jsonObject.getString(root+"versioncode"));
            info.setMsg(jsonObject.getString(root+"msg"));
            info.setURL(jsonObject.getString(root+"url"));
            String update = jsonObject.getString(root+"forceupdate");
            if(update.equalsIgnoreCase("false")){
                info.setForceUpdate(false);
            }else{
                info.setForceUpdate(true);
            }

            return  info;
        } catch (JSONException e) {
            e.printStackTrace();
            return  null;
        }
    }
}