Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buttonLogin.setOnClickListener{
- //val intent = Intent(this, MainActivity::class.java);
- //startActivity(intent);
- val email = editTextLogin.text.toString().trim();
- val password = editTextPassword.text.toString().trim();
- val call : retrofit2.Call<User> = RetrofitClient.create().login(email, password)
- call.enqueue(object : retrofit2.Callback<User>{
- override fun onFailure(call: retrofit2.Call<User>?, t:Throwable?){
- }
- override fun onResponse(call:retrofit2.Call<User>?, response: Response<User>){
- if(response.isSuccessful){
- val user: User = response.body()!!
- if(user.success.equals("true")){
- Log.d("", "onResponse()");
- }
- else {
- Log.d("", "onFail()");
- }
- }
- }
- })
- @FormUrlEncoded
- @POST("/login")
- fun login(@Field("email") email: String,
- @Field("password") password: String)
- : retrofit2.Call<User>;
- //fun login(@Query("login")login: String, @Query("password")password:String) : retrofit2.Call<User>
- class User {
- var success : String = "";
- }
Add Comment
Please, Sign In to add comment