@Override public void OnUpdateDataFinish(int Result) { if (getView() == null) return; if (Result == TResult.ESuccess) { strurl = wetools.GetWeUrl(); weversion.setText(getString(R.string.course_we) + wetools.GetWeversion()); wesize.setText( String.format(getString(R.string.we_size), wetools.GetWesize()) + getString(R.string.we_num)); initView(); } else { downbutton.setVisibility(View.GONE); Toast.makeText(getActivity(), getString(R.string.networkerr), Toast.LENGTH_SHORT).show(); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); String mTitle = null; if (getArguments() != null) { mTitle = getArguments().getString("title"); } if (mTitle != null && mTitle.length() != 0) { setTitle(mTitle); } else { setTitle(R.string.course_we); } setLeftBack(); setRightNaviNone(); strpackgagename = CMGlobal.getInstance().readPropertiesURL("wePackage"); toWE = CMGlobal.getInstance().readPropertiesURL("weAction"); weversion = (TextView) getView().findViewById(R.id.version); wesize = (TextView) getView().findViewById(R.id.wesize); downbutton = (Button) getView().findViewById(R.id.down_button); downbutton.setVisibility(View.GONE); downbutton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (checkApkExist(strpackgagename)) { Intent intent = new Intent(toWE); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Map<String, String> map = CMGlobal.getInstance().createMapForWE(); Bundle bundle = new Bundle(); bundle.putSerializable("message", (Serializable) map); intent.putExtras(bundle); intent.putExtra("hasAuth", true); startActivity(intent); return; } switch (downloader.status) { case -1: // 没有下载过的 downService.startDownload(strurl, onDownloadListener); break; case Downloader.STATE_COMPLETE: File newFile = new File( FileUtils.getAppUpdateDir(), downloader.filename + "." + downloader.suffix); if (newFile.exists()) openApkfile(newFile); break; case Downloader.STATE_PAUSE: downService.resumeDown(strurl, onDownloadListener); break; case Downloader.STATE_CANCEL: downService.startDownload(strurl, onDownloadListener); case Downloader.STATE_FAIL: downService.startDownload(strurl, onDownloadListener); break; default: break; } } }); wetools.GetWetool(); // strurl = CMGlobal.getInstance().readPropertiesURL("weDownloadUrl"); getActivity() .bindService( new Intent(getActivity(), CMDownloadService.class), mConn, Context.BIND_AUTO_CREATE); }