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) { private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, 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.validate(user)
disposable.add(ldapService.fakeValidate(fuser) disposable.add(ldapService.fakeValidate(fuser)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())

View File

@ -5,6 +5,7 @@ import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -36,11 +37,12 @@ public class TutorTab extends AppCompatActivity {
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
private TextView userName; private TextView userName;
private TextView userDutyHours; private TextView userDutyHours;
private TextView userNote; private EditText userNote;
private TextView userRoom; private TextView userRoom;
private TextView userEmail; private TextView userEmail;
private TextView department; private TextView department;
private Button saveButon; private Button saveButon;
private TutorTabViewModel newTab;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -53,7 +55,7 @@ public class TutorTab extends AppCompatActivity {
setContentView(R.layout.content_tutor_tab); setContentView(R.layout.content_tutor_tab);
TextView userName = findViewById(R.id.userName); TextView userName = findViewById(R.id.userName);
TextView userDutyHours = findViewById(R.id.userDutyHours); 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 userRoom = findViewById(R.id.userRoom);
TextView userEmail = findViewById(R.id.userEmail); TextView userEmail = findViewById(R.id.userEmail);
TextView department = findViewById(R.id.userDepartment); TextView department = findViewById(R.id.userDepartment);
@ -66,6 +68,7 @@ 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;
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()));
@ -85,7 +88,6 @@ public class TutorTab extends AppCompatActivity {
})); }));
disposable.add( disposable.add(
// userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
userService.getUserById(PrefUtils.getUserId(getApplicationContext())) userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -102,15 +104,16 @@ public class TutorTab extends AppCompatActivity {
showError(e); showError(e);
} }
})); }));
// setUpSaveListener(); setUpSaveListener(saveButon, userNote);
} }
private void setUpSaveListener() { private void setUpSaveListener(Button button, EditText note) {
saveButon.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
TutorTabViewModel newTab = new TutorTabViewModel(); TutorTabViewModel toPost = newTab;
putUserTab(newTab); toPost.setNote(note.getText().toString());
putUserTab(toPost);
} }
}); });
} }