Witam , mam maly problem z logowaniem do aplikacji . Czy mogłby ktos pomoc , badz wyjasnic co robie nie tak ... Po odpaleniu i kliknieciu przycisku nie wystepuja zadne błedy ... Dodam ze program pisany jest w kotlinie . OTO kod :
package pl.progressif.bdmanager
import com.google.gson.annotations.SerializedName
class User {
var success : String = "";
}
package pl.progressif.bdmanager
import android.telecom.Call
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import retrofit2.http.Query
import java.util.*
interface Api {
@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>
}
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()");
}
}
}
})
}