From 50cda1fccad49d27a47affb24c41cd5d6d4432c2 Mon Sep 17 00:00:00 2001 From: Ahmad Mustafa Date: Wed, 25 Apr 2018 22:55:02 +0300 Subject: [PATCH] improve the code i think it's good idea to reassigned the variable "state" to zero when the drive is completed --- .../java/com/simcoder/uber/DriverMapActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/simcoder/uber/DriverMapActivity.java b/app/src/main/java/com/simcoder/uber/DriverMapActivity.java index aa96e00..e2f95eb 100644 --- a/app/src/main/java/com/simcoder/uber/DriverMapActivity.java +++ b/app/src/main/java/com/simcoder/uber/DriverMapActivity.java @@ -147,6 +147,8 @@ public void onClick(View v) { case 2: recordRide(); endRide(); + // you have to reassigned this variable + status=0; break; } } @@ -185,6 +187,15 @@ public void onClick(View v) { }); getAssignedCustomer(); } + + // when the activity life cycle change + @Override + protected void onRestart() { + super.onRestart(); + if (state == 0){ + getAssignedCustomer(); + } + } private void getAssignedCustomer(){ String driverId = FirebaseAuth.getInstance().getCurrentUser().getUid(); @@ -541,4 +552,4 @@ private void erasePolylines(){ polylines.clear(); } -} \ No newline at end of file +}