Actually in my app when I swipe my RecyclerView
it's open a custom AlertDialog if I'm doing operation with button's in it all is going as it have to be.
The issue comes when I press outside the AlertDialog because it's dismiss the AlertDialog without sending the notification to the recyclerView so the recyclerView is not turning back from the swipeMode.
How can I handle the click outside the AlertDialog? I just need to add in this handle exampleAdapter.notifyItemChanged.
Here is my AlertDialog code:
public void customAllertQuantity(final int position){
AlertDialog.Builder mBuilder = new AlertDialog.Builder(this);
@SuppressLint("InflateParams") View mView = getLayoutInflater().inflate(R.layout.alert_quantity, null);
final EditText quantita = mView.findViewById(R.id.editTextQTA);
Button buttonPiu = mView.findViewById(R.id.btnPLUS);
Button buttonMeno = mView.findViewById(R.id.btnMINUS);
ImageButton save = mView.findViewById(R.id.saveButton);
quantita.setText(String.valueOf(itemCassas.get(position).getQuant()));
mBuilder.setView(mView);
final AlertDialog dialog = mBuilder.create();
dialog.show();
buttonPiu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
quantita.setText(String.valueOf((Integer.parseInt(quantita.getText().toString()) + 1)));
}
});
buttonMeno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(Integer.parseInt(quantita.getText().toString()) > 1){
quantita.setText(String.valueOf((Integer.parseInt(quantita.getText().toString()) - 1)));
}else{
Log.i("LOG","QTA = 1");
//
}
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
double prezz = itemCassas.get(position).getImporto();
itemCassas.get(position).setQuant(Integer.parseInt(quantita.getText().toString()));
itemCassas.get(position).setPrice(prezz * itemCassas.get(position).getQuant());
TotalPrice();
exampleAdapter.notifyItemChanged(position);
dialog.dismiss();
}
});
}