private void showChoiceImageAlert() { // 设置为头像 final CustomSelectPhotoDialog selectDialog = new CustomSelectPhotoDialog(this); selectDialog.show(); selectDialog.setClicklistener( new CustomSelectPhotoDialog.ClickListenerInterface() { @Override public void onSelectGallery() { // 相册 tmpImageName = JLXCUtils.getPhotoFileName() + ""; // 相册 Intent intentAlbum = new Intent(CreateGroupActivity.this, GalleyActivity.class); intentAlbum.putExtra(GalleyActivity.INTENT_KEY_SELECTED_COUNT, 0); intentAlbum.putExtra(GalleyActivity.INTENT_KEY_ONE, true); startActivityForResult(intentAlbum, ALBUM_SELECT); selectDialog.dismiss(); } @Override public void onSelectCamera() { // 相机 Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); tmpImageName = JLXCUtils.getPhotoFileName() + ""; File tmpFile = new File(FileUtil.TEMP_PATH + tmpImageName); intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile)); startActivityForResult(intentCamera, TAKE_PHOTO); selectDialog.dismiss(); } }); }
private void showChoiceImageAlert() { // if (imageDialog == null) { // imageDialog = new AlertDialog.Builder(this) // .setTitle("选择照片") // .setItems(new String[] { "拍照", "相册" }, // new OnClickListener() { // // @Override // public void onClick(DialogInterface dialog, // int which) { // // switch (which) { // case 0: // // 拍照 // Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // tmpImageName = JLXCUtils.getPhotoFileName() + ""; // LogUtils.i(tmpImageName, 1); // File tmpFile = new File(FileUtil.TEMP_PATH+ tmpImageName); // intentCamera.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(tmpFile)); // startActivityForResult(intentCamera, // TAKE_PHOTO); // break; // case 1: // // 相册 // // Intent intentAlbum = new Intent( // // Intent.ACTION_GET_CONTENT); // // tmpImageName = JLXCUtils // // .getPhotoFileName() + ""; // // intentAlbum.setType(IMAGE_UNSPECIFIED); // // startActivityForResult(intentAlbum, // // ALBUM_SELECT); // Intent intentAlbum = new // Intent(PublishNewsActivity.this,GalleyActivity.class); // int imageCount = addImageLayout.getChildCount()-1; // if (imageCount < 0) { // imageCount = 0; // } // intentAlbum.putExtra(GalleyActivity.INTENT_KEY_SELECTED_COUNT,imageCount); // startActivityForResult(intentAlbum, // ALBUM_SELECT); // rightLayout.setEnabled(false); // break; // default: // break; // } // } // }).setNegativeButton("取消", null).create(); // } // // imageDialog.show(); // 设置为头像 if (selectDialog == null) { selectDialog = new CustomSelectPhotoDialog(this); selectDialog.setClicklistener( new CustomSelectPhotoDialog.ClickListenerInterface() { @Override public void onSelectGallery() { // 相册 Intent intentAlbum = new Intent(PublishNewsActivity.this, GalleyActivity.class); int imageCount = addImageLayout.getChildCount() - 1; if (imageCount < 0) { imageCount = 0; } intentAlbum.putExtra(GalleyActivity.INTENT_KEY_SELECTED_COUNT, imageCount); startActivityForResult(intentAlbum, ALBUM_SELECT); rightLayout.setEnabled(false); selectDialog.dismiss(); } @Override public void onSelectCamera() { // 拍照 Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); tmpImageName = JLXCUtils.getPhotoFileName() + ""; LogUtils.i(tmpImageName, 1); File tmpFile = new File(FileUtil.TEMP_PATH + tmpImageName); intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile)); startActivityForResult(intentCamera, TAKE_PHOTO); selectDialog.dismiss(); } }); } selectDialog.show(); }