Created
July 25, 2020 11:42
-
-
Save firdaus1453/8904ad54929f95a810e5c9124f81f4c2 to your computer and use it in GitHub Desktop.
LoginActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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