@Override public void onClick(View v) { switch (v.getId()) { case R.id.upload_btn: if ((null != WtloginUtil.getUin()) && (isNewProj == false)) { String sk = WtloginUtil.getSKey(WtloginUtil.getUin()); String psk = WtloginUtil.getPsKey(WtloginUtil.getUin()); String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin()); dataPersisted(); showUploadDialog(sk, psk, lsk); } else if (isNewProj == true) { String sk = WtloginUtil.getSKey(WtloginUtil.getUin()); String psk = WtloginUtil.getPsKey(WtloginUtil.getUin()); String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin()); File file = new File(strNewProjName); comfirmUpdateSize(file, sk, psk, lsk); } else { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.qq_need_login); } break; case R.id.back_gt: finish(); break; } }
private void judgeToast() { if (upperValue <= lowerValue && !isToasted) { isToasted = true; ToastUtil.ShowLongToast(GTApp.getContext(), "lower value must less than upper value!"); return; } else if (upperValue <= lowerValue && isToasted) { return; } isToasted = false; }
/* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { String userAccount = ""; ErrMsg errMsg = null; WUserSigInfo userSigInfo = null; switch (requestCode) { case WtloginUtil.REQ_VCODE: { if (data == null) break; Bundle bundle = data.getExtras(); if (bundle == null) break; userAccount = bundle.getString("ACCOUNT"); errMsg = (ErrMsg) bundle.getParcelable("ERRMSG"); userSigInfo = (WUserSigInfo) bundle.getParcelable("USERSIG"); if (resultCode == util.S_SUCCESS) { // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_pull_products), getString(R.string.pi_octopus_pull_products_content)); loginSuccess(userAccount); } else if (resultCode == util.S_LH_EXPIRED || resultCode == util.S_BABYLH_EXPIRED) { Ticket ticket = WtloginHelper.GetUserSigInfoTicket(userSigInfo, SigType.WLOGIN_LHSIG); finish(); ToastUtil.ShowLongToast( GTApp.getContext(), "lhsig=" + util.buf_to_string(ticket._sig) + " errMsg=" + errMsg); } else { finish(); ToastUtil.ShowLongToast(GTApp.getContext(), "errMsg=" + errMsg); } } break; case WtloginUtil.REQ_QLOGIN: // 快速登录返回 try { if (data == null) { // 这种情况下用户多半是直接按了返回按钮,没有进行快速登录;快速登录失败可提醒用户输入密码登录 break; } WUserSigInfo sigInfo = WtloginUtil.getSigInfo(data); if (sigInfo == null) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_login_user_quickerror); break; } WtloginUtil.setUin(sigInfo.uin); // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_pull_products), getString(R.string.pi_octopus_pull_products_content)); // 快速登录只是从手Q换取了A1票据,A1则相当于用户密码,在此仍需要再发起一次A1换票的流程,才能拿到目标票据 WtloginUtil.getStWithPasswd(sigInfo); // 换票据成功后会触发wtloginListener的监听 } catch (Exception e) { util.printException(e); } break; default: break; } }
private void comfirmUpdateSize( final File folder, final String skey, final String pskey, final String lskey) { // 从folder解析出三级目录 String[] paths = folder.getPath().split(FileUtil.separator); if (paths == null || paths.length <= 3) { // TODO 非预期目录有问题,无法处理的error return; } final String path1 = paths[paths.length - 3]; final String path2 = paths[paths.length - 2]; final String path3 = paths[paths.length - 1]; Object oProductPair = spProductName.getSelectedItem(); if (oProductPair == null) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } if (!(oProductPair instanceof Pair)) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } final Pair<String, String> productPair = (Pair) oProductPair; // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_calc_size), getString(R.string.pi_octopus_calc_size_content)); new Thread( new Runnable() { @Override public void run() { long size = 0; File[] csvFiles = folder.listFiles(FileUtil.CSV_FILTER); // 网络操作需要在独立线程完成 PreUploadEntry preUploadEntry = HttpAssist.preUpload( csvFiles, productPair.first, path1, path2, path3, WtloginUtil.getUin(), skey, pskey, lskey); if (preUploadEntry == null) { ToastUtil.ShowLongToast(GTApp.getContext(), ErrorMsg.NET_ERROR); return; } final List<String> chosedFilePathList = new ArrayList<String>(); for (File f : preUploadEntry.choicedCsvFileList) { size += f.length(); chosedFilePathList.add(f.getPath()); } final long sizeKB = size / 1024 + 1; runOnUiThread( new Runnable() { @Override public void run() { dismissProDialog(); AlertDialog.Builder builder = new Builder(GTOctopusActivity.this); builder.setMessage( getString(R.string.pi_octopus_upload_confirm_content) + sizeKB + "KB"); builder.setTitle(getString(R.string.pi_octopus_upload_confirm_title)); builder.setPositiveButton( getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setNegativeButton( getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Object oProductPair = spProductName.getSelectedItem(); if (oProductPair == null) { ToastUtil.ShowLongToast( GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } if (!(oProductPair instanceof Pair)) { ToastUtil.ShowLongToast( GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } Pair<String, String> productPair = (Pair) oProductPair; // 从folder解析出三级目录 String[] paths = folder.getPath().split(FileUtil.separator); if (paths == null || paths.length <= 3) { // TODO 报个error return; } // 分析文件,准备上传,用Service处理 Intent intent = new Intent(); intent.putExtra(SRC, folder.getPath()); intent.putExtra( FILE_ARRAY, chosedFilePathList.toArray(new String[] {})); intent.putExtra(PRODUCT_ID, productPair.first); intent.putExtra(PRODUCT_NAME, productPair.second); intent.putExtra(PATH1, paths[paths.length - 3]); intent.putExtra(PATH2, paths[paths.length - 2]); intent.putExtra(PATH3, paths[paths.length - 1]); intent.putExtra(UIN, WtloginUtil.getUin()); intent.putExtra(S_KEY, skey); intent.putExtra(P_S_KEY, pskey); intent.putExtra(LS_KEY, lskey); PluginManager.getInstance() .getPluginControler() .startService(GTOctopusEngine.getInstance(), intent); } }); builder.setCancelable(false); builder.show(); } }); } }, "choicedCsvFilesThread") .start(); }