@Override
 protected Object doInBackground(Object[] params) {
   GetData gd = new GetData();
   try {
     res = gd.Passenger_RateDriver(Driver_ID, Passenger_ID, Route_ID, NoOfStars);
   } catch (JSONException e) {
     e.printStackTrace();
   }
   return null;
 }
    @Override
    protected void onPostExecute(Object o) {

      SupportMapFragment mapFragment =
          (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_ride_details);
      mapFragment.getMapAsync(this);

      //            if (FLAG_HIDE_JOIN==1) {
      //                Join_Ride_btn.setVisibility(View.VISIBLE);

      //            }

      if (FLAG_HIDE_JOIN == 2) {

        ratingBar.setVisibility(View.VISIBLE);
        Join_Ride_btn.setVisibility(View.INVISIBLE);
        Passenger_Review_Driver_Btn.setVisibility(View.VISIBLE);
      }
      if (FLAG_HIDE_JOIN == 5) {

        Join_Ride_btn.setVisibility(View.INVISIBLE);
      }

      if (FLAG_REVIEW == 0) {
        Relative_REviews.setVisibility(View.INVISIBLE);
        Relative_REviews_Address_2.setVisibility(View.INVISIBLE);
      }

      DriverGetReviewAdapter arrayAdapter =
          new DriverGetReviewAdapter(con, driverGetReviewDataModels_arr);
      Driver_get_Review_lv.setAdapter(arrayAdapter);
      setListViewHeightBasedOnChildren(Driver_get_Review_lv);

      Passenger_Review_Driver_Btn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (Passenger_ID == 0) {
                final Dialog dialog = new Dialog(RideDetailsAsPassenger.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.please_log_in_dialog);
                Button btn = (Button) dialog.findViewById(R.id.noroute_id);
                TextView Text_3 = (TextView) dialog.findViewById(R.id.Text_3);
                Button No_Btn = (Button) dialog.findViewById(R.id.No_Btn);
                Text_3.setText(getString(R.string.login_first));
                dialog.show();
                No_Btn.setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        dialog.dismiss();
                      }
                    });
                btn.setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        dialog.dismiss();
                        Intent intent =
                            new Intent(RideDetailsAsPassenger.this, LoginApproved.class);
                        RideDetailsAsPassenger.this.startActivity(intent);
                      }
                    });
              } else {

                Review_str = "";
                final Dialog dialog = new Dialog(con);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.review_dialog);
                Button btn = (Button) dialog.findViewById(R.id.Review_Btn);
                final TextView Review_Empty_Error =
                    (TextView) dialog.findViewById(R.id.Review_Empty_Error);
                Edit_Review_txt = (EditText) dialog.findViewById(R.id.Edit_Review_txt);
                dialog.show();
                btn.setOnClickListener(
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {

                        Review_str = Edit_Review_txt.getText().toString();

                        if (!Review_str.equals("")) {
                          Review_Empty_Error.setVisibility(View.INVISIBLE);
                          try {
                            String response =
                                j.Passenger_Review_Driver(
                                    Driver_ID,
                                    Passenger_ID,
                                    Route_ID,
                                    URLEncoder.encode(Review_str));
                            if (response.equals("\"-1\"") || response.equals("\"-2\'")) {
                              Toast.makeText(
                                      RideDetailsAsPassenger.this,
                                      getString(R.string.cannot_review),
                                      Toast.LENGTH_SHORT)
                                  .show();
                            } else {
                              Toast.makeText(
                                      RideDetailsAsPassenger.this,
                                      getString(R.string.done),
                                      Toast.LENGTH_SHORT)
                                  .show();
                              con.recreate();
                            }
                            dialog.dismiss();
                          } catch (JSONException e) {
                            e.printStackTrace();
                          }

                        } //  if review is null
                        else {
                          Review_Empty_Error.setVisibility(View.VISIBLE);
                        }
                      }
                    });
              }
            }
          });

      if (exists) {
        try {
          ratingBar.setRating(
              Float.parseFloat(j.Passenger_GetDriverRate(Driver_ID, Passenger_ID, Route_ID)));
          ratingBar.setOnRatingBarChangeListener(
              new RatingBar.OnRatingBarChangeListener() {
                @Override
                public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                  NoOfStars = (int) rating;
                  new rateDriver().execute();
                }
              });
          days = "";
          FromRegionEnName.setText(json.getString(getString(R.string.from_reg_en_name)));
          ToRegionEnName.setText(json.getString(getString(R.string.fto_reg_en_name)));
          FromEmirateEnName.setText(json.getString(getString(R.string.from_em_en_name)));
          ToEmirateEnName.setText(json.getString(getString(R.string.to_em_en_name)));

          FromRegionEnName_Str = (json.getString(getString(R.string.from_reg_en_name)));
          ToRegionEnName_Str = (json.getString(getString(R.string.fto_reg_en_name)));
          FromEmirateEnName_Str = (json.getString(getString(R.string.from_em_en_name)));
          ToEmirateEnName_Str = (json.getString(getString(R.string.to_em_en_name)));

          str_StartFromTime = json.getString("StartFromTime");
          No_Seats = json.getInt("NoOfSeats");
          if (No_Seats == 0) {
            Join_Ride_btn.setVisibility(View.INVISIBLE);
          }
          if (str_StartFromTime.equals("null")) {
            str_StartFromTime = getString(R.string.not_set);
            StartFromTime.setText(str_StartFromTime);
          } else {
            str_StartFromTime =
                str_StartFromTime.substring(Math.max(0, str_StartFromTime.length() - 7));
            StartFromTime.setText(str_StartFromTime);
          }
          str_EndToTime_ = json.getString("EndToTime_");
          if (str_EndToTime_.equals("null")) {
            str_EndToTime_ = getString(R.string.not_set);
            // EndToTime_.setText(str_EndToTime_);
          } else {
            str_EndToTime_ = str_EndToTime_.substring(Math.max(0, str_EndToTime_.length() - 7));
            Log.d("time to", str_EndToTime_);
            // EndToTime_.setText(str_EndToTime_);
          }
          if (json.getString(getString(R.string.nat_name2)).equals("null")) {
            NationalityEnName.setText(getString(R.string.not_set));
          } else {
            NationalityEnName.setText(json.getString(getString(R.string.nat_name2)));
          }
          if (json.getString("PrefLanguageId").equals("0")
              || json.getString("PrefLanguageId").equals("null")) {
            PrefLanguageEnName.setText(getString(R.string.not_set));
          } else {
            PrefLanguageEnName.setText(json.getString(getString(R.string.pref_lang)));
          }
          if (json.getString("AgeRangeID").equals("0")
              || json.getString("AgeRangeID").equals("null")) {
            AgeRange.setText(getString(R.string.not_set));
          } else {
            AgeRange.setText(json.getString("AgeRange"));
          }
          Gender_ste = "";
          Gender_ste = json.getString("PreferredGender");
          switch (Gender_ste) {
            case "M":
              Gender_ste = getString(R.string.reg_gender_male);
              break;
            case "F":
              Gender_ste = getString(R.string.reg_gender_female);
              break;
            default:
              Gender_ste = getString(R.string.not_set);
              break;
          }
          PreferredGender.setText(Gender_ste);
          Smokers_str = "";
          Smokers_str = json.getString("IsSmoking");
          if (Smokers_str.equals("true")) {
            Smokers_str = getString(R.string.Accept_Smokers_txt);
          } else if (Smokers_str.equals("false")) {
            Smokers_str = getString(R.string.not_set);
          } else {
            Smokers_str = getString(R.string.not_set);
          }

          IsSmoking.setText(Smokers_str);
          StartLat = json.getDouble("StartLat");
          StartLng = json.getDouble("StartLng");
          EndLat = json.getDouble("EndLat");
          EndLng = json.getDouble("EndLng");
          Log.d("S Lat", String.valueOf(StartLat));

          if (json.getString("Saturday").equals("true")) {
            days += getString(R.string.sat);
          }
          if (json.getString("Sunday").equals("true")) {
            days += getString(R.string.sun);
          }
          if (json.getString("Monday").equals("true")) {
            days += getString(R.string.mon);
          }
          if (json.getString("Tuesday").equals("true")) {
            days += getString(R.string.tue);
          }
          if (json.getString("Wednesday").equals("true")) {
            days += getString(R.string.wed);
          }
          if (json.getString("Thursday").equals("true")) {
            days += getString(R.string.thu);
          }
          if (json.getString("Friday").equals("true")) {
            days += getString(R.string.fri);
          }
          if (!days.equals("")) {
            ride_details_day_of_week.setText(days.substring(1));
          } else {
            ride_details_day_of_week.setText(days);
          }
          days = "";

        } catch (JSONException e) {
          e.printStackTrace();
        }

        Join_Ride_btn.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (Passenger_ID == 0) {
                  final Dialog dialog = new Dialog(RideDetailsAsPassenger.this);
                  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  dialog.setContentView(R.layout.please_log_in_dialog);
                  Button btn = (Button) dialog.findViewById(R.id.noroute_id);
                  TextView Text_3 = (TextView) dialog.findViewById(R.id.Text_3);
                  Button No_Btn = (Button) dialog.findViewById(R.id.No_Btn);
                  Text_3.setText(getString(R.string.login_first));
                  dialog.show();
                  No_Btn.setOnClickListener(
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          dialog.dismiss();
                        }
                      });
                  btn.setOnClickListener(
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          dialog.dismiss();
                          Intent intent =
                              new Intent(RideDetailsAsPassenger.this, LoginApproved.class);
                          RideDetailsAsPassenger.this.startActivity(intent);
                        }
                      });
                } else {
                  final Dialog dialog = new Dialog(con);
                  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  dialog.setContentView(R.layout.review_dialog);
                  Button btn = (Button) dialog.findViewById(R.id.Review_Btn);
                  TextView Lang_Dialog_txt_id =
                      (TextView) dialog.findViewById(R.id.Lang_Dialog_txt_id);
                  TextView Review_text_address =
                      (TextView) dialog.findViewById(R.id.Review_text_address);
                  Edit_Review_txt = (EditText) dialog.findViewById(R.id.Edit_Review_txt);
                  Lang_Dialog_txt_id.setText(R.string.write_remark);
                  Review_text_address.setText(R.string.your_remarks);
                  Edit_Review_txt.setText(R.string.i_like_join_ride);
                  dialog.show();
                  btn.setOnClickListener(
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          str_Remarks = Edit_Review_txt.getText().toString();
                          String response = null;
                          try {
                            response =
                                j.Passenger_SendAlert(
                                    Driver_ID,
                                    Passenger_ID,
                                    Route_ID,
                                    URLEncoder.encode(str_Remarks));
                          } catch (JSONException e) {
                            e.printStackTrace();
                          }
                          assert response != null;
                          switch (response) {
                            case "\"-1\"":
                              Toast.makeText(
                                      RideDetailsAsPassenger.this,
                                      getString(R.string.already_sent_request),
                                      Toast.LENGTH_SHORT)
                                  .show();
                              dialog.dismiss();
                              break;
                            case "\"0\"":
                              Toast.makeText(
                                      RideDetailsAsPassenger.this,
                                      getString(R.string.login_network_error),
                                      Toast.LENGTH_SHORT)
                                  .show();
                              dialog.dismiss();
                              break;
                            default:
                              Toast.makeText(
                                      RideDetailsAsPassenger.this,
                                      R.string.req_sent_succ,
                                      Toast.LENGTH_LONG)
                                  .show();
                              dialog.dismiss();
                              Join_Ride_btn.setVisibility(View.INVISIBLE);
                              finish();
                              break;
                          }
                        }
                      });
                }
              }
            });

        //
        //                Passenger_Review_Driver_Btn.setOnClickListener(new View.OnClickListener()
        // {
        //                    @Override
        //                    public void onClick(View v) {
        //                        if (Passenger_ID == 0) {
        //                            final Dialog dialog = new Dialog(RideDetailsPassenger.this);
        //                            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //                            dialog.setContentView(R.layout.please_log_in_dialog);
        //                            Button btn = (Button) dialog.findViewById(R.id.noroute_id);
        //                            TextView Text_3 = (TextView) dialog.findViewById(R.id.Text_3);
        //                            Button No_Btn = (Button) dialog.findViewById(R.id.No_Btn);
        //                            Text_3.setText("In order to proceed you have to login first");
        //                            dialog.show();
        //
        //                            No_Btn.setOnClickListener(new View.OnClickListener() {
        //                                @Override
        //                                public void onClick(View v) {
        //                                    dialog.dismiss();
        //                                }
        //                            });
        //
        //                            btn.setOnClickListener(new View.OnClickListener() {
        //                                @Override
        //                                public void onClick(View v) {
        //                                    dialog.dismiss();
        //                                    Intent intent = new Intent(RideDetailsPassenger.this,
        // LoginApproved.class);
        //                                    RideDetailsPassenger.this.startActivity(intent);
        //
        //                                }
        //                            });
        //                        } else {
        //
        //
        //                            final GetData j = new GetData();
        //                            Review_str = "";
        //                            final Dialog dialog = new Dialog(con);
        //                            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //                            dialog.setContentView(R.layout.review_dialog);
        //                            Button btn = (Button) dialog.findViewById(R.id.Review_Btn);
        //                            Edit_Review_txt = (EditText)
        // dialog.findViewById(R.id.Edit_Review_txt);
        //                            dialog.show();
        //
        //                            btn.setOnClickListener(new View.OnClickListener() {
        //                                @Override
        //                                public void onClick(View v) {
        //                                    Review_str = Edit_Review_txt.getText().toString();
        //                                    try {
        //                                        String response =
        // j.Passenger_Review_Driver(Driver_ID, Passenger_ID, Route_ID,
        // URLEncoder.encode(Review_str));
        //                                        if (response.equals("\"-1\"") ||
        // response.equals("\"-2\'")) {
        //                                            Toast.makeText(RideDetailsPassenger.this,
        // "Cannot Review", Toast.LENGTH_SHORT).show();
        //                                        } else {
        //                                            Toast.makeText(RideDetailsPassenger.this,
        // "Done", Toast.LENGTH_SHORT).show();
        //                                        }
        //                                        dialog.dismiss();
        //                                    } catch (JSONException e) {
        //                                        e.printStackTrace();
        //                                    }
        //                                }
        //                            });
        //
        //
        //                        } //else
        //                    } // on click view
        //                });
        hidePDialog();
      }
    }
  private void CreateNotification(int y) {
    GetData gd = new GetData();
    try {
      JSONArray jsonArray = gd.GetDriverAlertsForRequest(Integer.parseInt(ID));
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject j = jsonArray.getJSONObject(i);
        Intent intent = new Intent(this, DriverAlertsForRequest.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        Notification.Builder builder = new Notification.Builder(this);
        builder.setContentTitle(getString(R.string.route) + j.getString("RouteName"));
        builder.setContentText(
            j.getString("PassengerName") + getString(R.string.send_you_join_request));
        builder.setSmallIcon(R.drawable.sharekni_logo);
        builder.setContentIntent(pendingIntent);
        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.notify(y, notification);
      }

    } catch (JSONException e) {
      e.printStackTrace();
    }

    try {
      JSONArray jsonArray = gd.Get_Passenger_GetAcceptedRequestsFromDriver(Integer.parseInt(ID));
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject j = jsonArray.getJSONObject(i);
        Intent intent = new Intent(this, DriverAlertsForRequest.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        Notification.Builder builder = new Notification.Builder(this);
        builder.setContentTitle(getString(R.string.route) + j.getString("RouteName"));
        builder.setContentText(j.getString("DriverName") + getString(R.string.accept_your_request));
        builder.setSmallIcon(R.drawable.notificationlogo);
        builder.setContentIntent(pendingIntent);
        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.notify(y, notification);
      }

    } catch (JSONException e) {
      e.printStackTrace();
    }

    try {
      JSONArray jsonArray = gd.Passenger_AlertsForInvitation(Integer.parseInt(ID));
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject j = jsonArray.getJSONObject(i);
        Intent intent = new Intent(this, DriverAlertsForRequest.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        Notification.Builder builder = new Notification.Builder(this);
        builder.setContentTitle(getString(R.string.route) + j.getString("RouteName"));
        builder.setContentText(j.getString("DriverName") + getString(R.string.Sent_Invite));
        builder.setSmallIcon(R.drawable.notificationlogo);
        builder.setContentIntent(pendingIntent);
        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        manager.notify(y, notification);
      }

    } catch (JSONException e) {
      e.printStackTrace();
    }
  }