Guest User

Untitled

a guest
Nov 28th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. buttonLogin.setOnClickListener{
  2. //val intent = Intent(this, MainActivity::class.java);
  3. //startActivity(intent);
  4. val email = editTextLogin.text.toString().trim();
  5. val password = editTextPassword.text.toString().trim();
  6.  
  7.  
  8. val call : retrofit2.Call<User> = RetrofitClient.create().login(email, password)
  9. call.enqueue(object : retrofit2.Callback<User>{
  10. override fun onFailure(call: retrofit2.Call<User>?, t:Throwable?){
  11.  
  12. }
  13.  
  14. override fun onResponse(call:retrofit2.Call<User>?, response: Response<User>){
  15.  
  16.  
  17. if(response.isSuccessful){
  18.  
  19. val user: User = response.body()!!
  20.  
  21. if(user.success.equals("true")){
  22. Log.d("", "onResponse()");
  23.  
  24.  
  25. }
  26. else {
  27. Log.d("", "onFail()");
  28. }
  29. }
  30. }
  31. })
  32.  
  33. @FormUrlEncoded
  34. @POST("/login")
  35. fun login(@Field("email") email: String,
  36. @Field("password") password: String)
  37. : retrofit2.Call<User>;
  38. //fun login(@Query("login")login: String, @Query("password")password:String) : retrofit2.Call<User>
  39.  
  40. class User {
  41. var success : String = "";
  42. }
Add Comment
Please, Sign In to add comment