I have two dynamic check box one is for deleting video and another is for saving video.I want to add a confirm box so that it confirms my action when i click on checkbox.How to add the confirm box in my code?
deleteCheckBox.setOnClickListener(deleteRelatedThumbnail(deleteCheckBox));
View.OnClickListener deleteRelatedThumbnail(final CheckBox checkBox) {
return new View.OnClickListener() {
public void onClick(View v) {
int index = checkBox.getId();
if (((CheckBox) v).isChecked() && deleteVideoFile(index - 1)){
// if(deleteVideoFile(index-1)){
bitMapsAvailable.remove(index - 1);
bitMapsFilePath.remove(index - 1);
Toast.makeText(MainActivity.this, "Selected video file is deleted successfully.", Toast.LENGTH_SHORT).show();
showThumbnails();
}else{
Toast.makeText(MainActivity.this, "Not deleted", Toast.LENGTH_SHORT).show();
}
}
};
}
saveCheckBox.setOnClickListener(saveRelatedThumbnail(saveCheckBox));
View.OnClickListener saveRelatedThumbnail(final CheckBox checkBox) {
return new View.OnClickListener() {
public void onClick(View v) {
int index = checkBox.getId()-31;
if (((CheckBox) v).isChecked()){
String src = bitMapsFilePath.get(index-1);
String destination = mVideoFolder+"/"+new File(src).getName();
File srcFile = new File(src);
srcFile.renameTo(new File(destination));
Toast.makeText(MainActivity.this, "Saved in "+destination, Toast.LENGTH_SHORT).show();
bitMapsAvailable.clear();
for(String filePath: bitMapsFilePath ) {
File file = new File(filePath);
file.delete();
}
bitMapsFilePath.clear();
Toast.makeText(MainActivity.this, "Temporary videos are deleted successfully",Toast.LENGTH_SHORT).show();
showThumbnails();
}
}
};
}