@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case ParamConst.TAKE_CAMERA_PICTURE: // Toast.makeText(this, path + CameraUtil.getImagename(), 1).show(); if (CameraUtil.getNewTakePhotoFile() != null) { ImgUtil.refreshGallery(CameraUtil.getNewTakePhotoFile(), this); } List<String> imgs = galleryUtil .getmImageFoldersMap() .get(galleryUtil.getmImgDir().getAbsolutePath()) .getImgs(); imgs.add(0, path + "/" + CameraUtil.getImagename()); galleryUtil.setmImgs(imgs); gridItemAdapter.changeData( galleryUtil.getmImgs() /*, galleryUtil.getmImgDir().getAbsolutePath()*/); break; case ParamConst.GALLERY_ACTIVITY_TO_UPLOAD_PIC_PREVIEW_ACTIVITY_REQUEST_CODE: if (resultCode == ParamConst.UPLOAD_PIC_PREVIEW_ACTIVITY_BACK_TO_GALLERY_ACTIVITY_RESULT_CODE) { Bundle bundle = data.getExtras(); /*ArrayList<String> checkedImgDatas = bundle.getStringArrayList(ParamConst.CHECKED_IMG_DATAS); ImageGridItemContainCheckAdapter.setmSelectedImage(checkedImgDatas);*/ gridItemAdapter.changeData( galleryUtil.getmImgs() /*, galleryUtil.getmImgDir().getAbsolutePath()*/); titleRightTV.setText( "完成(" + ImageGridItemContainCheckAdapter.getmSelectedImage().size() + "张)"); preview.setText( "预览(" + ImageGridItemContainCheckAdapter.getmSelectedImage().size() + "张)"); } break; } }
private void initTitleRight() { titleRightTV = (TextView) findViewById(R.id.titleRightTV); titleRightTV.setText( "完成(" + ImageGridItemContainCheckAdapter.getmSelectedImage().size() + "张)"); titleRightTV.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (ImageGridItemContainCheckAdapter.getmSelectedImage().size() == 0) { Toast.makeText(GalleryActivity.this, "请先选择一张图片后再点击完成", Toast.LENGTH_SHORT).show(); return; } // ActivityJumpUtil.sendImgDatasToActivity((ArrayList<String>) // GridItemContainCheckAdapter.getmSelectedImage(), (ArrayList<String>) // GridItemContainCheckAdapter.getmSelectedImage(), 0, GalleryActivity.this, // UploadPicFinishCheckActivity.class); Intent intent = new Intent(); // 用于表示当前进入相册进行操作时发送到广播中的action intent.putExtra(ParamConst.BROADCAST_ACTION, broadcaseAction); ActivityJumpUtil.sendTakePhotoToActivity( (ArrayList<String>) ImageGridItemContainCheckAdapter.getmSelectedImage(), GalleryActivity.this, UploadPicFinishCheckActivity.class, ParamConst.ADD_PIC_IS_JUMP_TO_PREV_ACTIVITY_YES, intent); } }); }
private void getCheckedImg() { Intent intent = getIntent(); ArrayList<String> imgDatas = intent.getStringArrayListExtra(ParamConst.CHECKED_IMG_DATAS); if (imgDatas != null) { ImageGridItemContainCheckAdapter.setmSelectedImage(imgDatas); designationPath = new File(imgDatas.get(0)).getParentFile().getAbsolutePath(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); ImageGridItemContainCheckAdapter.getmSelectedImage().clear(); initBaseData(); initTitle(); initBottom(); initView(); getImg(); initEvent(); }
private void initPreview() { preview = (TextView) findViewById(R.id.preview); preview.setText("预览(" + ImageGridItemContainCheckAdapter.getmSelectedImage().size() + "张)"); }