@Override public void run() { try { if (NetUtil.hasNetwork(this)) { BaseParser<Version> jsonParser = new VersionParser(); RequestVo vo = new RequestVo(R.string.url_version, this, null, jsonParser); version = (Version) NetUtil.get(vo); if (version != null) { String v = version.getVersion(); Logger.d(TAG, "获取当前服务器版本号为 :" + v); if (clientVersion.equals(v)) { gotoHome(); } else { Message.obtain(handler, SHOW_UPDATE_DIALOG).sendToTarget(); } } else { gotoHome(); } } else { gotoHome(); } } catch (Exception e) { Logger.e(TAG, e); gotoHome(); } }
@Override public List<OrderList> parseJSON(String paramString) throws JSONException { Logger.d(TAG, "解析OrderList订单列表数据"); if (paramString == null) { return null; } else { JSONObject json = new JSONObject(paramString); String result = json.getString("response"); if (result != null && !result.equals("error")) { String orderlist = json.getString("orderlist"); List<OrderList> list = JSON.parseArray(orderlist, OrderList.class); return list; } else { return null; } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_activity); try { // 获取现在客户端的版本 clientVersion = getClientVersion(); } catch (NameNotFoundException e) { Logger.e(TAG, e); } // 在欢迎界面中显示 版本的信息 ((TextView) findViewById(R.id.welcome_version)).setText(clientVersion); // 加入到线程池中 ThreadPoolManager.getInstance().addTask(this); }
public void handleMessage(android.os.Message msg) { switch (msg.what) { case DOWN_ERROR: mProgressDialog.dismiss(); Toast.makeText(WelcomeActivity.this, R.string.down_error, Toast.LENGTH_SHORT).show(); gotoHome(); break; case SHOW_UPDATE_DIALOG: Logger.d(TAG, "更新版本提示"); new Builder(WelcomeActivity.this) .setTitle("升级提醒") .setMessage("亲,有新的版本赶快升级!") .setCancelable(false) .setPositiveButton( "是", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 下载最新的apk downApk(); } }) .setNegativeButton( "否", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Logger.d(TAG, "不更新直接进入主界面"); gotoHome(); } }) .show(); break; default: break; } };