From dc26b40bfa156725888bff47e991a595219371b9 Mon Sep 17 00:00:00 2001 From: meet2711 Date: Thu, 11 Apr 2024 19:13:08 +0530 Subject: [PATCH] . --- .idea/deploymentTargetDropDown.xml | 8 +- .../locationupdates/LocationService.java | 4 +- .../FoodReminderNotifyingService.java | 6 +- .../fragments/register/SplashFragment.java | 119 ++++++++++++------ 4 files changed, 95 insertions(+), 42 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index ad808ad..cb3d0c6 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -4,9 +4,9 @@ - + - + @@ -14,8 +14,8 @@ - - + + diff --git a/app/src/main/java/com/app/simplitend/locationupdates/LocationService.java b/app/src/main/java/com/app/simplitend/locationupdates/LocationService.java index e887cbe..9438fc7 100644 --- a/app/src/main/java/com/app/simplitend/locationupdates/LocationService.java +++ b/app/src/main/java/com/app/simplitend/locationupdates/LocationService.java @@ -192,7 +192,7 @@ public class LocationService extends Service implements LocationClient.DefaultLo .setOngoing(true) .build(); - NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); +// NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); try { locationClient.getLocationUpdates(minInterval, this); @@ -201,7 +201,7 @@ public class LocationService extends Service implements LocationClient.DefaultLo } startForeground(LOCATION_UPDATES_NOTIFICATION_ID, notification); - notificationManager.notify(LOCATION_UPDATES_NOTIFICATION_ID, notification); +// notificationManager.notify(LOCATION_UPDATES_NOTIFICATION_ID, notification); } @Override diff --git a/app/src/main/java/com/app/simplitend/patient_dashboard/foodreminders/FoodReminderNotifyingService.java b/app/src/main/java/com/app/simplitend/patient_dashboard/foodreminders/FoodReminderNotifyingService.java index 2288c35..d1000d6 100644 --- a/app/src/main/java/com/app/simplitend/patient_dashboard/foodreminders/FoodReminderNotifyingService.java +++ b/app/src/main/java/com/app/simplitend/patient_dashboard/foodreminders/FoodReminderNotifyingService.java @@ -38,7 +38,11 @@ public class FoodReminderNotifyingService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { - int which_meal = intent.getIntExtra(WHICH_FOOD_REMINDER, -1); + int which_meal = -1; + + if (intent != null) { + which_meal = intent.getIntExtra(WHICH_FOOD_REMINDER, -1); + } if (which_meal != -1){ Log.d(TAG, "NO clicked for " + which_meal); diff --git a/app/src/main/java/com/app/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java b/app/src/main/java/com/app/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java index c9104fa..b124f49 100644 --- a/app/src/main/java/com/app/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java +++ b/app/src/main/java/com/app/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java @@ -122,6 +122,7 @@ public class SplashFragment extends Fragment } } catch (Exception e) { // do nothing + return; } binding.newUpdateView.getRoot().setVisibility(View.VISIBLE); @@ -149,7 +150,11 @@ public class SplashFragment extends Fragment @Override public void onFailure(Call> call, Throwable t) { - Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + try { + Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + // do nothing + } binding.retry.setVisibility(View.VISIBLE); binding.loadAnim.setVisibility(View.GONE); @@ -162,9 +167,16 @@ public class SplashFragment extends Fragment binding.retry.setVisibility(View.GONE); binding.loadAnim.setVisibility(View.VISIBLE); - String patient_token = AppUtil.getPatientToken(requireContext()); - String cg_token = AppUtil.getCgToken(requireContext()); - boolean is_patient_logged_in = AppUtil.isPatientLoggedIn(requireContext()); + String patient_token = null; + String cg_token = null; + boolean is_patient_logged_in = false; + try { + patient_token = AppUtil.getPatientToken(requireContext()); + cg_token = AppUtil.getCgToken(requireContext()); + is_patient_logged_in = AppUtil.isPatientLoggedIn(requireContext()); + } catch (Exception e) { + // do nothing + } if (patient_token != null && !patient_token.isEmpty() && is_patient_logged_in){ // user is already logged in as PATIENT @@ -238,17 +250,21 @@ public class SplashFragment extends Fragment binding.retry.setVisibility(View.VISIBLE); binding.loadAnim.setVisibility(View.GONE); - new AlertDialog.Builder(requireContext()) - .setTitle("Session Expired") - .setMessage("Your login session has expired.\nPlease login again.") - .setCancelable(true) - .setPositiveButton("OKAY", (dialogInterface, i) -> { - AppUtil.patientSignOut(requireContext()); - AppUtil.cgSignOut(requireContext()); + try { + new AlertDialog.Builder(requireContext()) + .setTitle("Session Expired") + .setMessage("Your login session has expired.\nPlease login again.") + .setCancelable(true) + .setPositiveButton("OKAY", (dialogInterface, i) -> { + AppUtil.patientSignOut(requireContext()); + AppUtil.cgSignOut(requireContext()); - gotoWelcomeFragment(); - }) - .show(); + gotoWelcomeFragment(); + }) + .show(); + } catch (Exception e) { + // do nothing + } } private void gotoReActivateScreen(String cg_status, String token, int cg_xid, boolean is_caregiver){ @@ -286,24 +302,36 @@ public class SplashFragment extends Fragment } private void gotoPatientDashBoard() { - Intent intent = new Intent(requireActivity(), DashBoardActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - requireActivity().finish(); + try { + Intent intent = new Intent(requireActivity(), DashBoardActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + requireActivity().finish(); + } catch (Exception e) { + // do nothing + } } private void gotoCgAuthScreen(){ - Intent intent = new Intent(requireActivity(), CgAuthActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - requireActivity().finish(); + try { + Intent intent = new Intent(requireActivity(), CgAuthActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + requireActivity().finish(); + } catch (Exception e) { + // do nothing + } } private void gotoCgDashBoard(){ - Intent intent = new Intent(requireActivity(), CaregiverDashActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - requireActivity().finish(); + try { + Intent intent = new Intent(requireActivity(), CaregiverDashActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + requireActivity().finish(); + } catch (Exception e) { + // do nothing + } } // get cg user data callback @@ -315,8 +343,12 @@ public class SplashFragment extends Fragment if (!careGiverData.caregiver_status.equals(AccountPresenter.ACC_ACTIVE_STR)){ // account is not active - gotoReActivateScreen(careGiverData.caregiver_status, AppUtil.getCgToken(requireContext()), - careGiverData.caregiver_xid, true); + try { + gotoReActivateScreen(careGiverData.caregiver_status, AppUtil.getCgToken(requireContext()), + careGiverData.caregiver_xid, true); + } catch (Exception e) { + // do nothing + } return; } @@ -326,7 +358,12 @@ public class SplashFragment extends Fragment if (careGiverData.isPatientAndCareGiverConnected == 1){ // patient is linked with the caregiver - int cg_security = AppUtil.getWantSecurityFlag(requireContext()); + int cg_security = 0; + try { + cg_security = AppUtil.getWantSecurityFlag(requireContext()); + } catch (Exception e) { + return; + } if (cg_security == AppUtil.NOT_ASKED_CG_SECURITY || cg_security == AppUtil.CG_SECURITY_NEEDED){ // user want their app to be secure @@ -354,7 +391,11 @@ public class SplashFragment extends Fragment @Override public void onCgDataFetchFailed(Throwable t, String message) { - Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + try { + Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + // do nothing + } binding.retry.setVisibility(View.VISIBLE); binding.loadAnim.setVisibility(View.GONE); @@ -372,9 +413,13 @@ public class SplashFragment extends Fragment if (!patientData.caregiver_status.equals(AccountPresenter.DEFAULT_ACTIVE_STATUS)) { // account is in default state - gotoReActivateScreen(patientData.caregiver_status, - AppUtil.getPatientToken(requireContext()), - -1, false); + try { + gotoReActivateScreen(patientData.caregiver_status, + AppUtil.getPatientToken(requireContext()), + -1, false); + } catch (Exception e) { + // do nothing + } return; } } @@ -385,7 +430,7 @@ public class SplashFragment extends Fragment try { AppUtil.setUserSubscribed(requireContext(), patientData.isCaregiverTakeSubscription == 1); } catch (Exception e) { - // do nothing + return; } if (patientData.isCareGiverConnectedWithPatient == 1 && patientData.isCaregiverTakeSubscription == 1){ @@ -414,7 +459,11 @@ public class SplashFragment extends Fragment @Override public void onProfileProgressFetchFailed(Throwable t, String message) { - Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + try { + Toast.makeText(requireContext(), "Couldn't connect.", Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + // do nothing + } binding.retry.setVisibility(View.VISIBLE); binding.loadAnim.setVisibility(View.GONE);