working dutyhour adapter

This commit is contained in:
marcin.jedynski 2018-12-15 17:35:20 +01:00
parent 0884fc4873
commit baa8cac0e4
7 changed files with 131 additions and 137 deletions

View File

@ -1,29 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

View File

@ -2,16 +2,21 @@ package com.uam.wmi.findmytutor.activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.DutyHoursAdapter;
import com.uam.wmi.findmytutor.model.DutyHour;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User;
@ -43,27 +48,35 @@ public class TutorTab extends AppCompatActivity {
private TextView userEmail;
private TextView department;
private Button saveButon;
private List<DutyHourViewModel> dutyHourList;
private RecyclerView dutyHoursRecycller;
private RecyclerView.Adapter dutyHoursAdapter;
private RecyclerView.LayoutManager dutyHoursLayoutManager;
private TutorTabViewModel newTab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tutorTabService = ApiClient.getClient(getApplicationContext())
.create(TutorTabApi.class);
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
setContentView(R.layout.content_tutor_tab);
TextView userName = findViewById(R.id.userName);
TextView userDutyHours = findViewById(R.id.userDutyHours);
// TextView userDutyHours = findViewById(R.id.userDutyHours);
EditText userNote = findViewById(R.id.userNote);
TextView userRoom = findViewById(R.id.userRoom);
TextView userEmail = findViewById(R.id.userEmail);
TextView department = findViewById(R.id.userDepartment);
Button saveButon = findViewById(R.id.saveButon);
findViewById(R.id.contentTutorTabInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_tutor_tab));
dutyHoursRecycller = (RecyclerView) findViewById(R.id.dutyHourView);
dutyHoursLayoutManager = new LinearLayoutManager(this);
dutyHoursRecycller.setLayoutManager(dutyHoursLayoutManager);
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
tutorTabService = ApiClient.getClient(getApplicationContext())
.create(TutorTabApi.class);
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
disposable.add(
tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io())
@ -71,12 +84,22 @@ public class TutorTab extends AppCompatActivity {
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
Log.d("dupa tab", tutorTabViewModel.toString());
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList();
dutyHourList = tutorTabViewModel.getDutyHours();
if(dutyHourList == null){
Log.d("dupa godziny","null godziny");
}else{
userRoom.setText(String.format("%s: %s", getString(R.string.userRoom), tutorTabViewModel.getRoom()));
userEmail.setText(String.format("%s: %s", getString(R.string.userEmail), tutorTabViewModel.getEmailTutorTab()));
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),dutyHourList);
dutyHoursRecycller.setAdapter(dutyHoursAdapter);
Log.d("dupa godziny",dutyHourList.toString());
}
// List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
// .map(DutyHourViewModel::getSummary).toList();
userRoom.setText(String.format("%s", tutorTabViewModel.getRoom()));
userEmail.setText(String.format("%s", tutorTabViewModel.getEmailTutorTab()));
if (!tutorTabViewModel.getNote().equals("")) {
userNote.setText(String.format("%s", tutorTabViewModel.getNote()));
}
@ -89,6 +112,13 @@ public class TutorTab extends AppCompatActivity {
showError(e);
}
}));
findViewById(R.id.contentTutorTabInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_tutor_tab));
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
disposable.add(
userService.getUserById(PrefUtils.getUserId(getApplicationContext()))

View File

@ -9,6 +9,9 @@ import android.view.ViewGroup;
import android.widget.TextView;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.DutyHour;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -16,11 +19,11 @@ import butterknife.ButterKnife;
public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyViewHolder> {
private Context context;
private List<DutyHour> hours;
private List<DutyHourViewModel> hours;
public DutyHoursAdapter(Context context, List<DutyHour> hours) {
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours) {
this.context = context;
this.hours = hours;
this.hours = new ArrayList<DutyHourViewModel>(hours);
}
@NonNull
@ -34,7 +37,7 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
DutyHour duty = hours.get(position);
DutyHourViewModel duty = hours.get(position);
holder.dutyDay.setText(duty.getDay());
holder.dutyStart.setText(duty.getStart());
holder.dutyStop.setText(duty.getEnd());
@ -48,13 +51,13 @@ public int getItemCount() {
class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.duty_day)
@BindView(R.id.duty_day_value)
TextView dutyDay;
@BindView(R.id.duty_start)
@BindView(R.id.duty_start_value)
TextView dutyStart;
@BindView(R.id.duty_stop)
@BindView(R.id.duty_stop_value)
TextView dutyStop;
MyViewHolder(View view) {

View File

@ -33,6 +33,9 @@ public class DutyHour extends BaseResponse {
public DutyHour dutyHourId(UUID dutyHourId) {
this.dutyHourId = dutyHourId;
return this;
}
public DutyHour(){
}
/**

View File

@ -42,7 +42,7 @@
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:textColor="@color/note_list_text"
android:hint="hint"
android:hint="@string/hint_department"
/>
</android.support.design.widget.TextInputLayout>
@ -57,7 +57,7 @@
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:textColor="@color/note_list_text"
android:hint="hint"
android:hint="@string/hint_room"
/>
</android.support.design.widget.TextInputLayout>
@ -72,78 +72,16 @@
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:textColor="@color/note_list_text"
android:hint="hint"
android:hint="@string/hint_email"
/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
<android.support.v7.widget.RecyclerView
android:id="@+id/dutyHourView"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
android:layout_height="match_parent"/>
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="@+id/userDutyHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="hint"
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:text="@string/dutyHours"
android:textColor="@color/note_list_text"
tools:text="@string/dutyHours" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="@+id/userDutyStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="hint"
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:text="@string/dutyHours"
android:textColor="@color/note_list_text"
tools:text="@string/dutyHours" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="@+id/userDutyStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="hint"
android:lineSpacingExtra="8sp"
android:paddingTop="5dp"
android:text="@string/dutyHours"
android:textColor="@color/note_list_text"
tools:text="@string/dutyHours" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
<TextView
android:id="@+id/userNoteTitle"
android:layout_width="match_parent"

View File

@ -5,23 +5,26 @@
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:fontFamily="@font/lato_regular"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="12dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="12dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="100dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/duty_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:hint="@string/hint_duty_day">
<android.support.design.widget.TextInputEditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/duty_day_value"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignStart="@+id/duty_day"
android:hint="hint"
tools:text="@tools:sample/date/day_of_week" />
</android.support.design.widget.TextInputLayout>
@ -29,14 +32,16 @@
android:id="@+id/duty_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_toEndOf="@+id/duty_day">
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="142dp"
android:hint="@string/hint_duty_start">
<android.support.design.widget.TextInputEditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/duty_start_value"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/duty_start"
android:hint="hint"
tools:text="@tools:sample/date/hhmm" />
</android.support.design.widget.TextInputLayout>
@ -44,24 +49,26 @@
android:id="@+id/duty_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_toEndOf="@+id/duty_start">
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="75dp"
android:hint="@string/hint_duty_end">
<android.support.design.widget.TextInputEditText
android:id="@+id/duty_stop_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_alignStart="@+id/duty_stop"
android:layout_alignTop="@+id/duty_stop"
android:hint="hint"
tools:text="@tools:sample/date/hhmm" />
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/deleteRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_toEndOf="@+id/duty_stop"
android:layout_height="41dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:scaleX="0.7"
android:scaleY="0.7"
app:srcCompat="@android:drawable/ic_delete" />

View File

@ -297,4 +297,17 @@
<string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string>
<string name="info_icon_userlist_tab_level_status_inactive_tip">(didnt share any localization data since 7 days)</string>
<!--(ENG) Profile Activity strings-->
<string name="hint_duty_day">Day</string>
<string name="hint_duty_start">Start</string>
<string name="hint_duty_end">End</string>
<string name="hint_department">Department</string>
<string name="hint_room">Room</string>
<string name="hint_email">Email</string>
</resources>