Skip to content

Instantly share code, notes, and snippets.

@firdaus1453
Created July 25, 2020 11:42
Show Gist options
  • Select an option

  • Save firdaus1453/8904ad54929f95a810e5c9124f81f4c2 to your computer and use it in GitHub Desktop.

Select an option

Save firdaus1453/8904ad54929f95a810e5c9124f81f4c2 to your computer and use it in GitHub Desktop.
LoginActivity.java
public class LoginActivity extends AppCompatActivity {
@BindView(R.id.edtEmail)
EditText edtEmail;
@BindView(R.id.edtPassword)
EditText edtPassword;
@BindView(R.id.btnLogin)
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
}
@OnClick(R.id.btnLogin)
public void onViewClicked() {
BodyLogin bodyLogin = new BodyLogin();
bodyLogin.setEmail(edtEmail.getText().toString());
bodyLogin.setPassword(edtPassword.getText().toString());
RestClient.getService().postLogin(bodyLogin).enqueue(new Callback<LoginResponse>() {
// TODO method dibawah otomatis pada saat new Callback
@Override
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
Toast.makeText(LoginActivity.this, response.body().getToken(), Toast.LENGTH_SHORT).show();
Log.i("Response",response.message());
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
@Override
public void onFailure(Call<LoginResponse> call, Throwable t) {
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment