tegarkurniawan

HoleActivity

Jan 24th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. @OnClick(R.id.next) void next() {
  2. Log.d("score", "masuk");
  3. result.get(0).getScore();
  4. Log.d("Score Activity","score is" + result.get(0).getNama());
  5. Gson gson = new Gson();
  6. String json = gson.toJson(result);
  7. System.out.println(json);
  8. Log.d("json", json);
  9. Retrofit retrofit = new Retrofit.Builder()
  10. .baseUrl(URL)
  11. .addConverterFactory(GsonConverterFactory.create())
  12. .build();
  13. RequestApi api = retrofit.create(RequestApi.class);
  14. Call<Value> call = api.holecreate(gson.toJson(result));
  15. Log.d("datas", call.toString());
  16. call.enqueue(new Callback<Value>() {
  17. @Override
  18. public void onResponse(Call<Value> call, Response<Value> response) {
  19. String value = response.body().getValue();
  20. String message = response.body().getMessage();
  21. Log.d("return", message);
  22. if (value.equals("1")) {
  23. Toast.makeText(HoleActivity.this, message, Toast.LENGTH_SHORT).show();
  24.  
  25. } else {
  26. Toast.makeText(HoleActivity.this, message, Toast.LENGTH_SHORT).show();
  27. }
  28.  
  29. }
  30.  
  31. @Override
  32. public void onFailure(Call<Value> call, Throwable t) {
  33. Log.d("return", "error");
  34. }
  35. });
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment