.
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicationInfo;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Reminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
@@ -38,4 +41,35 @@ public interface PatientProfileAPIService {
|
||||
@Header("patientReminderId") int patient_reminder_id,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
|
||||
// medical information apis
|
||||
|
||||
@Multipart
|
||||
@POST("api/patient-medical-details-store/{id}")
|
||||
Call<CallResponse<MedicationInfo>> addNUpdateMedicalInfo(@PartMap Map<String, RequestBody> body,
|
||||
@Path("id") int patient_id,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@GET("api/get-medical-details/{id}")
|
||||
Call<CallResponse<MedicationInfo>> getMedicalInfo(@Path("id") int patient_id,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
|
||||
// routines apis
|
||||
|
||||
@GET("api/get-routine-details/{id}")
|
||||
Call<CallResponse<List<RoutineDetails>>> getRoutines(@Path("id") int patient_id,
|
||||
@Query("weekday") int week_day,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@POST("api/patient-routine-store/{id}")
|
||||
Call<CallResponse<RoutineDetails>> addNUpdateRoutine(@Path("id") int patient_id,
|
||||
@Body RoutineDetails routineDetails,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@POST("api/patient-routine-delete")
|
||||
Call<CallResponse<Object>> deleteRoutine(@Header("patientId") int patient_id,
|
||||
@Header("patientRoutineId") int patient_routine_id,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicationInfo;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,9 +29,39 @@ public interface ProfileContracts {
|
||||
}
|
||||
|
||||
interface ReminderDeleteCallback{
|
||||
void onReminderDeleted(int adapterPostion);
|
||||
void onReminderDeleted(int adapterPosition);
|
||||
|
||||
void onReminderDeleteFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface AddMedicalIntoCallback{
|
||||
void onMedicalInfoAdded(MedicationInfo medicationInfo);
|
||||
|
||||
void onMedicalInfoAddFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface GetMedicationInfoCallback{
|
||||
void onMedicalInfoFetched(MedicationInfo medicationInfo);
|
||||
|
||||
void onMedicationInfoFetchedFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface GetRoutinesCallback{
|
||||
void onRoutinesFetched(List<RoutineDetails> routineList);
|
||||
|
||||
void onRoutinesFetchedFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface RoutineDeleteCallback{
|
||||
void onRoutineDeleted(int adapterPosition);
|
||||
|
||||
void onRoutineDeleteFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface AddNUpdateRoutineCallback{
|
||||
void onRoutineAdded(RoutineDetails medicationInfo);
|
||||
|
||||
void onRoutineAddFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfo;
|
||||
import com.ssb.simplitend.databinding.AddMedicalInfoBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfoViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicationInfo;
|
||||
|
||||
public class AddMedicalInfoFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class AddMedicalInfoFragment extends Fragment implements
|
||||
ProfileContracts.AddMedicalIntoCallback {
|
||||
|
||||
// view binding
|
||||
protected AddMedicalInfoBinding binding;
|
||||
|
||||
private MedicalInfo medicalInfo;
|
||||
private MedicalInfoViewModel medicalInfoViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private MedicationInfo medicalInfo;
|
||||
public static final String MEDICAL_INFO_KEY = "medical_info";
|
||||
|
||||
public AddMedicalInfoFragment(){
|
||||
@@ -33,6 +49,8 @@ public class AddMedicalInfoFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddMedicalInfoBinding.inflate(inflater, container, false);
|
||||
|
||||
medicalInfoViewModel = new ViewModelProvider(requireActivity()).get(MedicalInfoViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -41,24 +59,24 @@ public class AddMedicalInfoFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle != null){
|
||||
medicalInfo = (MedicalInfo) bundle.getSerializable(MEDICAL_INFO_KEY);
|
||||
if (medicalInfo != null){
|
||||
binding.title.setText(getString(R.string.edit_medical_information));
|
||||
setLayoutInfo();
|
||||
}
|
||||
if (bundle != null && bundle.getSerializable(MEDICAL_INFO_KEY) != null){
|
||||
medicalInfo = (MedicationInfo) bundle.getSerializable(MEDICAL_INFO_KEY);
|
||||
setLayoutInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setLayoutInfo() {
|
||||
if (medicalInfo == null) return;
|
||||
|
||||
binding.diagnosis.setText(medicalInfo.diagnosis);
|
||||
binding.primaryDoc.setText(medicalInfo.primary_doc);
|
||||
binding.docContact.setText(medicalInfo.doc_contact);
|
||||
binding.hospitalPref.setText(medicalInfo.hospital_pref);
|
||||
binding.primaryDoc.setText(medicalInfo.primary_care_doctor);
|
||||
binding.docContact.setText(medicalInfo.doctor_phone_number);
|
||||
binding.hospitalPref.setText(medicalInfo.hospital_preference);
|
||||
binding.allergies.setText(medicalInfo.allergies);
|
||||
binding.dietRestrict.setText(medicalInfo.diet_restriction);
|
||||
|
||||
@@ -72,26 +90,145 @@ public class AddMedicalInfoFragment extends Fragment {
|
||||
binding.addBtn.setOnClickListener(v -> {
|
||||
ProfileProgress.MEDICAL_INFO_ADDED = true;
|
||||
|
||||
if (medicalInfo != null){
|
||||
// save changes animation
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.make_changes), getString(R.string.yes), getString(R.string.no),
|
||||
v2 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(), getString(R.string.changes_successful),
|
||||
R.raw.done_anim_primary, 3000,
|
||||
v4 -> {
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
});
|
||||
|
||||
}, v3 -> {
|
||||
// no click
|
||||
});
|
||||
|
||||
}else{
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
if (allOkay()){
|
||||
if (medicalInfo != null){
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.make_changes), getString(R.string.yes), getString(R.string.no),
|
||||
yes -> {
|
||||
// yes click
|
||||
addMedicationInfo();
|
||||
}, no -> {
|
||||
// no click
|
||||
});
|
||||
}else{
|
||||
addMedicationInfo();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addMedicationInfo() {
|
||||
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("while we add your medical information.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody diagnosis_body = RequestBody.create(binding.diagnosis.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("diagnosis", diagnosis_body);
|
||||
|
||||
RequestBody primary_doc_body = RequestBody.create(binding.primaryDoc.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("primary_care_doctor", primary_doc_body);
|
||||
|
||||
RequestBody doc_contact_body = RequestBody.create(binding.docContact.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("doctor_phone_number", doc_contact_body);
|
||||
|
||||
RequestBody hospital_pref_body = RequestBody.create(binding.hospitalPref.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("hospital_preference", hospital_pref_body);
|
||||
|
||||
RequestBody allergies_body = RequestBody.create(binding.allergies.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("allergies", allergies_body);
|
||||
|
||||
RequestBody diet_restriction_body = RequestBody.create(binding.dietRestrict.getText().toString().trim(),
|
||||
MediaType.parse("text/plain"));
|
||||
body.put("diet_restriction", diet_restriction_body);
|
||||
|
||||
RequestBody is_update_body;
|
||||
if (medicalInfo == null){
|
||||
// intent is to add medical info
|
||||
// thus, is_update is 0
|
||||
|
||||
is_update_body = RequestBody.create("0",
|
||||
MediaType.parse("text/plain"));
|
||||
|
||||
}else{
|
||||
// intent is to update info
|
||||
// thus, is_update is 1
|
||||
|
||||
is_update_body = RequestBody.create("1",
|
||||
MediaType.parse("text/plain"));
|
||||
}
|
||||
|
||||
body.put("is_update", is_update_body);
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
medicalInfoViewModel.addNUpdateMedicalInfo(body,
|
||||
AppUtil.getPatientUid(requireContext()),
|
||||
token,
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.diagnosis.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.diagnosis.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.primaryDoc.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.primaryDoc.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.docContact.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.docContact.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.hospitalPref.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.hospitalPref.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.allergies.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.allergies.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.dietRestrict.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.dietRestrict.setError("Required");
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMedicalInfoAdded(MedicationInfo medicationInfo) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (this.medicalInfo == null){
|
||||
Toast.makeText(requireContext(), "Medical information added successfully", Toast.LENGTH_SHORT).show();
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.medicalInfoFragment, false);
|
||||
}else{
|
||||
AppUtil.showAnimateDBS(requireContext(), getString(R.string.changes_successful),
|
||||
R.raw.done_anim_primary, 3000,
|
||||
yes -> {
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.medicalInfoFragment, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMedicalInfoAddFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo;
|
||||
|
||||
import static com.ssb.simplitend.patientprofile.medicalinfo.AddMedicalInfoFragment.MEDICAL_INFO_KEY;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.databinding.MedicalIntoFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfo;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfoViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicationInfo;
|
||||
|
||||
public class MedicalInfoFragment extends Fragment {
|
||||
public class MedicalInfoFragment extends Fragment implements ProfileContracts.GetMedicationInfoCallback {
|
||||
|
||||
// view binding
|
||||
protected MedicalIntoFragmentBinding binding;
|
||||
|
||||
private MedicalInfoViewModel medicalInfoViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private MedicationInfo medicationInfo;
|
||||
|
||||
public MedicalInfoFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
@@ -29,6 +43,8 @@ public class MedicalInfoFragment extends Fragment {
|
||||
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();
|
||||
|
||||
clickEvents();
|
||||
@@ -37,17 +53,18 @@ public class MedicalInfoFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
if (ProfileProgress.MEDICAL_INFO_ADDED){
|
||||
binding.medicalInfo.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.GONE);
|
||||
}else{
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
binding.medicalInfo.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// loading medical info
|
||||
progressDialog.setTitle("Please wait..");
|
||||
progressDialog.setMessage("while we load your medical information.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
medicalInfoViewModel.getMedicalInfo(AppUtil.getPatientUid(requireContext()),
|
||||
token, this);
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
@@ -61,16 +78,53 @@ public class MedicalInfoFragment extends Fragment {
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
MedicalInfo medicalInfo = new MedicalInfo("Cognitive impairment and memeory loss.",
|
||||
"Dr. Sandeep Kanojia", "+63456398456", "Baycrest Health Sciences",
|
||||
"Latex allergy", "Lorum ipsum dummy is simple dummy");
|
||||
bundle.putSerializable(AddMedicalInfoFragment.MEDICAL_INFO_KEY, medicalInfo);
|
||||
if (medicationInfo != null){
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putSerializable(MEDICAL_INFO_KEY, medicationInfo);
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_medicalInfoFragment_to_addMedicalInfoFragment, bundle);
|
||||
}
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_medicalInfoFragment_to_addMedicalInfoFragment, bundle);
|
||||
});
|
||||
|
||||
binding.done.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
}
|
||||
|
||||
private void loadMedicalInfo(MedicationInfo medicationInfo) {
|
||||
binding.diagnosis.setText(medicationInfo.diagnosis);
|
||||
binding.primaryDoc.setText(medicationInfo.primary_care_doctor);
|
||||
binding.docContact.setText(medicationInfo.doctor_phone_number);
|
||||
binding.hospitalPref.setText(medicationInfo.hospital_preference);
|
||||
binding.allergies.setText(medicationInfo.allergies);
|
||||
binding.dietRestrict.setText(medicationInfo.diet_restriction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMedicalInfoFetched(MedicationInfo medicationInfo) {
|
||||
this.medicationInfo = medicationInfo;
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (medicationInfo != null){
|
||||
binding.medicalInfo.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.GONE);
|
||||
binding.editBtn.setVisibility(View.VISIBLE);
|
||||
|
||||
loadMedicalInfo(medicationInfo);
|
||||
}else{
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
binding.medicalInfo.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.VISIBLE);
|
||||
binding.editBtn.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMedicationInfoFetchedFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "Couldn't load medical information.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MedicalInfo implements Serializable {
|
||||
|
||||
public String diagnosis, primary_doc, doc_contact, hospital_pref
|
||||
, allergies, diet_restriction;
|
||||
|
||||
public MedicalInfo() {}
|
||||
|
||||
public MedicalInfo(String diagnosis, String primary_doc, String doc_contact, String hospital_pref, String allergies, String diet_restriction) {
|
||||
this.diagnosis = diagnosis;
|
||||
this.primary_doc = primary_doc;
|
||||
this.doc_contact = doc_contact;
|
||||
this.hospital_pref = hospital_pref;
|
||||
this.allergies = allergies;
|
||||
this.diet_restriction = diet_restriction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo.mvvm;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class MedicalInfoViewModel extends ViewModel {
|
||||
|
||||
private final MedicalIntoRepository medicalIntoRepository;
|
||||
|
||||
public MedicalInfoViewModel(){
|
||||
medicalIntoRepository = MedicalIntoRepository.getMedicalIntoRepository();
|
||||
}
|
||||
|
||||
public void addNUpdateMedicalInfo(Map<String, RequestBody> body,
|
||||
int patient_id,
|
||||
String token,
|
||||
@NonNull ProfileContracts.AddMedicalIntoCallback medicalIntoCallback){
|
||||
medicalIntoRepository.addNUpdateMedicalInfo(body, patient_id, token, medicalIntoCallback);
|
||||
}
|
||||
|
||||
public void getMedicalInfo(int patient_id,
|
||||
String token,
|
||||
@NonNull ProfileContracts.GetMedicationInfoCallback medicationInfoCallback){
|
||||
medicalIntoRepository.getMedicalInfo(patient_id, token, medicationInfoCallback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo.mvvm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.patientprofile.PatientProfileAPIService;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class MedicalIntoRepository {
|
||||
|
||||
private static final String TAG = "MedicalIntoRepository";
|
||||
|
||||
private static MedicalIntoRepository medicalIntoRepository;
|
||||
|
||||
private PatientProfileAPIService apiService;
|
||||
|
||||
private MedicalIntoRepository(){
|
||||
apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
}
|
||||
|
||||
public static synchronized MedicalIntoRepository getMedicalIntoRepository(){
|
||||
if (medicalIntoRepository == null){
|
||||
medicalIntoRepository = new MedicalIntoRepository();
|
||||
}
|
||||
|
||||
return medicalIntoRepository;
|
||||
}
|
||||
|
||||
public void addNUpdateMedicalInfo(Map<String, RequestBody> body,
|
||||
int patient_id,
|
||||
String token,
|
||||
@NonNull ProfileContracts.AddMedicalIntoCallback medicalIntoCallback){
|
||||
|
||||
apiService.addNUpdateMedicalInfo(body, patient_id, token)
|
||||
.enqueue(new Callback<CallResponse<MedicationInfo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<MedicationInfo>> call, Response<CallResponse<MedicationInfo>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
medicalIntoCallback.onMedicalInfoAddFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
medicalIntoCallback.onMedicalInfoAdded(response.body().result);
|
||||
}else{
|
||||
medicalIntoCallback.onMedicalInfoAddFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<MedicationInfo>> call, Throwable t) {
|
||||
medicalIntoCallback.onMedicalInfoAddFailed(new Exception(), "Please try again later.");
|
||||
Log.e(TAG, "onFailure: ", t);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void getMedicalInfo(int patient_id,
|
||||
String token,
|
||||
@NonNull ProfileContracts.GetMedicationInfoCallback medicationInfoCallback){
|
||||
|
||||
apiService.getMedicalInfo(patient_id, token)
|
||||
.enqueue(new Callback<CallResponse<MedicationInfo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<MedicationInfo>> call, Response<CallResponse<MedicationInfo>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
medicationInfoCallback.onMedicationInfoFetchedFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
medicationInfoCallback.onMedicalInfoFetched(response.body().result);
|
||||
}else{
|
||||
medicationInfoCallback.onMedicationInfoFetchedFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<MedicationInfo>> call, Throwable t) {
|
||||
medicationInfoCallback.onMedicationInfoFetchedFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MedicationInfo implements Serializable {
|
||||
public String patient_xid;
|
||||
public String diagnosis;
|
||||
public String primary_care_doctor;
|
||||
public String doctor_phone_number;
|
||||
public String hospital_preference;
|
||||
public String allergies;
|
||||
public String diet_restriction;
|
||||
public String updated_at;
|
||||
public String created_at;
|
||||
public int id;
|
||||
|
||||
public String is_update;
|
||||
|
||||
public MedicationInfo(){}
|
||||
}
|
||||
@@ -111,8 +111,21 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
if (allOkay()) {
|
||||
adReminder();
|
||||
|
||||
if (reminder != null){
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
adReminder();
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
}else{
|
||||
adReminder();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -585,18 +598,11 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
|
||||
} else {
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.reminderFragment, false, true);
|
||||
});
|
||||
}, v2 -> {
|
||||
// no click
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.reminderFragment, false, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.ssb.simplitend.databinding.RemindersFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderAdapter;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Reminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -108,16 +107,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
Reminder reminder = new Reminder("Vitamin D3", "05:00 PM", "5 Capsules");
|
||||
|
||||
bundle.putSerializable(AddReminderFragment.REMINDER_KEY, reminder);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadReminderList(int day_of_week){
|
||||
|
||||
@@ -23,12 +23,12 @@ public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter
|
||||
private static final DiffUtil.ItemCallback<ReminderResult> DIFF_CALLBACK = new DiffUtil.ItemCallback<ReminderResult>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull ReminderResult oldItem, @NonNull ReminderResult newItem) {
|
||||
return oldItem.id == newItem.id;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull ReminderResult oldItem, @NonNull ReminderResult newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ssb.simplitend.patientprofile.setuproutine;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -9,23 +10,30 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.AddRoutineFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.Routine;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineViewModel;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AddRoutineFragment extends Fragment implements CompoundButton.OnCheckedChangeListener{
|
||||
public class AddRoutineFragment extends Fragment implements CompoundButton.OnCheckedChangeListener,
|
||||
ProfileContracts.AddNUpdateRoutineCallback {
|
||||
|
||||
// view binding
|
||||
protected AddRoutineFragmentBinding binding;
|
||||
@@ -33,7 +41,11 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
private boolean[] week_state;
|
||||
|
||||
public static final String ROUTINE_KEY = "routine_key";
|
||||
private Routine routine;
|
||||
private RoutineDetails routine;
|
||||
|
||||
private RoutineViewModel routineViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public AddRoutineFragment() {
|
||||
// required empty const.
|
||||
@@ -44,6 +56,8 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddRoutineFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
routineViewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -54,10 +68,14 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
setUpWeekSelection();
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle != null){
|
||||
routine = (Routine) bundle.getSerializable(ROUTINE_KEY);
|
||||
if (bundle != null && bundle.getSerializable(ROUTINE_KEY) != null){
|
||||
routine = (RoutineDetails) bundle.getSerializable(ROUTINE_KEY);
|
||||
setLayoutDetails();
|
||||
}
|
||||
|
||||
@@ -83,42 +101,158 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
binding.title.setText(getString(R.string.edit_routine));
|
||||
binding.addRoutine.setText(getString(R.string.save));
|
||||
|
||||
binding.routineName.setText(routine.routine_name);
|
||||
binding.routineName.setText(routine.routine_title);
|
||||
binding.routineDescription.setText(routine.routine_description);
|
||||
|
||||
binding.startTime.setText(routine.start_time_str);
|
||||
binding.endTime.setText(routine.end_time_str);
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String start_time, end_time;
|
||||
|
||||
try {
|
||||
Date start_date = input_sdf.parse(routine.routine_start_time);
|
||||
start_time = output_sdf.format(Objects.requireNonNull(start_date));
|
||||
|
||||
Date end_date = input_sdf.parse(routine.routine_end_time);
|
||||
end_time = output_sdf.format(Objects.requireNonNull(end_date));
|
||||
} catch (Exception e) {
|
||||
start_time = routine.routine_start_time;
|
||||
end_time = routine.routine_end_time;
|
||||
}
|
||||
|
||||
binding.startTime.setText(start_time);
|
||||
binding.endTime.setText(end_time);
|
||||
|
||||
binding.startTime.setHint(routine.routine_start_time);
|
||||
binding.endTime.setHint(routine.routine_end_time);
|
||||
|
||||
setSelectionState(0, week_state[0] = routine.sun.equals("1"));
|
||||
setSelectionState(1, week_state[1] = routine.mon.equals("1"));
|
||||
setSelectionState(2, week_state[2] = routine.tue.equals("1"));
|
||||
setSelectionState(3, week_state[3] = routine.wed.equals("1"));
|
||||
setSelectionState(4, week_state[4] = routine.thu.equals("1"));
|
||||
setSelectionState(5, week_state[5] = routine.fri.equals("1"));
|
||||
setSelectionState(6, week_state[6] = routine.sat.equals("1"));
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.startTime.setOnClickListener(v -> getTime(binding.startTime));
|
||||
binding.endTime.setOnClickListener(v -> getTime(binding.endTime));
|
||||
binding.startTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime(binding.startTime);
|
||||
});
|
||||
binding.endTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime(binding.endTime);
|
||||
});
|
||||
|
||||
binding.addRoutine.setOnClickListener(v -> {
|
||||
if (routine == null){
|
||||
Navigation.findNavController(v).popBackStack(R.id.routineFragment, false, true);
|
||||
}else{
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(v).popBackStack(R.id.routineFragment, false, true);
|
||||
});
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
if (allOkay()) {
|
||||
|
||||
if (routine != null){
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
addRoutine();
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
}else{
|
||||
addRoutine();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setUpWeekSelection();
|
||||
}
|
||||
|
||||
private void addRoutine() {
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we save your reminder.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
RoutineDetails routineDetails = new RoutineDetails();
|
||||
|
||||
routineDetails.routine_title = binding.routineName.getText().toString().trim();
|
||||
routineDetails.routine_description = binding.routineDescription.getText().toString().trim();
|
||||
|
||||
// saving the actual format of time i.e. HH:mm:ss as hint
|
||||
// and saving the formatted time as text i.e. hh:mm a
|
||||
routineDetails.routine_start_time = binding.startTime.getHint().toString();
|
||||
routineDetails.routine_end_time = binding.endTime.getHint().toString();
|
||||
|
||||
routineDetails.sun = week_state[0] ? "1" : "0";
|
||||
routineDetails.mon = week_state[1] ? "1" : "0";
|
||||
routineDetails.tue = week_state[2] ? "1" : "0";
|
||||
routineDetails.wed = week_state[3] ? "1" : "0";
|
||||
routineDetails.thu = week_state[4] ? "1" : "0";
|
||||
routineDetails.fri = week_state[5] ? "1" : "0";
|
||||
routineDetails.sat = week_state[6] ? "1" : "0";
|
||||
|
||||
if (routine != null) {
|
||||
// this intent is to update the reminder
|
||||
routineDetails.is_update = 1;
|
||||
routineDetails.patientRoutineId = routine.id;
|
||||
} else {
|
||||
routineDetails.is_update = 0;
|
||||
}
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
routineViewModel.addNUpdateRoutine(AppUtil.getPatientUid(requireContext()),
|
||||
routineDetails,
|
||||
token,
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.routineName.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.routineName.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.routineDescription.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.routineDescription.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.startTime.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.startTime.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.endTime.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.endTime.setError("Required");
|
||||
}
|
||||
|
||||
if (allOkay) {
|
||||
boolean anyOneSelected = false;
|
||||
for (int i = 0; i < week_state.length; i++) {
|
||||
if (week_state[i]) {
|
||||
// this week day is selected
|
||||
anyOneSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyOneSelected) {
|
||||
// none are selected
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Select a week day.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
// set selection and un-selection of week day
|
||||
@@ -151,9 +285,11 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
cal.set(Calendar.MINUTE, minute);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
textView.setText(selected_time);
|
||||
textView.setHint(sdf2.format(cal.getTime()));
|
||||
|
||||
}, calendar.getTime().getHours(), calendar.getTime().getMinutes(), false);
|
||||
|
||||
@@ -265,4 +401,39 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
setSelectionState(i, week_state[i] = isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add update routine callback
|
||||
@Override
|
||||
public void onRoutineAdded(RoutineDetails medicationInfo) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (this.routine == null) {
|
||||
Toast.makeText(requireContext(), "Routine added successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.popBackStack(R.id.routineFragment, false, true);
|
||||
|
||||
} else {
|
||||
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.routineFragment, false, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoutineAddFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package com.ssb.simplitend.patientprofile.setuproutine;
|
||||
|
||||
import static com.ssb.simplitend.patientprofile.setuproutine.AddRoutineFragment.ROUTINE_KEY;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -17,23 +19,31 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.RoutineFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.Routine;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.WeekDayViewHolder;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineViewModel;
|
||||
|
||||
public class RoutineFragment extends Fragment implements RoutineAdapter.ClickListener, RoutineAdapter.DeleteClickListener {
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class RoutineFragment extends Fragment implements RoutineAdapter.ClickListener,
|
||||
RoutineAdapter.DeleteClickListener,
|
||||
ProfileContracts.GetRoutinesCallback,
|
||||
ProfileContracts.RoutineDeleteCallback {
|
||||
|
||||
// view binding
|
||||
protected RoutineFragmentBinding binding;
|
||||
|
||||
// selection state for week days
|
||||
/*
|
||||
true -> date selected
|
||||
false -> date unselected
|
||||
*/
|
||||
private boolean[] selection_state;
|
||||
private RoutineAdapter routineAdapter;
|
||||
|
||||
private RoutineViewModel viewModel;
|
||||
private ArrayList<WeekDayViewHolder> weekDayViewsList;
|
||||
|
||||
private RoutineViewModel routineViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public RoutineFragment(){
|
||||
// required empty const.
|
||||
@@ -44,6 +54,8 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
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();
|
||||
|
||||
clickEvents();
|
||||
@@ -52,163 +64,293 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
// date selections
|
||||
binding.day.setOnClickListener(v -> {
|
||||
setDayOfWeek(0);
|
||||
loadRoutineList(weekDayViewsList.get(0).day_of_week);
|
||||
});
|
||||
binding.day2.setOnClickListener(v -> {
|
||||
setDayOfWeek(1);
|
||||
loadRoutineList(weekDayViewsList.get(1).day_of_week);
|
||||
});
|
||||
binding.day3.setOnClickListener(v -> {
|
||||
setDayOfWeek(2);
|
||||
loadRoutineList(weekDayViewsList.get(2).day_of_week);
|
||||
});
|
||||
binding.day4.setOnClickListener(v -> {
|
||||
setDayOfWeek(3);
|
||||
loadRoutineList(weekDayViewsList.get(3).day_of_week);
|
||||
});
|
||||
binding.day5.setOnClickListener(v -> {
|
||||
setDayOfWeek(4);
|
||||
loadRoutineList(weekDayViewsList.get(4).day_of_week);
|
||||
});
|
||||
binding.day6.setOnClickListener(v -> {
|
||||
setDayOfWeek(5);
|
||||
loadRoutineList(weekDayViewsList.get(5).day_of_week);
|
||||
});
|
||||
binding.day7.setOnClickListener(v -> {
|
||||
setDayOfWeek(6);
|
||||
loadRoutineList(weekDayViewsList.get(6).day_of_week);
|
||||
});
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.addRoutine.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).navigate(R.id.action_routineFragment_to_addRoutineFragment);
|
||||
});
|
||||
|
||||
// date selections
|
||||
binding.sun.setOnClickListener(v -> {
|
||||
setSelectionState(0, selection_state[0] = !selection_state[0]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.mon.setOnClickListener(v -> {
|
||||
setSelectionState(1, selection_state[1] = !selection_state[1]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.tue.setOnClickListener(v -> {
|
||||
setSelectionState(2, selection_state[2] = !selection_state[2]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.wed.setOnClickListener(v -> {
|
||||
setSelectionState(3, selection_state[3] = !selection_state[3]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.thu.setOnClickListener(v -> {
|
||||
setSelectionState(4, selection_state[4] = !selection_state[4]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.fri.setOnClickListener(v -> {
|
||||
setSelectionState(5, selection_state[5] = !selection_state[5]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.sat.setOnClickListener(v -> {
|
||||
setSelectionState(6, selection_state[6] = !selection_state[6]);
|
||||
loadRoutineList();
|
||||
});
|
||||
}
|
||||
|
||||
private void loadRoutineList(int day_of_week) {
|
||||
Toast.makeText(requireContext(), "loading for " + routineViewModel.getDayOfWeek(day_of_week-1), Toast.LENGTH_SHORT).show();
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we fetch reminders list for you.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
day_of_week--; // because, at server side day_of_week starts from 0
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
int patient_uid = AppUtil.getPatientUid(requireContext());
|
||||
routineViewModel.getRoutines(patient_uid, token, day_of_week, this);
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
selection_state = new boolean[7];
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
|
||||
}
|
||||
|
||||
private void loadRoutineList() {
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.routineRv.setVisibility(View.VISIBLE);
|
||||
binding.routineRv.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
binding.routineRv.setAdapter(viewModel.getRoutineAdapter());
|
||||
routineAdapter = new RoutineAdapter();
|
||||
routineAdapter.setDeleteClickListener(this);
|
||||
routineAdapter.setClickListener(this);
|
||||
binding.routineRv.setAdapter(routineAdapter);
|
||||
|
||||
viewModel.getRoutineAdapter().setDeleteClickListener(this);
|
||||
viewModel.getRoutineAdapter().setClickListener(this);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
viewModel.getRoutineAdapter().submitList(viewModel.getRoutines());
|
||||
String today_date = routineViewModel.getMonthOfYear(calendar.get(Calendar.MONTH));
|
||||
today_date = today_date.concat(", " + calendar.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
binding.todayDate.setText(today_date);
|
||||
|
||||
// show days of week
|
||||
setDayOfWeekViews();
|
||||
|
||||
setDayOfWeek(routineViewModel.selected_dow);
|
||||
|
||||
loadRoutineList(weekDayViewsList.get(routineViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
private void setSelectionState(int position, boolean selection){
|
||||
if (selection){
|
||||
switch (position){
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.sunT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sunT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.monT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.monT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.tue1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.tue2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.wed1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.wed2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.thu1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.thu2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.fri1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.fri2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.sat1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sat2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
private void setDayOfWeekViews() {
|
||||
weekDayViewsList = new ArrayList<>();
|
||||
|
||||
// adding all day_views to the list
|
||||
WeekDayViewHolder day1 = new WeekDayViewHolder(binding.day, binding.dayT1, binding.dayT2);
|
||||
weekDayViewsList.add(day1);
|
||||
|
||||
WeekDayViewHolder day2 = new WeekDayViewHolder(binding.day2, binding.day2T1, binding.day2T2);
|
||||
weekDayViewsList.add(day2);
|
||||
|
||||
WeekDayViewHolder day3 = new WeekDayViewHolder(binding.day3, binding.day31, binding.day32);
|
||||
weekDayViewsList.add(day3);
|
||||
|
||||
WeekDayViewHolder day4 = new WeekDayViewHolder(binding.day4, binding.day41, binding.day42);
|
||||
weekDayViewsList.add(day4);
|
||||
|
||||
WeekDayViewHolder day5 = new WeekDayViewHolder(binding.day5, binding.day51, binding.day52);
|
||||
weekDayViewsList.add(day5);
|
||||
|
||||
WeekDayViewHolder day6 = new WeekDayViewHolder(binding.day6, binding.day61, binding.day62);
|
||||
weekDayViewsList.add(day6);
|
||||
|
||||
WeekDayViewHolder day7 = new WeekDayViewHolder(binding.day7, binding.day71, binding.day72);
|
||||
weekDayViewsList.add(day7);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
for (int i = 0; i<7; i++){
|
||||
WeekDayViewHolder dayViewHolder = weekDayViewsList.get(i);
|
||||
|
||||
dayViewHolder.day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
dayViewHolder.day.setText(routineViewModel.getDayOfWeek(dayViewHolder.day_of_week - 1));
|
||||
dayViewHolder.date.setText(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
|
||||
|
||||
calendar.add(Calendar.DAY_OF_WEEK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDayOfWeek(int selection){
|
||||
|
||||
clearSelection();
|
||||
|
||||
switch (routineViewModel.selected_dow = selection){
|
||||
case 0:
|
||||
binding.day.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.dayT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.dayT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
|
||||
binding.day2.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day2T1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day2T2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
|
||||
binding.day3.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day31.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day32.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
|
||||
binding.day4.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day41.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day42.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
|
||||
binding.day5.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day51.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day52.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
|
||||
binding.day6.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day61.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day62.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
|
||||
binding.day7.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day71.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day72.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void clearSelection(){
|
||||
switch (routineViewModel.selected_dow){
|
||||
case 0:
|
||||
binding.day.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.dayT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.dayT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
|
||||
binding.day2.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day2T1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day2T2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
|
||||
binding.day3.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day31.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day32.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
|
||||
binding.day4.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day41.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day42.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
|
||||
binding.day5.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day51.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day52.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
|
||||
binding.day6.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day61.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day62.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
|
||||
binding.day7.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day71.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day72.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// delete routine callback
|
||||
|
||||
|
||||
@Override
|
||||
public void onRoutineDeleted(int adapterPosition) {
|
||||
Toast.makeText(requireContext(), "Reminder deleted.", Toast.LENGTH_SHORT).show();
|
||||
progressDialog.dismiss();
|
||||
loadRoutineList(weekDayViewsList.get(routineViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoutineDeleteFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
// get routine callback
|
||||
@Override
|
||||
public void onRoutinesFetched(List<RoutineDetails> routineList) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (routineList != null && routineList.size() > 0){
|
||||
// reminders are present
|
||||
binding.routineRv.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
|
||||
routineAdapter.submitList(routineList);
|
||||
}else{
|
||||
switch (position){
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sunT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.sunT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.monT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.monT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.tue1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.tue2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.wed1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.wed2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.thu1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.thu2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.fri1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.fri2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sat1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.sat2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
}
|
||||
binding.routineRv.setVisibility(View.GONE);
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete(Routine routine, int position) {
|
||||
public void onRoutinesFetchedFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
binding.routineRv.setVisibility(View.GONE);
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete(RoutineDetails routine, int position) {
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.delete_med_routine),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1-> {
|
||||
// yes click
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we delete the routine for you.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
routineViewModel.deleteRoutine(AppUtil.getPatientUid(requireContext()),
|
||||
routine.id,
|
||||
position,
|
||||
token,
|
||||
this);
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
@@ -216,7 +358,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Routine routine, int position) {
|
||||
public void onClick(RoutineDetails routine, int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(ROUTINE_KEY, routine);
|
||||
|
||||
|
||||
@@ -10,17 +10,22 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ssb.simplitend.databinding.RoutineViewholderBinding;
|
||||
|
||||
public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineViewHolder> {
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
private static final DiffUtil.ItemCallback<Routine> DIFF_UTIL = new DiffUtil.ItemCallback<Routine>() {
|
||||
public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.RoutineViewHolder> {
|
||||
|
||||
private static final DiffUtil.ItemCallback<RoutineDetails> DIFF_UTIL = new DiffUtil.ItemCallback<RoutineDetails>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull Routine oldItem, @NonNull Routine newItem) {
|
||||
public boolean areItemsTheSame(@NonNull RoutineDetails oldItem, @NonNull RoutineDetails newItem) {
|
||||
// TODO: 10-07-2023
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull Routine oldItem, @NonNull Routine newItem) {
|
||||
public boolean areContentsTheSame(@NonNull RoutineDetails oldItem, @NonNull RoutineDetails newItem) {
|
||||
// TODO: 10-07-2023
|
||||
return false;
|
||||
}
|
||||
@@ -29,7 +34,7 @@ public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineV
|
||||
private DeleteClickListener deleteClickListener;
|
||||
private ClickListener clickListener;
|
||||
|
||||
public RoutineAdapter(){
|
||||
public RoutineAdapter() {
|
||||
super(DIFF_UTIL);
|
||||
}
|
||||
|
||||
@@ -53,7 +58,8 @@ public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineV
|
||||
holder.setData(getItem(position), position);
|
||||
|
||||
holder.binding.delete.setOnClickListener(v -> {
|
||||
if (deleteClickListener != null) deleteClickListener.onDelete(getItem(position), position);
|
||||
if (deleteClickListener != null)
|
||||
deleteClickListener.onDelete(getItem(position), position);
|
||||
});
|
||||
|
||||
holder.binding.card.setOnClickListener(v -> {
|
||||
@@ -62,28 +68,46 @@ public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineV
|
||||
|
||||
}
|
||||
|
||||
public static class RoutineViewHolder extends RecyclerView.ViewHolder{
|
||||
public static class RoutineViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
RoutineViewholderBinding binding;
|
||||
|
||||
public RoutineViewHolder(RoutineViewholderBinding binding){
|
||||
public RoutineViewHolder(RoutineViewholderBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public void setData(Routine routine, int position){
|
||||
public void setData(RoutineDetails routine, int position) {
|
||||
|
||||
binding.routineName.setText(routine.routine_name);
|
||||
binding.routineName.setText(routine.routine_title);
|
||||
binding.description.setText(routine.routine_description);
|
||||
|
||||
String time_slot = routine.start_time_str + " - " + routine.end_time_str;
|
||||
// converting time format from hh:mm:ss to hh:mm s
|
||||
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String start_time, end_time;
|
||||
|
||||
try {
|
||||
Date start_date = input_sdf.parse(routine.routine_start_time);
|
||||
start_time = output_sdf.format(Objects.requireNonNull(start_date)).replace(".", "").toUpperCase();
|
||||
|
||||
Date end_date = input_sdf.parse(routine.routine_end_time);
|
||||
end_time = output_sdf.format(Objects.requireNonNull(end_date)).replace(".", "").toUpperCase();
|
||||
} catch (Exception e) {
|
||||
start_time = routine.routine_start_time;
|
||||
end_time = routine.routine_end_time;
|
||||
}
|
||||
|
||||
String time_slot = start_time + " - " + end_time;
|
||||
binding.timeSlot.setText(time_slot);
|
||||
|
||||
// static
|
||||
String start_slot = routine.start_time_str.substring(0, 2) + " " + routine.start_time_str.substring(routine.start_time_str.length()-2);
|
||||
// static in format of hh a
|
||||
String start_slot = start_time.substring(0, 2) + " " + start_time.substring(start_time.length() - 2);
|
||||
binding.startTimeStatic.setText(start_slot);
|
||||
|
||||
String end_slot = routine.end_time_str.substring(0, 2) + " " + routine.end_time_str.substring(routine.end_time_str.length()-2);
|
||||
String end_slot = end_time.substring(0, 2) + " " + end_time.substring(end_time.length() - 2);
|
||||
binding.endTimeStatic.setText(end_slot);
|
||||
|
||||
}
|
||||
@@ -93,13 +117,13 @@ public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineV
|
||||
// interfaces
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DeleteClickListener{
|
||||
void onDelete(Routine routine, int position);
|
||||
public interface DeleteClickListener {
|
||||
void onDelete(RoutineDetails routineDetails, int position);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClickListener{
|
||||
void onClick(Routine routine, int position);
|
||||
public interface ClickListener {
|
||||
void onClick(RoutineDetails routineDetails, int position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class RoutineDetails implements Serializable {
|
||||
public int id;
|
||||
public int is_update;
|
||||
public int patientRoutineId;
|
||||
|
||||
public String patient_xid;
|
||||
public String routine_title;
|
||||
public String routine_description;
|
||||
public String reminder_everyday_flag;
|
||||
public String reminder_weekday_flag;
|
||||
public String routine_start_time;
|
||||
public String routine_end_time;
|
||||
public String mon;
|
||||
public String tue;
|
||||
public String wed;
|
||||
public String thu;
|
||||
public String fri;
|
||||
public String sat;
|
||||
public String sun;
|
||||
public String active;
|
||||
public String deleted_at;
|
||||
public String created_by;
|
||||
public String updated_by;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RoutineDetails that = (RoutineDetails) o;
|
||||
return id == that.id && Objects.equals(routine_title, that.routine_title) && Objects.equals(routine_description, that.routine_description) && Objects.equals(routine_start_time, that.routine_start_time) && Objects.equals(routine_end_time, that.routine_end_time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, routine_title, routine_description, routine_start_time, routine_end_time);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,97 @@
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RoutineViewModel extends ViewModel {
|
||||
|
||||
private final ArrayList<Routine> routines;
|
||||
private final RoutineAdapter routineAdapter;
|
||||
private final RoutinesRepository routinesRepository;
|
||||
|
||||
// selected day of week
|
||||
public int selected_dow;
|
||||
|
||||
public RoutineViewModel(){
|
||||
this.routineAdapter = new RoutineAdapter();
|
||||
this.routinesRepository = RoutinesRepository.getRoutineRepository();
|
||||
|
||||
// init static data in routine list
|
||||
this.routines = new ArrayList<>();
|
||||
routines.add(new Routine("Doctor appointment", "Meet your heart specialist Abraham at 4:00 pm", "07 : 00 AM", "09 : 00 AM"));
|
||||
routines.add(new Routine("Take medicines", "Lorem Ipsum is simply dummy.", "11 : 00 AM", "12 : 00 PM"));
|
||||
// selection state default
|
||||
selected_dow = 0;
|
||||
}
|
||||
|
||||
public RoutineAdapter getRoutineAdapter() {
|
||||
return routineAdapter;
|
||||
public void getRoutines(int patient_id,
|
||||
String token,
|
||||
int week_day,
|
||||
@NonNull ProfileContracts.GetRoutinesCallback routinesCallback){
|
||||
routinesRepository.getRoutines(patient_id, token, week_day, routinesCallback);
|
||||
}
|
||||
|
||||
public ArrayList<Routine> getRoutines() {
|
||||
return routines;
|
||||
public void addNUpdateRoutine(int patient_id,
|
||||
RoutineDetails routineDetails,
|
||||
String token,
|
||||
@NonNull ProfileContracts.AddNUpdateRoutineCallback routineCallback){
|
||||
routinesRepository.addNUpdateRoutine(patient_id, routineDetails, token, routineCallback);
|
||||
}
|
||||
|
||||
public void deleteRoutine(int patient_id,
|
||||
int patient_routine_id,
|
||||
int adapterPosition,
|
||||
String token,
|
||||
@NonNull ProfileContracts.RoutineDeleteCallback deleteCallback){
|
||||
routinesRepository.deleteRoutine(patient_id, patient_routine_id, adapterPosition, token, deleteCallback);
|
||||
}
|
||||
|
||||
public String getDayOfWeek(int position){
|
||||
switch (position){
|
||||
case 0:
|
||||
return "Sun";
|
||||
case 1:
|
||||
return "Mon";
|
||||
case 2:
|
||||
return "Tue";
|
||||
case 3:
|
||||
return "Wed";
|
||||
case 4:
|
||||
return "Thu";
|
||||
case 5:
|
||||
return "Fri";
|
||||
case 6:
|
||||
return "Sat";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getMonthOfYear(int month){
|
||||
switch (month){
|
||||
case 1:
|
||||
return "January";
|
||||
case 2:
|
||||
return "February";
|
||||
case 3:
|
||||
return "March";
|
||||
case 4:
|
||||
return "April";
|
||||
case 5:
|
||||
return "May";
|
||||
case 6:
|
||||
return "June";
|
||||
case 7:
|
||||
return "July";
|
||||
case 8:
|
||||
return "August";
|
||||
case 9:
|
||||
return "September";
|
||||
case 10:
|
||||
return "October";
|
||||
case 11:
|
||||
return "November";
|
||||
case 12:
|
||||
return "December";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.patientprofile.PatientProfileAPIService;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public class RoutinesRepository {
|
||||
|
||||
private static RoutinesRepository routineRepository;
|
||||
|
||||
private final PatientProfileAPIService apiService;
|
||||
|
||||
private RoutinesRepository(){
|
||||
this.apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
}
|
||||
|
||||
public static synchronized RoutinesRepository getRoutineRepository(){
|
||||
if (routineRepository == null){
|
||||
routineRepository = new RoutinesRepository();
|
||||
}
|
||||
|
||||
return routineRepository;
|
||||
}
|
||||
|
||||
public void getRoutines(int patient_id,
|
||||
String token,
|
||||
int week_day,
|
||||
@NonNull ProfileContracts.GetRoutinesCallback routinesCallback){
|
||||
|
||||
apiService.getRoutines(patient_id, week_day, token)
|
||||
.enqueue(new Callback<CallResponse<List<RoutineDetails>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<RoutineDetails>>> call, Response<CallResponse<List<RoutineDetails>>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
routinesCallback.onRoutinesFetchedFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
routinesCallback.onRoutinesFetched(response.body().result);
|
||||
}else{
|
||||
routinesCallback.onRoutinesFetchedFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<List<RoutineDetails>>> call, Throwable t) {
|
||||
routinesCallback.onRoutinesFetchedFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void addNUpdateRoutine(int patient_id,
|
||||
RoutineDetails routineDetails,
|
||||
String token,
|
||||
@NonNull ProfileContracts.AddNUpdateRoutineCallback routineCallback){
|
||||
|
||||
apiService.addNUpdateRoutine(patient_id, routineDetails, token)
|
||||
.enqueue(new Callback<CallResponse<RoutineDetails>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<RoutineDetails>> call, Response<CallResponse<RoutineDetails>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
routineCallback.onRoutineAddFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
routineCallback.onRoutineAdded(response.body().result);
|
||||
}else{
|
||||
routineCallback.onRoutineAddFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<RoutineDetails>> call, Throwable t) {
|
||||
routineCallback.onRoutineAddFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void deleteRoutine(int patient_id,
|
||||
int patient_routine_id,
|
||||
int adapterPosition,
|
||||
String token,
|
||||
@NonNull ProfileContracts.RoutineDeleteCallback deleteCallback){
|
||||
|
||||
apiService.deleteRoutine(patient_id, patient_routine_id, token)
|
||||
.enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
deleteCallback.onRoutineDeleteFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
deleteCallback.onRoutineDeleted(adapterPosition);
|
||||
}else{
|
||||
deleteCallback.onRoutineDeleteFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<Object>> call, Throwable t) {
|
||||
deleteCallback.onRoutineDeleteFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.CheckMailFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.OTPSentResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +32,8 @@ import java.util.Map;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class CheckMailFragment extends Fragment implements WelcomeContracts.VerifyOTPCallback {
|
||||
public class CheckMailFragment extends Fragment implements WelcomeContracts.VerifyOTPCallback,
|
||||
WelcomeContracts.SendOTPToEmailCallback{
|
||||
|
||||
// view binding
|
||||
protected CheckMailFragmentBinding binding;
|
||||
@@ -223,6 +225,10 @@ public class CheckMailFragment extends Fragment implements WelcomeContracts.Veri
|
||||
|
||||
});
|
||||
|
||||
binding.resendOtp.setOnClickListener(v -> {
|
||||
sendOTP();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verifyOTP() {
|
||||
@@ -241,6 +247,17 @@ public class CheckMailFragment extends Fragment implements WelcomeContracts.Veri
|
||||
viewModel.verifyOTP(body, this);
|
||||
}
|
||||
|
||||
private void sendOTP() {
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we resend an OTP to your email.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
viewModel.sendOTPToEmail(email_id,
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
private String getOTPFromInputs() {
|
||||
return binding.otp1.getText().toString() +
|
||||
binding.otp2.getText().toString() +
|
||||
@@ -297,4 +314,27 @@ public class CheckMailFragment extends Fragment implements WelcomeContracts.Veri
|
||||
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// resend otp call back
|
||||
|
||||
@Override
|
||||
public void onOTPSent(OTPSentResponse otpSentResponse) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
user_id = otpSentResponse.principal_xid;
|
||||
Toast.makeText(requireContext(), "OTP resent successfully.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPSentFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/primary_bg"/>
|
||||
<item android:drawable="@drawable/primary_bg"
|
||||
android:height="@dimen/_70sdp"
|
||||
android:width="@dimen/_70sdp"/>
|
||||
|
||||
<item android:drawable="@drawable/white_icon"
|
||||
android:gravity="center"
|
||||
android:width="@dimen/_40sdp"
|
||||
android:height="@dimen/_40sdp"
|
||||
/>
|
||||
|
||||
</layer-list>
|
||||
@@ -226,6 +226,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/resend_otp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/resend"
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_btn"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/edit"
|
||||
@@ -54,13 +55,14 @@
|
||||
/>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/no_data"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
android:overScrollMode="never">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/no_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
@@ -179,6 +181,7 @@
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/diagnosis"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -256,6 +259,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/primary_doc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -332,6 +336,7 @@
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/doc_contact"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -373,7 +378,7 @@
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hospital_pref"
|
||||
android:id="@+id/hospital_pref_img"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:contentDescription="@string/diagnosis"
|
||||
@@ -393,7 +398,7 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_toEndOf="@id/hospital_pref"
|
||||
android:layout_toEndOf="@id/hospital_pref_img"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -406,6 +411,7 @@
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hospital_pref"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -444,7 +450,7 @@
|
||||
app:srcCompat="@drawable/ic_primary_bar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/allergies"
|
||||
android:id="@+id/allergies_img"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_centerVertical="true"
|
||||
@@ -463,7 +469,7 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_toEndOf="@id/allergies"
|
||||
android:layout_toEndOf="@id/allergies_img"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -476,6 +482,7 @@
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/allergies"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -514,7 +521,7 @@
|
||||
app:srcCompat="@drawable/ic_primary_bar" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/diet_restrict"
|
||||
android:id="@+id/diet_restrict_img"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_centerVertical="true"
|
||||
@@ -533,7 +540,7 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_toEndOf="@id/diet_restrict"
|
||||
android:layout_toEndOf="@id/diet_restrict_img"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -546,6 +553,7 @@
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/diet_restrict"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -590,6 +598,7 @@
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/add_med_info"
|
||||
android:visibility="gone"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
|
||||
|
||||
@@ -200,15 +200,15 @@
|
||||
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/med_info_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
@@ -257,15 +257,15 @@
|
||||
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/setup_routine_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
@@ -313,15 +313,15 @@
|
||||
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/freq_apps"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
|
||||
@@ -41,25 +41,6 @@
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/edit"
|
||||
|
||||
app:srcCompat="@drawable/ic_edit_outline"
|
||||
android:layout_alignParentEnd="true"
|
||||
|
||||
android:baselineAlignBottom="true"
|
||||
|
||||
android:layout_below="@id/back_btn"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
android:padding="3dp"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/today_date"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/white_bg"
|
||||
android:overScrollMode="never">
|
||||
|
||||
@@ -65,11 +66,10 @@
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="15dp"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false"
|
||||
android:weightSum="7">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sun"
|
||||
android:id="@+id/day"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -82,25 +82,25 @@
|
||||
android:paddingVertical="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sun_t1"
|
||||
android:id="@+id/day_t1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/sun"
|
||||
tools:text="@string/sun"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sun_t2"
|
||||
android:id="@+id/day_t2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -118,7 +118,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mon"
|
||||
android:id="@+id/day2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -135,25 +135,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mon_t1"
|
||||
android:id="@+id/day2_t1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/mon"
|
||||
tools:text="@string/mon"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mon_t2"
|
||||
android:id="@+id/day2_t2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -171,7 +171,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tue"
|
||||
android:id="@+id/day3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -188,25 +188,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tue_1"
|
||||
android:id="@+id/day3_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/tue"
|
||||
tools:text="@string/tue"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tue_2"
|
||||
android:id="@+id/day3_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -224,7 +224,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wed"
|
||||
android:id="@+id/day4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -241,25 +241,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wed_1"
|
||||
android:id="@+id/day4_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/wed"
|
||||
tools:text="@string/wed"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wed_2"
|
||||
android:id="@+id/day4_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -277,7 +277,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/thu"
|
||||
android:id="@+id/day5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -294,25 +294,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thu_1"
|
||||
android:id="@+id/day5_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/thu"
|
||||
tools:text="@string/thu"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thu_2"
|
||||
android:id="@+id/day5_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -330,7 +330,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fri"
|
||||
android:id="@+id/day6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -347,25 +347,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fri_1"
|
||||
android:id="@+id/day6_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/fri"
|
||||
tools:text="@string/fri"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fri_2"
|
||||
android:id="@+id/day6_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -383,7 +383,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sat"
|
||||
android:id="@+id/day7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -398,25 +398,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sat_1"
|
||||
android:id="@+id/day7_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/sat"
|
||||
tools:text="@string/sat"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sat_2"
|
||||
android:id="@+id/day7_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
|
||||
@@ -157,9 +157,9 @@
|
||||
android:textColor="#131313"
|
||||
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_below="@+id/card"
|
||||
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="-35dp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
<ImageView
|
||||
android:transitionName="main_icon"
|
||||
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
app:srcCompat="@drawable/main_icon"
|
||||
android:contentDescription="@string/welcome_msg"
|
||||
|
||||
android:layout_marginTop="25dp"
|
||||
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
@@ -41,48 +42,31 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="6">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/next_btn"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:contentDescription="@string/next_btn"
|
||||
|
||||
app:srcCompat="@drawable/welcome_next"
|
||||
|
||||
android:layout_centerHorizontal="true"
|
||||
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/welcome_illustration"
|
||||
|
||||
app:srcCompat="@drawable/welocme_txt_bg"
|
||||
android:scaleType="fitXY"
|
||||
|
||||
android:layout_marginTop="30dp"
|
||||
android:background="@drawable/round_corners"
|
||||
android:backgroundTint="#EEF5FC"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:layout_marginTop="@dimen/_30sdp"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/next_btn"
|
||||
android:layout_width="@dimen/_60sdp"
|
||||
android:layout_height="@dimen/_60sdp"
|
||||
|
||||
android:src="@drawable/welcome_next"
|
||||
|
||||
android:text="@string/welcome_to_nsimplitend"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:fontFamily="@font/nunito_bold"
|
||||
android:textSize="@dimen/_28ssp"
|
||||
android:textColor="@color/black"
|
||||
android:textAlignment="center"
|
||||
app:civ_border_width="@dimen/_5sdp"
|
||||
app:civ_border_color="@color/white"
|
||||
|
||||
android:layout_below="@id/next_btn"
|
||||
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginBottom="@dimen/_15sdp"
|
||||
|
||||
/>
|
||||
|
||||
@@ -90,17 +74,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_below="@id/title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginHorizontal="@dimen/_15ssp"
|
||||
android:layout_marginVertical="@dimen/_10ssp"
|
||||
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
|
||||
android:text="@string/welcome_msg"
|
||||
android:textAlignment="center"
|
||||
android:textSize="@dimen/_18ssp"
|
||||
android:textColor="@color/black" />
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
"countries": [
|
||||
{
|
||||
"country": "United States",
|
||||
"states": ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"]
|
||||
},
|
||||
{
|
||||
"country": "Afghanistan",
|
||||
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
|
||||
@@ -728,10 +732,6 @@
|
||||
"country": "United Kingdom",
|
||||
"states": []
|
||||
},
|
||||
{
|
||||
"country": "United States",
|
||||
"states": ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"]
|
||||
},
|
||||
{
|
||||
"country": "Uruguay",
|
||||
"states": ["Artigas", "Canelones", "Cerro Largo", "Colonia", "Durazno", "Flores", "Florida", "Lavalleja", "Maldonado", "Montevideo", "Paysandu", "Rio Negro", "Rivera", "Rocha", "Salto", "San Jose", "Soriano", "Tacuarembo", "Treinta y Tres"]
|
||||
|
||||
@@ -234,5 +234,6 @@
|
||||
<string name="ok">Ok</string>
|
||||
<string name="something_went_wrong">Something went wrong</string>
|
||||
<string name="at">at</string>
|
||||
<string name="caring_for_loved_one">Caring for a loved one may be\noverwhelming....\nLet our app assist you!</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user