added save/fetch functionality to tutortab

This commit is contained in:
Marcin Jedynski 2018-11-27 13:03:45 +01:00
parent 6dbe50761a
commit c43aabf739
2 changed files with 13 additions and 10 deletions

View File

@ -154,7 +154,7 @@ public class LoginActivity extends AppCompatActivity {
private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, password);
LdapUser fuser = new LdapUser(email,password,"wmi","tutor","marek","nocny","smarek@wmi.pl");
LdapUser fuser = new LdapUser(email,password,"wmi","tutor","marek","nocny","szmare@wmi.pl");
// disposable.add(ldapService.validate(user)
disposable.add(ldapService.fakeValidate(fuser)
.subscribeOn(Schedulers.io())

View File

@ -5,6 +5,7 @@ import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@ -36,11 +37,12 @@ public class TutorTab extends AppCompatActivity {
private CompositeDisposable disposable = new CompositeDisposable();
private TextView userName;
private TextView userDutyHours;
private TextView userNote;
private EditText userNote;
private TextView userRoom;
private TextView userEmail;
private TextView department;
private Button saveButon;
private TutorTabViewModel newTab;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -53,7 +55,7 @@ public class TutorTab extends AppCompatActivity {
setContentView(R.layout.content_tutor_tab);
TextView userName = findViewById(R.id.userName);
TextView userDutyHours = findViewById(R.id.userDutyHours);
TextView userNote = findViewById(R.id.userNote);
EditText userNote = findViewById(R.id.userNote);
TextView userRoom = findViewById(R.id.userRoom);
TextView userEmail = findViewById(R.id.userEmail);
TextView department = findViewById(R.id.userDepartment);
@ -66,6 +68,7 @@ public class TutorTab extends AppCompatActivity {
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
newTab = tutorTabViewModel;
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList();
Log.d("TUTORTAB", Arrays.toString(dutyHoursList.toArray()));
@ -85,8 +88,7 @@ public class TutorTab extends AppCompatActivity {
}));
disposable.add(
// userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<User>() {
@ -102,15 +104,16 @@ public class TutorTab extends AppCompatActivity {
showError(e);
}
}));
// setUpSaveListener();
setUpSaveListener(saveButon, userNote);
}
private void setUpSaveListener() {
saveButon.setOnClickListener(new View.OnClickListener() {
private void setUpSaveListener(Button button, EditText note) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TutorTabViewModel newTab = new TutorTabViewModel();
putUserTab(newTab);
TutorTabViewModel toPost = newTab;
toPost.setNote(note.getText().toString());
putUserTab(toPost);
}
});
}