use of io.classify.service.UserService in project classify-system by anverliedoit.
the class LoginActivity method doLogin.
@Override
public void doLogin(final String _username, final String _password) {
Log.i(TAG, "doLogin");
progressBar.setVisibility(View.VISIBLE);
screen.setVisibility(View.VISIBLE);
username = _username;
password = _password;
UserService userService = new DI().getRetrofit().create(UserService.class);
userService.getByUsername(username).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<User>() {
@Override
public void accept(User user) throws Exception {
if (user.getPassword().equals(password)) {
teacherHelper.saveUser(user.getTeacherId());
Intent intent = new Intent(getApplicationContext(), MainActivity2.class);
intent.putExtra("teacherId", user.getTeacherId());
isVaild = true;
startActivity(intent);
} else {
if (!isVaild)
Toast.makeText(LoginActivity.this, "Incorrect username or password", Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.INVISIBLE);
screen.setVisibility(View.INVISIBLE);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (!isVaild)
Toast.makeText(LoginActivity.this, "Incorrect username or password", Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.INVISIBLE);
screen.setVisibility(View.INVISIBLE);
}
});
}
use of io.classify.service.UserService in project classify-system by anverliedoit.
the class ActivityChangePassword method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_changepassword);
text1 = findViewById(R.id.activity_changepassword_text1);
text2 = findViewById(R.id.activity_changepassword_text2);
button = findViewById(R.id.activityt_changepassword_button);
btnCancel = findViewById(R.id.activityt_changepassword_button_cancel);
progressBar = findViewById(R.id.progressbar_cp);
button.setOnClickListener(this);
btnCancel.setOnClickListener(this);
retrofit = new DI().getRetrofit();
userService = retrofit.create(UserService.class);
teacherService = new TeacherServiceImpl();
progressBar.setVisibility(View.INVISIBLE);
try {
teacher = teacherService.getTeacherById(getIntent().getExtras().getLong("teacherId"));
} catch (Exception e) {
e.printStackTrace();
teacher = new Teacher();
}
}
Aggregations