fixed post update tutortab

This commit is contained in:
Marcin Jedynski 2018-11-27 14:51:55 +01:00
parent c43aabf739
commit e96981c8b9
2 changed files with 18 additions and 4 deletions

View File

@ -60,6 +60,7 @@ public class TutorTab extends AppCompatActivity {
TextView userEmail = findViewById(R.id.userEmail); TextView userEmail = findViewById(R.id.userEmail);
TextView department = findViewById(R.id.userDepartment); TextView department = findViewById(R.id.userDepartment);
Button saveButon = findViewById(R.id.saveButon); Button saveButon = findViewById(R.id.saveButon);
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext()))); userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
disposable.add( disposable.add(
tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext())) tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext()))
@ -68,7 +69,9 @@ public class TutorTab extends AppCompatActivity {
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() { .subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override @Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) { public void onSuccess(TutorTabViewModel tutorTabViewModel) {
newTab = tutorTabViewModel; // newTab = tutorTabViewModel;
// Log.d("TUTORTAB onsuc toPost",newTab.toString());
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours()) List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList(); .map(DutyHourViewModel::getSummary).toList();
Log.d("TUTORTAB", Arrays.toString(dutyHoursList.toArray())); Log.d("TUTORTAB", Arrays.toString(dutyHoursList.toArray()));
@ -111,9 +114,12 @@ public class TutorTab extends AppCompatActivity {
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
TutorTabViewModel toPost = newTab; newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),note.getText().toString());
toPost.setNote(note.getText().toString()); Log.d("TUTORTAB button",note.getText().toString());
putUserTab(toPost); Log.d("TUTORTAB toPost",newTab.toString());
//topost jest nullem
// toPost.setNote(note.getText().toString());
putUserTab(newTab);
} }
}); });
} }

View File

@ -33,11 +33,19 @@ public class TutorTabViewModel {
@SerializedName("dutyHours") @SerializedName("dutyHours")
private List<DutyHourViewModel> dutyHours = null; private List<DutyHourViewModel> dutyHours = null;
public TutorTabViewModel(String userId, String note){
this.userId=userId;
// this.room=room;
// this.emailTutorTab=emailTutorTab;
this.note=note;
}
public TutorTabViewModel tutorTabId(UUID tutorTabId) { public TutorTabViewModel tutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId; this.tutorTabId = tutorTabId;
return this; return this;
} }
/** /**
* Get tutorTabId * Get tutorTabId
* @return tutorTabId * @return tutorTabId