.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ssb.simplitend.caregiverdashboard.activities;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
@@ -26,6 +27,8 @@ public class PatientProfileShowerActivity extends AppCompatActivity {
|
||||
|
||||
public static final String WHICH_FRAGMENT = "which_f";
|
||||
|
||||
private Fragment current_fragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -236,10 +236,13 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
viewModel.updatePatientAddress(careGiverData.patientId, body,
|
||||
"Bearer " + AppUtil.getCgToken(this),
|
||||
this);
|
||||
}else {
|
||||
Toast.makeText(this, "Couldn't load address.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// do nothing as we couldn't load the location from the lat lng
|
||||
Toast.makeText(this, "Couldn't load address.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ public class MedicalInfoFragment extends Fragment implements ProfileContracts.Ge
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = MedicalIntoFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
medicalInfoViewModel = new ViewModelProvider(requireActivity()).get(MedicalInfoViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.AddReminderFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.DosageType;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Frequency;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.MedicationType;
|
||||
@@ -69,6 +70,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
private ArrayList<Frequency> frequencyList;
|
||||
private ArrayList<MedicationType> medicationTypeList;
|
||||
|
||||
private ArrayList<DosageType> dosageTypeList;
|
||||
|
||||
public AddReminderFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -140,6 +143,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
|
||||
});
|
||||
|
||||
binding.dosageDrop.setOnClickListener(v -> {
|
||||
binding.dosageSpinner.show();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void adReminder() {
|
||||
@@ -157,9 +164,11 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
try {
|
||||
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(binding.frequencySpinner.getSelectedIndex()).id);
|
||||
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(binding.medicationsSpinner.getSelectedIndex()).id);
|
||||
reminderResult.dosage_unit = String.valueOf(dosageTypeList.get(binding.dosageSpinner.getSelectedIndex()).id);
|
||||
} catch (Exception e) {
|
||||
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(0).id);
|
||||
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(0).id);
|
||||
reminderResult.dosage_unit = String.valueOf(dosageTypeList.get(0).id);
|
||||
}
|
||||
|
||||
// saving the actual format of time i.e. HH:mm:ss as hint
|
||||
@@ -234,8 +243,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
|
||||
|
||||
frequencyList = new ArrayList<>();
|
||||
|
||||
medicationTypeList = new ArrayList<>();
|
||||
dosageTypeList = new ArrayList<>();
|
||||
|
||||
// scrolling instruction edit text
|
||||
binding.instructions.setOnTouchListener((v, event) -> {
|
||||
@@ -257,6 +266,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
binding.medicationsSpinner.setIsFocusable(true);
|
||||
binding.medicationsSpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.dosageSpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
binding.dosageSpinner.setIsFocusable(true);
|
||||
binding.dosageSpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.frequencySpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener<String>) (i, s, i1, item) -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
binding.frequencySpinner.setError(null);
|
||||
@@ -435,6 +448,13 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < dosageTypeList.size(); i++) {
|
||||
if (String.valueOf(dosageTypeList.get(i).id).equals(reminder.dosage_unit)) {
|
||||
binding.dosageSpinner.selectItemByIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// week day selection
|
||||
setSelectionState(0, week_state[0] = reminder.sun.equals("1"));
|
||||
setSelectionState(1, week_state[1] = reminder.mon.equals("1"));
|
||||
@@ -649,6 +669,7 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
public void onFreqNMedTypeLoaded(FreqNMedTypeResult result) {
|
||||
frequencyList.addAll(result.frequencies);
|
||||
medicationTypeList.addAll(result.medicationTypes);
|
||||
dosageTypeList.addAll(result.dosageUnits);
|
||||
|
||||
ArrayList<String> frequencies = new ArrayList<>();
|
||||
for (Frequency frequency : frequencyList) {
|
||||
@@ -657,7 +678,9 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
binding.frequencySpinner.setItems(frequencies);
|
||||
|
||||
// default selection to one
|
||||
if (frequencies.size() > 1) binding.frequencySpinner.selectItemByIndex(0);
|
||||
if (frequencies.size() > 1) {
|
||||
binding.frequencySpinner.selectItemByIndex(0);
|
||||
}
|
||||
|
||||
ArrayList<String> medicationTypes = new ArrayList<>();
|
||||
for (MedicationType type : medicationTypeList) {
|
||||
@@ -665,6 +688,17 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
}
|
||||
binding.medicationsSpinner.setItems(medicationTypes);
|
||||
|
||||
ArrayList<String> dosageTypes = new ArrayList<>();
|
||||
for (DosageType dosageType: dosageTypeList){
|
||||
dosageTypes.add(dosageType.title);
|
||||
}
|
||||
binding.dosageSpinner.setItems(dosageTypes);
|
||||
try {
|
||||
binding.dosageSpinner.selectItemByIndex(0);
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// checking if intent to EDIT or ADD reminder
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
|
||||
@@ -60,7 +60,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RemindersFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
reminderViewModel = new ViewModelProvider(requireActivity()).get(ReminderViewModel.class);
|
||||
|
||||
initViews();
|
||||
@@ -116,7 +115,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
getParentFragmentManager().beginTransaction()
|
||||
.replace(R.id.fcv_profile_shower, AddReminderFragment.class, null)
|
||||
.addToBackStack("add_reminder")
|
||||
.commitAllowingStateLoss();
|
||||
.commit();
|
||||
} catch (Exception ex) {
|
||||
// user may be out of context
|
||||
}
|
||||
@@ -180,7 +179,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
setDayOfWeekViews();
|
||||
|
||||
setDayOfWeek(reminderViewModel.selected_dow = 0);
|
||||
|
||||
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
@@ -432,7 +430,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
|
||||
try {
|
||||
getParentFragmentManager().beginTransaction()
|
||||
.add(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
|
||||
.replace(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
|
||||
.addToBackStack("add_reminder")
|
||||
.commitAllowingStateLoss();
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
public class DosageType{
|
||||
public int id;
|
||||
public String title;
|
||||
public String value;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
public String deleted_at;
|
||||
}
|
||||
@@ -5,4 +5,5 @@ import java.util.ArrayList;
|
||||
public class FreqNMedTypeResult{
|
||||
public ArrayList<Frequency> frequencies;
|
||||
public ArrayList<MedicationType> medicationTypes;
|
||||
public ArrayList<DosageType> dosageUnits;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RoutineFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
routineViewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
|
||||
|
||||
initViews();
|
||||
@@ -397,7 +396,6 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(ROUTINE_KEY, routine);
|
||||
|
||||
|
||||
try {
|
||||
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_routineFragment_to_addRoutineFragment, bundle);
|
||||
} catch (Exception e) {
|
||||
@@ -406,7 +404,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
|
||||
try {
|
||||
getParentFragmentManager().beginTransaction()
|
||||
.add(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
|
||||
.replace(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
|
||||
.addToBackStack("add_reminder")
|
||||
.commitAllowingStateLoss();
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/white_bg"
|
||||
android:overScrollMode="never"
|
||||
>
|
||||
android:overScrollMode="never">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -93,60 +93,125 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:orientation="vertical"
|
||||
|
||||
android:background="@drawable/edit_text_bg_2"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
android:weightSum="10"
|
||||
|
||||
>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dosage"
|
||||
android:layout_width="0dp"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="8"
|
||||
android:orientation="horizontal"
|
||||
|
||||
android:background="@android:color/transparent"
|
||||
|
||||
android:hint="@string/enter_dosage"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
|
||||
android:weightSum="10"
|
||||
|
||||
>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dosage"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="8"
|
||||
|
||||
android:background="@android:color/transparent"
|
||||
|
||||
android:hint="@string/enter_dosage"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:textColor="@color/black"
|
||||
android:textColorHint="#A1A1A1"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:paddingVertical="15dp"
|
||||
android:padding="10dp"
|
||||
|
||||
android:drawableStart="@drawable/ic_dosage"
|
||||
android:drawablePadding="10dp"
|
||||
|
||||
android:maxLength="6"
|
||||
|
||||
android:autofillHints="@null"
|
||||
android:inputType="numberDecimal"
|
||||
/>
|
||||
|
||||
<!-- <View-->
|
||||
<!-- android:layout_width="1dp"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
|
||||
<!-- android:background="@android:color/darker_gray"/>-->
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dosage_drop"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_down"
|
||||
android:layout_centerInParent="true"
|
||||
app:tint="@color/black" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:layout_weight="2"-->
|
||||
|
||||
<!-- android:text="@string/mg"-->
|
||||
<!-- android:fontFamily="@font/nunito_regular"-->
|
||||
<!-- android:textAlignment="center"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:textColor="@android:color/darker_gray"-->
|
||||
<!-- android:textAppearance="@style/TextAppearance.Material3.TitleMedium"-->
|
||||
|
||||
<!-- />-->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.skydoves.powerspinner.PowerSpinnerView
|
||||
android:id="@+id/dosage_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:background="@color/white_bg"
|
||||
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/black"
|
||||
|
||||
tools:text="Tablespoon"
|
||||
android:textColorHint="#A1A1A1"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:paddingVertical="15dp"
|
||||
android:padding="10dp"
|
||||
app:spinner_arrow_drawable="@drawable/ic_down"
|
||||
app:spinner_arrow_show="false"
|
||||
|
||||
android:drawableStart="@drawable/ic_dosage"
|
||||
android:drawablePadding="10dp"
|
||||
app:spinner_popup_max_height="200dp"
|
||||
app:spinner_arrow_animate="true"
|
||||
app:fontFamily="@font/nunito_regular"
|
||||
|
||||
android:maxLength="6"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
android:autofillHints="@null"
|
||||
android:inputType="numberDecimal"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
|
||||
android:text="@string/mg"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
app:spinner_popup_start_padding="15dp"
|
||||
app:spinner_popup_end_padding="15dp"
|
||||
|
||||
app:spinner_arrow_gravity="end"
|
||||
app:spinner_arrow_padding="8dp"
|
||||
app:spinner_arrow_tint="@color/black"
|
||||
app:spinner_divider_show="true"
|
||||
app:spinner_divider_size="0.4dp"
|
||||
app:spinner_divider_color="@color/black"
|
||||
app:spinner_item_height="46dp"
|
||||
app:spinner_popup_animation="dropdown"
|
||||
app:spinner_popup_background="@drawable/edit_text_bg_2"
|
||||
app:spinner_popup_elevation="14dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user