1.新建接口
public interface UpdateService {
/**
*更新接口
* @param updatevo
* @throws Exception
*/
void UpdateClient(UpdateVO updatevo) throws Exception;
}
2.接口实现
/**
* 更新接口的实现
* Created by zyy on 2017/7/24.
*/
public class UpdateServicelmpl implements UpdateService{
private Handler handler;
private ServerDataExchangeUtil serverDataExchangeUtil;
public UpdateServicelmpl(Handler handler) {
this.handler = handler;
init();
}
/**
* 初始化
*/
private void init() {
try {
serverDataExchangeUtil = new ServerDataExchangeUtil();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void UpdateClient(UpdateVO updatevo) throws Exception {
String url= Constant.UPDATEURL;
if(null != url && !"".equals(url)) {
String mac = Constant.MAC;
url = "http://" + url + FunctionUtil.getFunctionList(FunctionListEnum.UpdateClient.toString());
Map<String, Object> mapPara = new HashMap<>();
mapPara.put("mac", mac);
//创个userUser, 使之有token
InstanceServiceUtil.writeMap(UserUser.class.toString(), new UserUser());
serverDataExchangeUtil.handler = handler;
serverDataExchangeUtil.PostValue(CommandEnum.UPDATA_CLIENT, FunctionListEnum.UpdateClient.toString(), url, mapPara,ContentTypeEnum.Text.getContentType());
}
}
}
3.接口实体
public class UpdateVO {
//服务器中APP版本号
private int serverVersionCode;
private String url;
public int getServerVersionCode() {
return serverVersionCode;
}
public void setServerVersionCode(int serverVersionCode) {
this.serverVersionCode = serverVersionCode;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
网友评论