0

I have this android application where the user fill up their food order and some other data, and then pressed the button so that the data will be inserted to the firebase DB and then the application will go to the menu activity again through intent.

but here's the problem, after pressing the button there will be some seconds where the user can still press the button again, so the data in the database can be duplicated. is there anyway to prevent this?

here's the insert code

Date date = new Date();
String name = edtName.getText().toString();
String note = edtNote.getText().toString();
String tableNum = noMeja;
DBOrderDataModel order = new DBOrderDataModel(name, note, tableNum, date, orderList, totalharga);
order.setOnProcess(true);
ForinFirebase DBForin = new ForinFirebase();
    
DBForin.add(order)
       .addOnSuccessListener(suc -> {
            limitPress = 1;
            Toast.makeText(this, "Pesanan Anda Berhasil Ditambahkan", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(PesananActivity.this, Keterangan.class));
        }).addOnFailureListener(er -> {
            Toast.makeText(this, "Terjadi Kesalahan Dalam Memasukkan Pesananan Anda", Toast.LENGTH_LONG).show();
        });
hiddeneyes02
  • 2,562
  • 1
  • 31
  • 58
Dapa
  • 11
  • 1
  • 2

0 Answers0