Add duty hours to user information modal
This commit is contained in:
parent
299e25d0f9
commit
4701387d48
@ -57,5 +57,6 @@ dependencies {
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
||||
implementation 'com.annimon:stream:1.2.1'
|
||||
implementation 'com.facebook.shimmer:shimmer:0.3.0'
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -18,6 +20,7 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.DutyHour;
|
||||
@ -44,6 +47,8 @@ import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class UsersListActivity extends BaseActivity {
|
||||
private static final String TAG = UsersListActivity.class.getSimpleName();
|
||||
@BindView(R.id.coordinator_layout)
|
||||
@ -120,8 +125,12 @@ public class UsersListActivity extends BaseActivity {
|
||||
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(this);
|
||||
alertDialogBuilderUserInput.setView(view);
|
||||
|
||||
alertDialogBuilderUserInput.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||
// User cancelled the dialog
|
||||
});
|
||||
|
||||
TextView userName = view.findViewById(R.id.userName);
|
||||
TextView userDutyHours = view.findViewById(R.id.userDutyHours);
|
||||
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
|
||||
TextView userNote = view.findViewById(R.id.userNote);
|
||||
TextView userRoom = view.findViewById(R.id.userRoom);
|
||||
TextView userEmail = view.findViewById(R.id.userEmail);
|
||||
@ -133,19 +142,22 @@ public class UsersListActivity extends BaseActivity {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
||||
Log.e("TUTOR_TAB",tutorTabViewModel.toString());
|
||||
|
||||
List<String> dutyHourslist = Stream.of(tutorTabViewModel.getDutyHours())
|
||||
.map(DutyHourViewModel::toString).toList();
|
||||
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
||||
.map(DutyHourViewModel::getSummary).toList();
|
||||
|
||||
userRoom.setText(tutorTabViewModel.getRoom());
|
||||
userEmail.setText(tutorTabViewModel.getEmailTutorTab());
|
||||
userNote.setText(tutorTabViewModel.getNote());
|
||||
userRoom.setText(getString(R.string.userRoom) + ": " + tutorTabViewModel.getRoom());
|
||||
userEmail.setText(getString(R.string.userEmail) + ": " + tutorTabViewModel.getEmailTutorTab());
|
||||
userNote.setText(getString(R.string.userNote) + ": " + tutorTabViewModel.getNote());
|
||||
|
||||
if(dutyHourslist.size() > 0)
|
||||
userDutyHours.setText(dutyHourslist.get(0));
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(UsersListActivity.this,
|
||||
android.R.layout.simple_list_item_activated_1,dutyHoursList);
|
||||
|
||||
userDutyHours.setAdapter(arrayAdapter);
|
||||
|
||||
|
||||
}
|
||||
@ -159,7 +171,7 @@ public class UsersListActivity extends BaseActivity {
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fetchAllTutors() {
|
||||
@ -202,8 +214,6 @@ public class UsersListActivity extends BaseActivity {
|
||||
showError(e);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showError(Throwable e) {
|
||||
|
@ -94,6 +94,11 @@ public class DutyHourViewModel {
|
||||
return Objects.hash(day, start, end);
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return this.getDay() + " " + this.getStart() + " " + this.getEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -22,13 +22,13 @@ public class TutorTabViewModel {
|
||||
private String userId = null;
|
||||
|
||||
@SerializedName("room")
|
||||
private String room = null;
|
||||
private String room = "";
|
||||
|
||||
@SerializedName("emailTutorTab")
|
||||
private String emailTutorTab = null;
|
||||
private String emailTutorTab = "";
|
||||
|
||||
@SerializedName("note")
|
||||
private String note = null;
|
||||
private String note = "";
|
||||
|
||||
@SerializedName("dutyHours")
|
||||
private List<DutyHourViewModel> dutyHours = null;
|
||||
@ -112,6 +112,9 @@ public class TutorTabViewModel {
|
||||
|
||||
|
||||
public String getNote() {
|
||||
if(note == null)
|
||||
return "";
|
||||
|
||||
return note;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
|
||||
<TextView android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -33,6 +34,14 @@
|
||||
android:textColor="@color/note_list_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userDutyHoursTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/userDutyHoursHeader"
|
||||
android:textColor="@color/note_list_text"
|
||||
tools:text="Dyżury:" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/userDutyHours"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -44,5 +53,4 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/note_list_text" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -2,7 +2,7 @@
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#9ef13f</color>
|
||||
<color name="colorAccent">#dc0004</color>
|
||||
<color name="msg_no_notes">#999</color>
|
||||
<color name="hint_enter_note">#89c3c3c3</color>
|
||||
<color name="timestamp">#858585</color>
|
||||
|
@ -198,4 +198,9 @@ functionality.</string>
|
||||
|
||||
<string name="title_activity_main2">Main2Activity</string>
|
||||
<string name="there_is_no_users_in_system">There is no users in system</string>
|
||||
<string name="cancel">Close</string>
|
||||
<string name="userRoom">Pokój</string>
|
||||
<string name="userEmail">Email</string>
|
||||
<string name="userNote">Notatka</string>
|
||||
<string name="userDutyHoursHeader">Dyżury:</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user