location updates from home screen with home location and geofence for reference
This commit is contained in:
@@ -33,10 +33,11 @@ import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.CaregiverDataCache;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CgHomeContracts;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CgHomeRepository;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.models.GeoFenceDetails;
|
||||
import com.app.simplitend.chats.SocketHelper;
|
||||
import com.app.simplitend.databinding.ActivityCgGeofencingBinding;
|
||||
import com.app.simplitend.databinding.GeofenceBottomSheetBinding;
|
||||
import com.app.simplitend.chats.SocketHelper;
|
||||
import com.app.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
import com.bumptech.glide.Glide;
|
||||
@@ -57,7 +58,6 @@ import com.google.android.libraries.places.widget.model.AutocompleteActivityMode
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -65,7 +65,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class CgGeoFencingActivity extends AppCompatActivity implements OnMapReadyCallback,
|
||||
CgHomeContracts.SaveGeoFenceCallback, CgHomeContracts.UpdatePatientAddressCallback {
|
||||
CgHomeContracts.SaveGeoFenceCallback, CgHomeContracts.UpdatePatientAddressCallback, CgHomeContracts.GetGeoFenceCallback {
|
||||
|
||||
private static final String TAG = "CgGeoFencingActivity";
|
||||
|
||||
@@ -184,6 +184,31 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
binding.locationBs.setVisibility(View.VISIBLE);
|
||||
|
||||
binding.refreshBtn.setVisibility(View.VISIBLE);
|
||||
|
||||
binding.refreshBtn.setOnClickListener(v -> {
|
||||
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("while we refresh the details");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
CaregiverDataCache.setCareGiverData(null);
|
||||
CaregiverDataCache.getCaregiverData(this, careGiverData1 -> {
|
||||
if (careGiverData1 != null && careGiverData1.patientDetails != null){
|
||||
this.careGiverData = careGiverData1;
|
||||
this.patientData = careGiverData.patientDetails;
|
||||
|
||||
loadPatientsLocation();
|
||||
|
||||
CgHomeRepository.getHomeRepository().getGeoFenceDetails(AppUtil.getPatientUid(this) + "",
|
||||
"", "Bearer " + AppUtil.getPatientToken(this),
|
||||
this);
|
||||
}
|
||||
}, false);
|
||||
|
||||
});
|
||||
|
||||
BottomSheetBehavior<LinearLayout> bs_behavior = BottomSheetBehavior.from(binding.locationBs);
|
||||
bs_behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
|
||||
@@ -716,7 +741,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
updateHomeMarker(home_lat_lng);
|
||||
addRadius();
|
||||
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home_lat_lng, 14));
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home_lat_lng, 17));
|
||||
} catch (Exception e) {
|
||||
// near marine drive
|
||||
Toast.makeText(this, "Couldn't load home location", Toast.LENGTH_SHORT).show();
|
||||
@@ -749,7 +774,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
if (home_loc_marker != null) home_loc_marker.remove();
|
||||
|
||||
home_loc_marker = mMap.addMarker(markerOptions);
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(home_latLng, 14));
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(home_latLng, 17));
|
||||
}
|
||||
|
||||
private void registerMapSearchResultLauncher() {
|
||||
@@ -849,4 +874,20 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(this, "Couldn't update patient's location.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofenceDetailsFetched(GeoFenceDetails geoFenceDetails) {
|
||||
progressDialog.dismiss();
|
||||
updateCurrentLocationPatientMarker();
|
||||
updatePatientCurrentLocationDetails();
|
||||
if (showLocationUpdates){
|
||||
updateCurrentLocationBs();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofenceDetailsFetchFailed(Throwable throwable, String message) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(this, "Couldn't load senior's current location", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
<LinearLayout
|
||||
@@ -11,7 +12,7 @@
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:gravity="center_vertical"
|
||||
@@ -24,11 +25,16 @@
|
||||
android:layout_height="40dp"
|
||||
android:contentDescription="@string/back_button"
|
||||
android:padding="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/quantum_ic_arrow_back_grey600_24"
|
||||
app:tint="@color/black" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/head_titles"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/back_btn"
|
||||
android:layout_toStartOf="@id/refresh_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginStart="5dp"
|
||||
@@ -44,7 +50,7 @@
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:singleLine="true"
|
||||
android:text="Aditya"
|
||||
tools:text="Aditya"
|
||||
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
@@ -61,7 +67,7 @@
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:singleLine="true"
|
||||
android:text="Last updated now "
|
||||
tools:text="Last updated now "
|
||||
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleSmall"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
@@ -70,7 +76,20 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/refresh_btn"
|
||||
android:visibility="gone"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:contentDescription="@string/back_button"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/ic_refresh"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/geofencing_title"
|
||||
@@ -369,7 +388,7 @@
|
||||
android:padding="15dp"
|
||||
android:orientation="vertical"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="42dp"
|
||||
app:behavior_peekHeight="50dp"
|
||||
android:background="@drawable/top_round_corner"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
@@ -381,72 +400,83 @@
|
||||
android:background="@android:color/darker_gray"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:strokeWidth="1dp"
|
||||
app:strokeColor="@color/color_accent"
|
||||
app:cardCornerRadius="5dp"
|
||||
>
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/bs_senior_image"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
|
||||
android:src="@drawable/static_3" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="10dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bs_senior_name"
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/bs_senior_image"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
|
||||
android:src="@drawable/static_3" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
android:text="@string/couldn_t_load"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_bold"
|
||||
<TextView
|
||||
android:id="@+id/bs_senior_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/couldn_t_load"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_bold"
|
||||
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
/>
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bs_senior_current_location_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
/>
|
||||
|
||||
android:text="@string/couldn_t_load"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_medium"
|
||||
<TextView
|
||||
android:id="@+id/bs_senior_current_location_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/couldn_t_load"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_medium"
|
||||
|
||||
/>
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bs_distance_from_home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
android:text="0.25 miles away from home"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_medium"
|
||||
<TextView
|
||||
android:id="@+id/bs_distance_from_home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
tools:text="0.25 miles away from home"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/nunito_medium"
|
||||
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user