Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. private void getDetail(){
  2. String dadali ="dadali";
  3. String metland = "metland";
  4. btn_proses.setOnClickListener(new View.OnClickListener() {
  5. @Override
  6. public void onClick(View view) {
  7.  
  8. if (destination.getText().toString() == dadali) {
  9. ApiInterfaces apiInterface = Api.getUrl().create(ApiInterfaces.class);
  10. Call<Rute> call = apiInterface.getRute(1);
  11. call.enqueue(new Callback<Rute>() {
  12. @Override
  13. public void onResponse(Call<Rute> call, Response<Rute> response) {
  14.  
  15. Rute.Data data = response.body().getData();
  16. Log.e("_getproduc",data.getWaktu_tercepat());
  17. TextView rute1 = findViewById(R.id.rute1);
  18. rute1.setText("WAKTU TERCEPAT :" + data.getWaktu_tercepat());
  19. TextView jarak2 = findViewById(R.id.rute2);
  20. jarak2.setText("JARAK 1 :" + data.getJarak1() + " WAKTU =" + data.getWaktu1());
  21. TextView jarak3 = findViewById(R.id.rute3);
  22. jarak3.setText("JARAK 2 :" + data.getJarak2() + " WAKTU =" + data.getWaktu2());
  23.  
  24. }
  25.  
  26. @Override
  27. public void onFailure(Call<Rute> call, Throwable t) {
  28.  
  29. }
  30. });
  31. }
  32. else if(metland == destination.getText().toString()){
  33. ApiInterfaces apiInterface = Api.getUrl().create(ApiInterfaces.class);
  34. Call<Rute> call = apiInterface.getRute(2);
  35. call.enqueue(new Callback<Rute>() {
  36. @Override
  37. public void onResponse(Call<Rute> call, Response<Rute> response) {
  38. Rute.Data data = response.body().getData();
  39. Log.e("_getproduc",data.getWaktu_tercepat());
  40. TextView rute1 = findViewById(R.id.rute1);
  41. rute1.setText("WAKTU TERCEPAT :" + data.getWaktu_tercepat());
  42. TextView jarak2 = findViewById(R.id.rute2);
  43. jarak2.setText("JARAK 1 :" + data.getJarak1() + " WAKTU =" + data.getWaktu1());
  44. TextView jarak3 = findViewById(R.id.rute3);
  45. jarak3.setText("JARAK 2 :" + data.getJarak2() + " WAKTU =" + data.getWaktu2());
  46. }
  47.  
  48. @Override
  49. public void onFailure(Call<Rute> call, Throwable t) {
  50.  
  51. }
  52. });
  53. }
  54. }
  55. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement