@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.create_case_add_test_layout); context = this; editor = new SharePreferencesEditor(context); WindowManager wm = this.getWindowManager(); width = wm.getDefaultDisplay().getWidth(); height = wm.getDefaultDisplay().getHeight(); caseId = getIntent().getStringExtra("caseId"); departmentId = getIntent().getStringExtra("departmentId"); imageString = getIntent().getStringExtra("imageString"); mQueue = Volley.newRequestQueue(context); mImageLoader = new ImageLoader(mQueue, new BitmapCache()); initData(); initView(); }
@Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { switch (requestCode) { case 0: if (data != null) { String photoPath = data.getStringExtra("bitmap"); List<String> paths = pathMap.get(currentPosition); List<String> bigPaths = bigPathMap.get(currentPosition); if (null == paths) { paths = new ArrayList<String>(); paths.add(photoPath); pathMap.put(currentPosition, paths); } else { if (!paths.contains(photoPath)) { paths.add(photoPath); } } if (null == bigPaths) { bigPaths = new ArrayList<String>(); bigPaths.add(photoPath); bigPathMap.put(currentPosition, bigPaths); } else { if (!bigPaths.contains(photoPath)) { bigPaths.add(photoPath); } } showRightLayout(currentPosition); } break; case 1: if (resultCode == Activity.RESULT_OK) { Map<String, String> parmas = new HashMap<String, String>(); parmas.put("id", idMap.get(currentPosition).get(data.getIntExtra("index", 0))); parmas.put("accessToken", ClientUtil.getToken()); parmas.put("uid", editor.get("uid", "")); CommonUtil.showLoadingDialog(CaseTestActivity.this); OpenApiService.getInstance(CaseTestActivity.this) .getDeleteCaseImage( mQueue, parmas, new Response.Listener<String>() { @Override public void onResponse(String arg0) { CommonUtil.closeLodingDialog(); try { JSONObject responses = new JSONObject(arg0); if (responses.getInt("rtnCode") == 1) { pathMap.get(currentPosition).remove(data.getIntExtra("index", 0)); idMap.get(currentPosition).remove(data.getIntExtra("index", 0)); showRightLayout(currentPosition); } else if (responses.getInt("rtnCode") == 10004) { Toast.makeText( CaseTestActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) {} @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity(new Intent(CaseTestActivity.this, LoginActivity.class)); } else { Toast.makeText( CaseTestActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { CommonUtil.closeLodingDialog(); Toast.makeText(CaseTestActivity.this, "网络连接失败,请稍后重试", Toast.LENGTH_SHORT) .show(); } }); } break; default: break; } super.onActivityResult(requestCode, resultCode, data); }