.
This commit is contained in:
@@ -37,23 +37,36 @@ import com.ssb.simplitend.caregiverdashboard.mvvm.CgHomeContracts;
|
||||
import com.ssb.simplitend.caregiverdashboard.mvvm.models.GeoFenceDetails;
|
||||
import com.ssb.simplitend.cg_geofencing.CgGeoFencingActivity;
|
||||
import com.ssb.simplitend.databinding.CaregiverDashFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.NearestActivity;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.NearestReminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineViewModel;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class CgDashBoardFragment extends Fragment implements
|
||||
OnMapReadyCallback, ArticleContracts.GetArticleCallback, CgHomeContracts.GetGeoFenceCallback {
|
||||
OnMapReadyCallback, ArticleContracts.GetArticleCallback, CgHomeContracts.GetGeoFenceCallback, ProfileContracts.GetRemindersListCallback, CaregiverMainViewModel.GetNearestResultCallback, ProfileContracts.GetRoutinesCallback, CaregiverMainViewModel.GetNearestActivityCallback {
|
||||
|
||||
// view binding
|
||||
protected CaregiverDashFragmentBinding binding;
|
||||
|
||||
private CaregiverMainViewModel viewModel;
|
||||
|
||||
private ReminderViewModel reminderViewModel;
|
||||
private RoutineViewModel routineViewModel;
|
||||
|
||||
private CareGiverData careGiverData;
|
||||
|
||||
private PatientData patientData;
|
||||
@@ -71,8 +84,17 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CaregiverDashFragmentBinding.inflate(inflater, container, false);
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(CaregiverMainViewModel.class);
|
||||
reminderViewModel = new ViewModelProvider(requireActivity()).get(ReminderViewModel.class);
|
||||
routineViewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// CaregiverDataCache.getCaregiverData(requireActivity(), (careGiverData1 -> {
|
||||
// this.careGiverData = careGiverData1;
|
||||
//
|
||||
// loadReminders();
|
||||
// }), true);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -91,9 +113,35 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
this.careGiverData = careGiverData1;
|
||||
|
||||
setDetails();
|
||||
loadReminders();
|
||||
loadActivities();
|
||||
}), true);
|
||||
}
|
||||
|
||||
private void loadActivities() {
|
||||
if (careGiverData == null) return;
|
||||
|
||||
binding.onGoingActivity.setText(getString(R.string.loading));
|
||||
binding.upcomingActivity.setText(getString(R.string.loading));
|
||||
|
||||
routineViewModel.getRoutines(careGiverData.patientId,
|
||||
"Bearer " + AppUtil.getCgToken(requireContext()),
|
||||
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1,
|
||||
this);
|
||||
}
|
||||
|
||||
private void loadReminders(){
|
||||
if (careGiverData == null) return;
|
||||
|
||||
binding.nearestReminder.setText(getString(R.string.loading));
|
||||
binding.dailyReminder.setText(getString(R.string.loading));
|
||||
|
||||
reminderViewModel.getRemindersList(careGiverData.patientId,
|
||||
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1,
|
||||
"Bearer " + AppUtil.getCgToken(requireContext()),
|
||||
this);
|
||||
}
|
||||
|
||||
private void loadArticles() {
|
||||
viewModel.getArticles(this);
|
||||
}
|
||||
@@ -283,4 +331,201 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemindersListFetched(List<ReminderResult> reminderResult) {
|
||||
viewModel.getNearestReminder(reminderResult, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchRemindersListFailed(Throwable t, String message) {
|
||||
binding.nearestReminder.setText(getString(R.string.couldnt_load_data));
|
||||
binding.dailyReminder.setText(getString(R.string.couldnt_load_data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nearestReminder(NearestReminder nearestReminder) {
|
||||
Log.d("aditya", "nearestReminder: " + nearestReminder);
|
||||
|
||||
// daily routine setting
|
||||
String daily_r_txt;
|
||||
|
||||
try {
|
||||
|
||||
if (nearestReminder.daily_reminder_time == null){
|
||||
daily_r_txt = "No daily reminders for today";
|
||||
}else{
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String daily_r_time = format_sdf.format(Objects.requireNonNull(input_sdf.parse(nearestReminder.daily_reminder_time)));
|
||||
daily_r_txt = "Daily reminder at " + daily_r_time;
|
||||
}
|
||||
}catch (Exception e){
|
||||
daily_r_txt = getString(R.string.couldnt_load_data);
|
||||
}
|
||||
|
||||
binding.dailyReminder.setText(daily_r_txt);
|
||||
|
||||
// next reminder setting
|
||||
try {
|
||||
if (nearestReminder == null) throw new Exception();
|
||||
|
||||
if (nearestReminder.upcoming_time == null){
|
||||
binding.nearestReminder.setText(R.string.all_reminder_done);
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
Date upcoming_date = input_sdf.parse(nearestReminder.upcoming_time);
|
||||
if (upcoming_date == null) throw new Exception();
|
||||
|
||||
Calendar cur_cal = Calendar.getInstance();
|
||||
Date cur_date = new Date(upcoming_date.getYear(), upcoming_date.getMonth(), upcoming_date.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), upcoming_date.getSeconds());
|
||||
|
||||
long time_diff = upcoming_date.getTime() - cur_date.getTime() + 1000; // +1000 for extra one min to reach that time
|
||||
|
||||
if (time_diff < 0){
|
||||
// the nearest time has already passed the current time
|
||||
// i.e. all the reminders has been done for current day
|
||||
|
||||
binding.nearestReminder.setText(R.string.all_reminder_done);
|
||||
}else{
|
||||
time_diff = time_diff/1000; // milliseconds to seconds
|
||||
long s = time_diff % 60;
|
||||
long m = (time_diff / 60) % 60;
|
||||
long h = (time_diff / (60 * 60)) % 24;
|
||||
|
||||
StringBuilder reminder_txt = new StringBuilder("Remind " + nearestReminder.medication_name);
|
||||
|
||||
// if (h > 0){
|
||||
// reminder_txt.append(" in " ).append(h);
|
||||
//
|
||||
// if (h > 1) reminder_txt.append(" Hrs ");
|
||||
// else reminder_txt.append(" Hr ");
|
||||
// }
|
||||
//
|
||||
// if (m > 0){
|
||||
// reminder_txt.append(m).append(" Min");
|
||||
//
|
||||
// if (m > 1) reminder_txt.append("s"); // plural
|
||||
// }
|
||||
|
||||
if (time_diff > 3600){
|
||||
// time greater than 60 mins
|
||||
// thus, showing direct time
|
||||
SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
try {
|
||||
String time = format_sdf.format(upcoming_date);
|
||||
reminder_txt.append(" at ").append(time);
|
||||
} catch (Exception e) {
|
||||
reminder_txt.append(" at ").append(nearestReminder.upcoming_time);
|
||||
}
|
||||
|
||||
}else{
|
||||
// show in minutes
|
||||
reminder_txt.append(" in ").append(m).append(" min");
|
||||
|
||||
if (m > 1) reminder_txt.append("s"); // plural
|
||||
}
|
||||
|
||||
binding.nearestReminder.setText(reminder_txt);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
binding.nearestReminder.setText(getString(R.string.couldnt_load_data));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoutinesFetched(List<RoutineDetails> routineList) {
|
||||
viewModel.getNearestActivity(routineList, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoutinesFetchedFailed(Throwable t, String message) {
|
||||
binding.upcomingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
binding.onGoingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nearestActivity(NearestActivity nearestActivity) {
|
||||
if (nearestActivity.ongoing_activity_name != null){
|
||||
binding.onGoingActivity.setText(nearestActivity.ongoing_activity_name);
|
||||
}else{
|
||||
binding.onGoingActivity.setText(R.string.no_ongoing_activity);
|
||||
}
|
||||
|
||||
// next routine setting
|
||||
try {
|
||||
|
||||
if (nearestActivity.upcoming_time == null){
|
||||
binding.upcomingActivity.setText(R.string.no_upcoming_activities);
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
Date upcoming_date = input_sdf.parse(nearestActivity.upcoming_time);
|
||||
if (upcoming_date == null) throw new Exception();
|
||||
|
||||
Calendar cur_cal = Calendar.getInstance();
|
||||
Date cur_date = new Date(upcoming_date.getYear(), upcoming_date.getMonth(), upcoming_date.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), upcoming_date.getSeconds());
|
||||
|
||||
long time_diff = upcoming_date.getTime() - cur_date.getTime() + 1000; // +1000 for extra one min to reach that time
|
||||
|
||||
if (time_diff < 0){
|
||||
// the nearest time has already passed the current time
|
||||
// i.e. all the reminders has been done for current day
|
||||
|
||||
binding.upcomingActivity.setText(R.string.all_reminder_done);
|
||||
}else{
|
||||
time_diff = time_diff/1000; // milliseconds to seconds
|
||||
long s = time_diff % 60;
|
||||
long m = (time_diff / 60) % 60;
|
||||
long h = (time_diff / (60 * 60)) % 24;
|
||||
|
||||
StringBuilder up_activity_txt = new StringBuilder(nearestActivity.upcoming_activity_name);
|
||||
|
||||
// if (h > 0){
|
||||
// up_activity_txt.append(" in " ).append(h);
|
||||
//
|
||||
// if (h > 1) up_activity_txt.append(" Hrs ");
|
||||
// else up_activity_txt.append(" Hr ");
|
||||
// }
|
||||
//
|
||||
// if (m > 0){
|
||||
// up_activity_txt.append(m).append(" Min");
|
||||
//
|
||||
// if (m > 1) up_activity_txt.append("s"); // plural
|
||||
// }
|
||||
|
||||
if (time_diff > 3600){
|
||||
// time greater than 60 mins
|
||||
// thus, showing direct time
|
||||
SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
try {
|
||||
String time = format_sdf.format(upcoming_date);
|
||||
up_activity_txt.append(" at ").append(time);
|
||||
} catch (Exception e) {
|
||||
up_activity_txt.append(" at ").append(nearestActivity.upcoming_time);
|
||||
}
|
||||
|
||||
}else{
|
||||
// show in minutes
|
||||
up_activity_txt.append(" in ").append(m).append(" min");
|
||||
|
||||
if (m > 1) up_activity_txt.append("s"); // plural
|
||||
}
|
||||
|
||||
binding.upcomingActivity.setText(up_activity_txt);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
binding.upcomingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
package com.ssb.simplitend.caregiverdashboard.mvvm;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.articles.ArticleContracts;
|
||||
import com.ssb.simplitend.articles.ArticleResult;
|
||||
import com.ssb.simplitend.caregiverdashboard.mvvm.models.GeoFenceDetails;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.NearestActivity;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.NearestReminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.yarolegovich.slidingrootnav.SlidingRootNav;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
@@ -85,4 +99,236 @@ public class CaregiverMainViewModel extends ViewModel {
|
||||
cgHomeRepository.signOut(token, signOutCallback);
|
||||
}
|
||||
|
||||
public synchronized void getNearestActivity(List<RoutineDetails> activityList,
|
||||
@NonNull GetNearestActivityCallback activityCallback){
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
executor.execute(() -> {
|
||||
// Background work
|
||||
|
||||
NearestActivity nearestActivity = new NearestActivity();
|
||||
|
||||
try {
|
||||
|
||||
for (RoutineDetails activity: activityList){
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
Date start_date = input_sdf.parse(activity.routine_start_time);
|
||||
Date end_date = input_sdf.parse(activity.routine_end_time);
|
||||
|
||||
if (start_date == null || end_date == null) throw new Exception();
|
||||
|
||||
Calendar cur_cal = Calendar.getInstance();
|
||||
|
||||
// matching date and seconds of the current date and routine dates
|
||||
Date cur_date = new Date(start_date.getYear(), start_date.getMonth(), start_date.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), 0);
|
||||
start_date.setSeconds(0);
|
||||
end_date.setSeconds(0);
|
||||
|
||||
// checking on going activity
|
||||
if (cur_date.getTime() >= start_date.getTime() &&
|
||||
cur_date.getTime() <= end_date.getTime()){
|
||||
// on going activity
|
||||
nearestActivity.ongoing_activity_name = activity.routine_title;
|
||||
nearestActivity.ongoing_start_time = activity.routine_start_time;
|
||||
nearestActivity.ongoing_end_time = activity.routine_end_time;
|
||||
}
|
||||
|
||||
// checking upcoming activity
|
||||
if (start_date.getTime() > cur_date.getTime() && smallestTime(activity.routine_start_time, nearestActivity.upcoming_time)){
|
||||
// upcoming_time for this reminder is less than nearestReminder.upcoming_time
|
||||
// thus, updating nearest reminder
|
||||
|
||||
nearestActivity.upcoming_time = activity.routine_start_time;
|
||||
nearestActivity.activity_id = activity.id;
|
||||
nearestActivity.upcoming_activity_name = activity.routine_title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
|
||||
handler.post(() -> activityCallback.nearestActivity(nearestActivity));
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void getNearestReminder(List<ReminderResult> reminderResultList,
|
||||
@NonNull GetNearestResultCallback nearestResultCallback){
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
executor.execute(() -> {
|
||||
// background thread work
|
||||
|
||||
NearestReminder nearestReminder = new NearestReminder();
|
||||
|
||||
try {
|
||||
for (ReminderResult reminder: reminderResultList){
|
||||
|
||||
if (reminder.all_days == 1){
|
||||
nearestReminder.daily_reminder_time = reminder.time1;
|
||||
}
|
||||
|
||||
String upcoming_time = selectNextReminder(reminder.time1, reminder.time2, reminder.time3);
|
||||
|
||||
if (upcoming_time != null && smallestTime(upcoming_time, nearestReminder.upcoming_time)){
|
||||
// upcoming_time for this reminder is less than nearestReminder.upcoming_time
|
||||
// thus, updating nearest reminder
|
||||
|
||||
nearestReminder.upcoming_time = upcoming_time;
|
||||
nearestReminder.reminder_id = reminder.id;
|
||||
nearestReminder.medication_name = reminder.medicine_name;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// callback through main thread
|
||||
handler.post(() -> nearestResultCallback.nearestReminder(nearestReminder));
|
||||
});
|
||||
}
|
||||
|
||||
private String selectNextReminder(@NonNull String time1, String time2, String time3) {
|
||||
return selectNextReminder(time1, selectNextReminder(time2, time3));
|
||||
}
|
||||
|
||||
private String selectNextReminder(String time1, String time2) {
|
||||
if (time1 == null && time2 == null) return null;
|
||||
if (time2 == null) {
|
||||
// time 2 is null
|
||||
// thus, checking if time1 has already passed current_time or not.
|
||||
|
||||
if (alreadyPassed(time1)){
|
||||
// the time1 has already passed the current time
|
||||
// thus, returning null
|
||||
|
||||
return null;
|
||||
}else{
|
||||
// the time1 is yet to come
|
||||
|
||||
return time1;
|
||||
}
|
||||
}
|
||||
if (time1 == null){
|
||||
// time1 is null
|
||||
// thus, checking if time2 has already passed current_time or not.
|
||||
|
||||
if (alreadyPassed(time2)){
|
||||
// the time1 has already passed the current time
|
||||
// thus, returning null
|
||||
|
||||
return null;
|
||||
}else{
|
||||
// the time1 is yet to come
|
||||
|
||||
return time2;
|
||||
}
|
||||
}
|
||||
|
||||
// comparing this 2 times with current time
|
||||
// first converting time string to calendar
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
try {
|
||||
Date date1 = input_sdf.parse(time1);
|
||||
Date date2 = input_sdf.parse(time2);
|
||||
|
||||
if (date2 == null || date1 == null) throw new Exception();
|
||||
|
||||
Calendar cur_cal = Calendar.getInstance();
|
||||
Date cur_date = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), date1.getSeconds());
|
||||
|
||||
// All three above dates are of same date 01 Jan 1970
|
||||
// but, of different times i.e. hh:mm:ss
|
||||
|
||||
long t1 = date1.getTime();
|
||||
long t2 = date2.getTime();
|
||||
long c_t = cur_date.getTime();
|
||||
|
||||
if (t1 < c_t && t2 > c_t){
|
||||
// t1 time is passed and t2 time is yet to come for the same day
|
||||
// thus, returning t2
|
||||
return time2;
|
||||
}else if (t1 > c_t && t2 < c_t){
|
||||
// t1 is yet to come for this day, and t2 has already been passed
|
||||
// thus, returning t1
|
||||
return time1;
|
||||
}else if (t1 > c_t && t2 > c_t){
|
||||
// Both the times are greater than current time, yet to come
|
||||
// In this case, we show the smallest time
|
||||
|
||||
if (t1 < t2) return time1;
|
||||
else return time2;
|
||||
}else{
|
||||
// Last case would be both the times has passed the current time
|
||||
// thus, returning null
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
// if something goes wrong, returning the time1
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the time has passed current time or not
|
||||
private boolean alreadyPassed(String time1) {
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
try {
|
||||
Date date = input_sdf.parse(time1);
|
||||
if (date == null) throw new Exception();
|
||||
|
||||
Calendar cur_cal = Calendar.getInstance();
|
||||
Date cur_date = new Date(date.getYear(), date.getMonth(), date.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), date.getSeconds());
|
||||
|
||||
return date.getTime() <= cur_date.getTime();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if time1 is less than time2;
|
||||
private boolean smallestTime(@NonNull String time1, String time2) {
|
||||
if (time2 == null) return true;
|
||||
|
||||
// comparing this 2 times with current time
|
||||
// first converting time string to calendar
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
try {
|
||||
Date date1 = input_sdf.parse(time1);
|
||||
Date date2 = input_sdf.parse(time2);
|
||||
|
||||
if (date2 == null || date1 == null) throw new Exception();
|
||||
|
||||
// All times above dates are of same date 01 Jan 1970
|
||||
// but, of different times i.e. hh:mm:ss
|
||||
|
||||
long t1 = date1.getTime();
|
||||
long t2 = date2.getTime();
|
||||
|
||||
return t1 < t2;
|
||||
}catch (Exception e){
|
||||
// if something goes wrong, returning the time1
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface GetNearestResultCallback{
|
||||
void nearestReminder(NearestReminder nearestReminder);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface GetNearestActivityCallback{
|
||||
void nearestActivity(NearestActivity nearestActivity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -200,6 +200,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
reminderResult.fri = week_state[5] ? "1" : "0";
|
||||
reminderResult.sat = week_state[6] ? "1" : "0";
|
||||
|
||||
reminderResult.all_days = binding.everydayCheck.isChecked()?1:0;
|
||||
|
||||
if (reminder != null) {
|
||||
// this intent is to update the reminder
|
||||
reminderResult.is_update = "1";
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
public class NearestActivity {
|
||||
public int activity_id;
|
||||
public String upcoming_time, upcoming_activity_name;
|
||||
public String ongoing_start_time, ongoing_end_time, ongoing_activity_name;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NearestActivity{" +
|
||||
"activity_id=" + activity_id +
|
||||
", upcoming_time='" + upcoming_time + '\'' +
|
||||
", upcoming_activity_name='" + upcoming_activity_name + '\'' +
|
||||
", ongoing_start_time='" + ongoing_start_time + '\'' +
|
||||
", ongoing_end_time='" + ongoing_end_time + '\'' +
|
||||
", ongoing_activity_name='" + ongoing_activity_name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
public class NearestReminder {
|
||||
public int reminder_id;
|
||||
public String upcoming_time;
|
||||
public String medication_name;
|
||||
public String daily_reminder_time;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NearestReminder{" +
|
||||
"reminder_id=" + reminder_id +
|
||||
", upcoming_time='" + upcoming_time + '\'' +
|
||||
", medication_name='" + medication_name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public class ReminderResult implements Serializable {
|
||||
public String medication_type_xid;
|
||||
public String medication_frequency_xid;
|
||||
public String reminder_everyday_flag;
|
||||
public int all_days;
|
||||
public String reminder_weekday_flag;
|
||||
public String reminder_time;
|
||||
public String medication_quantity;
|
||||
|
||||
Reference in New Issue
Block a user