hometc
This commit is contained in:
10
.idea/deploymentTargetDropDown.xml
generated
10
.idea/deploymentTargetDropDown.xml
generated
@@ -1,18 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$USER_HOME$/.android/avd/Pixel_7_Pro_API_33.avd" />
|
||||
<value value="C:\Users\ADITYA\.android\avd\Aditya_Pie.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-11-17T15:19:06.042756Z" />
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-11-17T19:42:40.119339700Z" />
|
||||
<targetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -82,6 +83,10 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
private BroadcastReceiver notification_receiver;
|
||||
|
||||
private boolean gotoGeofenceActivity;
|
||||
|
||||
private Marker pat_curr_marker;
|
||||
|
||||
public CgDashBoardFragment(){
|
||||
// required empty
|
||||
}
|
||||
@@ -180,8 +185,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
patientData = careGiverData.patientDetails;
|
||||
|
||||
binding.patientName.setText(patientData.first_name);
|
||||
|
||||
loadPatientData();
|
||||
}
|
||||
|
||||
private void setUpMap() {
|
||||
@@ -226,6 +229,9 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
binding.onGoingActivity.setText(viewModel.ongoingActivityText);
|
||||
binding.nearestReminder.setText(viewModel.upcomingReminderText);
|
||||
|
||||
this.gotoGeofenceActivity = false;
|
||||
loadGeofenceDetails();
|
||||
|
||||
loadReminders();
|
||||
loadActivities();
|
||||
|
||||
@@ -350,6 +356,8 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
loadPatientData();
|
||||
|
||||
loadGeofenceDetails();
|
||||
|
||||
googleMap.setOnMapClickListener(latLng1 -> {
|
||||
if (careGiverData != null) {
|
||||
progressDialog.setTitle("please wait...");
|
||||
@@ -357,10 +365,8 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
viewModel.getGeoFenceDetails(careGiverData.patientId + "",
|
||||
"",
|
||||
"Bearer " + AppUtil.getCgToken(requireContext()),
|
||||
this);
|
||||
this.gotoGeofenceActivity = true;
|
||||
loadGeofenceDetails();
|
||||
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
|
||||
@@ -368,6 +374,15 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
});
|
||||
}
|
||||
|
||||
private void loadGeofenceDetails(){
|
||||
if (careGiverData == null) return;
|
||||
|
||||
viewModel.getGeoFenceDetails(careGiverData.patientId + "",
|
||||
"",
|
||||
"Bearer " + AppUtil.getCgToken(requireContext()),
|
||||
this);
|
||||
}
|
||||
|
||||
private void loadPatientData() {
|
||||
LatLng latLng;
|
||||
String patient_name;
|
||||
@@ -396,7 +411,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.img_home_marker))
|
||||
.title(patient_name);
|
||||
|
||||
mGoogleMap.clear();
|
||||
mGoogleMap.addMarker(markerOptions);
|
||||
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));;
|
||||
}
|
||||
@@ -405,9 +419,34 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
public void onGeofenceDetailsFetched(GeoFenceDetails geoFenceDetails) {
|
||||
progressDialog.dismiss();
|
||||
try {
|
||||
Intent intent = new Intent(requireActivity(), CgGeoFencingActivity.class);
|
||||
intent.putExtra(GEOFENCE_DETAILS_KEY, geoFenceDetails);
|
||||
startActivity(intent);
|
||||
if (gotoGeofenceActivity){
|
||||
Intent intent = new Intent(requireActivity(), CgGeoFencingActivity.class);
|
||||
intent.putExtra(GEOFENCE_DETAILS_KEY, geoFenceDetails);
|
||||
startActivity(intent);
|
||||
}else{
|
||||
// load into home screen map view
|
||||
LatLng pat_cur_latLng;
|
||||
try {
|
||||
pat_cur_latLng = new LatLng(Double.parseDouble(geoFenceDetails.patient_radius_location.lat),
|
||||
Double.parseDouble(geoFenceDetails.patient_radius_location.lng));
|
||||
} catch (Exception e) {
|
||||
pat_cur_latLng = null;
|
||||
}
|
||||
|
||||
if (pat_cur_latLng != null && mGoogleMap != null){
|
||||
mGoogleMap.clear();
|
||||
|
||||
loadPatientData();
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(pat_cur_latLng)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.img_pat_curr_location));
|
||||
|
||||
mGoogleMap.addMarker(markerOptions);
|
||||
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(pat_cur_latLng, 16));;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
@@ -416,8 +455,13 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
@Override
|
||||
public void onGeofenceDetailsFetchFailed(Throwable throwable, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
try {
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
if (gotoGeofenceActivity) {
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}else {
|
||||
loadPatientData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
@@ -425,7 +469,7 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
@Override
|
||||
public void onRemindersListFetched(List<ReminderResult> reminderResult) {
|
||||
viewModel.remindersList = reminderResult;
|
||||
CaregiverMainViewModel.remindersList = reminderResult;
|
||||
viewModel.getNearestReminder(reminderResult, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
private boolean isTrackingSenior;
|
||||
|
||||
private String selectedStreet;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -403,16 +405,21 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
Map<String, String> body = new HashMap<>();
|
||||
|
||||
String addressLine = "";
|
||||
if (address.getMaxAddressLineIndex() >= 0 && address.getAddressLine(0) != null) {
|
||||
String[] addressLines = address.getAddressLine(0).split(",");
|
||||
for (int i = 0; i < Math.min(1, addressLines.length); i++) {
|
||||
addressLine = addressLine.concat(addressLines[i]);
|
||||
String addressLine;
|
||||
if (this.selectedStreet == null) {
|
||||
addressLine = "";
|
||||
if (address.getMaxAddressLineIndex() >= 0 && address.getAddressLine(0) != null) {
|
||||
String[] addressLines = address.getAddressLine(0).split(",");
|
||||
for (int i = 0; i < Math.min(1, addressLines.length); i++) {
|
||||
addressLine = addressLine.concat(addressLines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addressLine.isEmpty()){
|
||||
addressLine = (address.getThoroughfare() != null ? address.getThoroughfare() : address.getSubThoroughfare());
|
||||
if (addressLine.isEmpty()){
|
||||
addressLine = (address.getThoroughfare() != null ? address.getThoroughfare() : address.getSubThoroughfare());
|
||||
}
|
||||
} else {
|
||||
addressLine = this.selectedStreet;
|
||||
}
|
||||
|
||||
body.put("town", (address.getSubLocality() != null ? address.getSubLocality() : address.getLocality()));
|
||||
@@ -536,6 +543,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
this.mHomeLatLng = latLng1;
|
||||
isTrackingSenior = false;
|
||||
this.selectedStreet = null;
|
||||
|
||||
binding.updateBtnsView.setVisibility(View.VISIBLE);
|
||||
binding.homeLocationBtn.setVisibility(View.GONE);
|
||||
@@ -634,6 +642,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
if (place.getLatLng() == null) return;
|
||||
|
||||
this.mHomeLatLng = place.getLatLng();
|
||||
this.selectedStreet = place.getName();
|
||||
|
||||
binding.updateBtnsView.setVisibility(View.VISIBLE);
|
||||
binding.homeLocationBtn.setVisibility(View.GONE);
|
||||
|
||||
@@ -125,53 +125,25 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
|
||||
protected Void doInBackground(Void... voids) {
|
||||
SocketHelper socketHelper = SocketHelper.getInstance();
|
||||
|
||||
socketHelper.getMessage(new SocketHelper.Callback<Message>() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: CONNECTING TO SOCKET");
|
||||
|
||||
socketHelper.establishConnection(new SocketHelper.SockCallBack() {
|
||||
@Override
|
||||
public void onMessageReceived(Message result) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: MESSAGE SENT");
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
public void onSocketConnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTED");
|
||||
socketHelper.sendMessage(message, cg_id + "", patientId + "", channel_id + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageSentSuccessfully() {
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
public void onConnectionError(Exception e) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTION ERROR " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: MESSAGE NOT SENT " + e);
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
public void onDisconnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET DISCONNECTED");
|
||||
}
|
||||
}, cg_id + "", channel_id + "", patientId + "", null);
|
||||
|
||||
if (socketHelper.isConnected()) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: ALREADY CONNECTED TO SOCKET");
|
||||
socketHelper.sendMessage(message, cg_id + "", patientId + "", channel_id + "");
|
||||
} else {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: CONNECTING TO SOCKET");
|
||||
|
||||
socketHelper.establishConnection(new SocketHelper.SockCallBack() {
|
||||
@Override
|
||||
public void onSocketConnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTED");
|
||||
socketHelper.sendMessage(message, cg_id + "", patientId + "", channel_id + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionError(Exception e) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTION ERROR " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET DISCONNECTED");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user