.
This commit is contained in:
@@ -290,4 +290,11 @@ public abstract class AppUtil {
|
||||
phone_number, null));
|
||||
if (activity != null) activity.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void messageNumber(Activity activity, String phone_number){
|
||||
Uri uri = Uri.parse("smsto:" + phone_number);
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
|
||||
// intent.putExtra("sms_body", "The SMS text");
|
||||
if (activity != null) activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,20 @@ package com.ssb.simplitend.apputils;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.PatientProfileAPIService;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeApiService;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactData;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactListResponse;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.WelcomeApiService;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@@ -19,6 +24,64 @@ public class PatientDataCache {
|
||||
|
||||
private static PatientData patientData;
|
||||
|
||||
private static ArrayList<ContactData> contactList;
|
||||
|
||||
public synchronized static void setContactList(ArrayList<ContactData> newContactList){
|
||||
contactList = newContactList;
|
||||
}
|
||||
|
||||
public synchronized static void getContactList(Context context,
|
||||
String token,
|
||||
@NonNull PatientDataCache.GetContactList callBack,
|
||||
boolean show_progress){
|
||||
if (contactList != null){
|
||||
callBack.contactList(contactList);
|
||||
return;
|
||||
}
|
||||
|
||||
updateContactList(context, token, callBack, show_progress);
|
||||
}
|
||||
|
||||
private static void updateContactList(Context context, String token, GetContactList callBack, boolean show_progress) {
|
||||
WelcomeApiService apiService = RetrofitHelper.getRetrofit().create(WelcomeApiService.class);
|
||||
|
||||
ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we fetch details for you...");
|
||||
progressDialog.setCancelable(false);
|
||||
if (show_progress) {
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
apiService.getContactList(token)
|
||||
.enqueue(new Callback<CallResponse<List<ContactListResponse>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<ContactListResponse>>> call, Response<CallResponse<List<ContactListResponse>>> response) {
|
||||
progressDialog.dismiss();
|
||||
if (response.code() == 200 && response.body() != null && response.body().result != null){
|
||||
ArrayList<ContactData> contactList = new ArrayList<>();
|
||||
|
||||
for (ContactListResponse contactResponse : response.body().result){
|
||||
contactResponse.contact_data.contact_id = contactResponse.id;
|
||||
contactResponse.contact_data.is_doctor = contactResponse.is_doctor;
|
||||
contactList.add(contactResponse.contact_data);
|
||||
}
|
||||
|
||||
setContactList(contactList);
|
||||
callBack.contactList(contactList);
|
||||
}else{
|
||||
callBack.contactList(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<List<ContactListResponse>>> call, Throwable t) {
|
||||
progressDialog.dismiss();
|
||||
callBack.contactList(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized static void setPatientData(PatientData data){
|
||||
patientData = data;
|
||||
}
|
||||
@@ -77,4 +140,9 @@ public class PatientDataCache {
|
||||
public interface GetPatientCallBack{
|
||||
void patientData(PatientData patientData);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface GetContactList{
|
||||
void contactList(ArrayList<ContactData> contactList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.ssb.simplitend.caregiverdashboard.activities;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.ActivityPatientProfileShowerBinding;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.MedicalInfoFragment;
|
||||
|
||||
@@ -377,6 +377,8 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
if (nearestReminder.upcoming_time == null){
|
||||
binding.nearestReminder.setText(R.string.all_reminder_done);
|
||||
viewModel.upcomingReminderText = binding.nearestReminder.getText().toString();
|
||||
viewModel.dailyReminderText = binding.dailyReminder.getText().toString();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -460,6 +462,9 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
if (nearestActivity.upcoming_time == null){
|
||||
binding.upcomingActivity.setText(R.string.no_upcoming_activities);
|
||||
|
||||
viewModel.upcomingActivityText = binding.upcomingActivity.getText().toString();
|
||||
viewModel.ongoingActivityText = binding.onGoingActivity.getText().toString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,11 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
@@ -27,9 +30,9 @@ import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.maps.DirectionsApi;
|
||||
import com.google.maps.GeoApiContext;
|
||||
import com.google.maps.android.PolyUtil;
|
||||
@@ -46,6 +49,12 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
|
||||
protected ActivityDirectionToHomeBinding binding;
|
||||
|
||||
public static final String LAT_KEY = "lat_key";
|
||||
public static final String LNG_KEY = "lng_key";
|
||||
|
||||
private double pat_lat, pat_lng;
|
||||
private double pat_cur_lat, pat_cur_lng;
|
||||
|
||||
private ActivityResultLauncher<String[]> locationPermissionLauncher;
|
||||
private ActivityResultLauncher<Intent> enableLocationIntent;
|
||||
private FusedLocationProviderClient fusedLocationProviderClient;
|
||||
@@ -53,16 +62,49 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
private LocationRequest locationRequest;
|
||||
private GoogleMap mGoogleMap;
|
||||
|
||||
private BottomSheetBehavior<LinearLayout> bottomSheetBehavior;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityDirectionToHomeBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && intent.hasExtra(LAT_KEY) && intent.hasExtra(LNG_KEY)){
|
||||
pat_lat = intent.getDoubleExtra(LAT_KEY, 0);
|
||||
pat_lng = intent.getDoubleExtra(LNG_KEY, 0);
|
||||
}else {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
getLocationPermission();
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.closeBtn.setOnClickListener(v -> {
|
||||
if(bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED){
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
});
|
||||
|
||||
binding.goBtn.setOnClickListener(v -> {
|
||||
String cur_location = pat_cur_lat + "," + pat_cur_lng;
|
||||
String pat_location = pat_lat + "," + pat_lng;
|
||||
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
|
||||
Uri.parse("http://maps.google.com/maps?saddr=" + cur_location + "&daddr=" + pat_location));
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> {
|
||||
onBackPressed();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,6 +128,23 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
locationRequest = new LocationRequest.Builder(LocationRequest.PRIORITY_HIGH_ACCURACY, 5000)
|
||||
.build();
|
||||
|
||||
bottomSheetBehavior = BottomSheetBehavior.from(binding.directionBs);
|
||||
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED){
|
||||
binding.closeBtn.setVisibility(View.GONE);
|
||||
}else if (newState == BottomSheetBehavior.STATE_EXPANDED){
|
||||
binding.closeBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getLocationPermission() {
|
||||
@@ -168,6 +227,8 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
private void addMarkersToMap(DirectionsResult results, GoogleMap mMap) throws Exception {
|
||||
pat_cur_lat = results.routes[0].legs[0].startLocation.lat;
|
||||
pat_cur_lng = results.routes[0].legs[0].startLocation.lng;
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].startLocation.lat,results.routes[0].legs[0].startLocation.lng)).title("Your location"));
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].endLocation.lat,results.routes[0].legs[0].endLocation.lng)).title("Senior's location"));
|
||||
}
|
||||
@@ -184,7 +245,7 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
int padding = ((getWindowManager().getDefaultDisplay().getWidth() * 10) / 100); // offset from edges of the map
|
||||
// in pixels
|
||||
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,
|
||||
padding);
|
||||
padding+100);
|
||||
mMap.animateCamera(cu);
|
||||
}
|
||||
|
||||
@@ -232,15 +293,21 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
.apiKey(getString(R.string.GOOGLE_MAPS_API_KEY))
|
||||
.build())
|
||||
.origin(new com.google.maps.model.LatLng(location.getLatitude(), location.getLongitude()))
|
||||
.destination(new com.google.maps.model.LatLng(28.42104670992253, 76.92862066485148))
|
||||
.destination(new com.google.maps.model.LatLng(pat_lat, pat_lng))
|
||||
.alternatives(true)
|
||||
.await();
|
||||
|
||||
addMarkersToMap(directionsResult, mGoogleMap);
|
||||
positionCamera(directionsResult.routes[0], mGoogleMap);
|
||||
addPolyline(directionsResult, mGoogleMap);
|
||||
|
||||
binding.progress.setVisibility(View.GONE);
|
||||
binding.progress.setEnabled(false);
|
||||
binding.directionBs.setVisibility(View.VISIBLE);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "Couldn't load routes", Toast.LENGTH_SHORT).show();
|
||||
binding.progress.setVisibility(View.GONE);
|
||||
binding.progress.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.ssb.simplitend.patient_dashboard.fragments;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.ActivityCallsBinding;
|
||||
import com.ssb.simplitend.databinding.CallListDialogBinding;
|
||||
import com.ssb.simplitend.databinding.CreateContactViewHolderBinding;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.AddContactAdapter;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CallsActivity extends AppCompatActivity implements AddContactAdapter.ContactClickListener {
|
||||
|
||||
protected ActivityCallsBinding binding;
|
||||
|
||||
public static final String CALL_CONTACT_LIST_KEY = "contact_list_key";
|
||||
|
||||
protected AddContactAdapter contactAdapter;
|
||||
protected ArrayList<ContactData> contactList;
|
||||
|
||||
private String select_phone_number;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityCallsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
contactList = (ArrayList<ContactData>) getIntent().getSerializableExtra(CALL_CONTACT_LIST_KEY);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.backBtn.setOnClickListener(view -> onBackPressed());
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
binding.contactRv.setLayoutManager(new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false));
|
||||
contactAdapter = new AddContactAdapter();
|
||||
binding.contactRv.setAdapter(contactAdapter);
|
||||
contactAdapter.setContactClickListener(this);
|
||||
|
||||
if (contactList != null){
|
||||
contactAdapter.submitList(contactList);
|
||||
}else{
|
||||
Toast.makeText(this, "Couldn't load contact list", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showContactDialog(ContactData contactData) {
|
||||
CallListDialogBinding dialogBinding = CallListDialogBinding.inflate(getLayoutInflater());
|
||||
BottomSheetDialog bsd = new BottomSheetDialog(this, R.style.BottomSheetDialog);
|
||||
bsd.setContentView(dialogBinding.getRoot());
|
||||
|
||||
boolean default_contact_set = false;
|
||||
if (contactData.phone_number != null) {
|
||||
addContactView(contactData.phone_number, default_contact_set = true, dialogBinding.contactTable, contactData);
|
||||
select_phone_number = contactData.phone_number;
|
||||
}
|
||||
|
||||
// adding contacts to Contact_rv
|
||||
if (contactData.extra_phone_numbers != null && !contactData.extra_phone_numbers.isEmpty()) {
|
||||
String[] phone_numbers = contactData.extra_phone_numbers.split(",");
|
||||
|
||||
for (String phone_number : phone_numbers) {
|
||||
addContactView(phone_number, phone_numbers.length == 1 && !default_contact_set, dialogBinding.contactTable, contactData);
|
||||
}
|
||||
}
|
||||
|
||||
dialogBinding.callBtn.setOnClickListener(v -> {
|
||||
if (select_phone_number == null){
|
||||
Toast.makeText(this, "Select a contact", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
AppUtil.dialPhone(this, select_phone_number);
|
||||
});
|
||||
|
||||
dialogBinding.messageBtn.setOnClickListener(v -> {
|
||||
if (select_phone_number == null){
|
||||
Toast.makeText(this, "Select a contact", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
AppUtil.messageNumber(this, select_phone_number);
|
||||
});
|
||||
|
||||
bsd.show();
|
||||
}
|
||||
|
||||
private void addContactView(String contact_number, boolean id_default,
|
||||
TableLayout tableLayout, ContactData contactData) {
|
||||
CreateContactViewHolderBinding contact_binding = CreateContactViewHolderBinding.inflate(getLayoutInflater());
|
||||
|
||||
contact_binding.createCountryCodes.setVisibility(View.GONE);
|
||||
contact_binding.createCountryCodes.setEnabled(false);
|
||||
|
||||
contact_binding.createPhoneNumber.setText(contact_number);
|
||||
contact_binding.createPhoneNumber.setEnabled(false);
|
||||
|
||||
contact_binding.defaultCheck.setOnClickListener(v -> {
|
||||
if (!contact_binding.defaultCheck.isSelected()) {
|
||||
selectDefaultContact(tableLayout.indexOfChild(contact_binding.getRoot()), tableLayout);
|
||||
select_phone_number = contact_number;
|
||||
}
|
||||
});
|
||||
|
||||
contact_binding.delete.setOnClickListener(v -> {
|
||||
if (tableLayout.getChildCount() == 1) {
|
||||
Toast.makeText(this, "Cannot be deleted", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
tableLayout.removeView(contact_binding.getRoot());
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "Couldn't delete contact.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
contact_binding.defaultCheck.setSelected(id_default);
|
||||
|
||||
// if contact is a doctor we wont allow the contact to be changes
|
||||
if (contactData != null && contactData.is_doctor != null && contactData.is_doctor.equals("1")){
|
||||
contact_binding.createPhoneNumber.setEnabled(false);
|
||||
contact_binding.createCountryCodes.setEnabled(false);
|
||||
contact_binding.defaultCheck.setEnabled(false);
|
||||
}
|
||||
|
||||
tableLayout.addView(contact_binding.getRoot());
|
||||
}
|
||||
|
||||
private void selectDefaultContact(int index, TableLayout tableLayout) {
|
||||
int count = tableLayout.getChildCount();
|
||||
if (index >= 0 && index < count) {
|
||||
// unselecting all other editBoxes
|
||||
for (int i = 0; i < count; i++) {
|
||||
View view = tableLayout.getChildAt(i);
|
||||
if (view != null) {
|
||||
ImageButton default_check = view.findViewById(R.id.default_check);
|
||||
if (default_check != null) {
|
||||
|
||||
if (i == index) {
|
||||
default_check.setSelected(true);
|
||||
} else {
|
||||
default_check.setSelected(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactClick(ContactData contactData, int position) {
|
||||
showContactDialog(contactData);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.ssb.simplitend.patient_dashboard.fragments;
|
||||
|
||||
import static com.ssb.simplitend.patient_dashboard.DirectionToHomeActivity.LAT_KEY;
|
||||
import static com.ssb.simplitend.patient_dashboard.DirectionToHomeActivity.LNG_KEY;
|
||||
import static com.ssb.simplitend.patient_dashboard.fragments.CallsActivity.CALL_CONTACT_LIST_KEY;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -9,6 +13,7 @@ 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;
|
||||
@@ -24,9 +29,11 @@ import com.ssb.simplitend.apputils.PatientDataCache;
|
||||
import com.ssb.simplitend.databinding.PatientDashboardFragmentBinding;
|
||||
import com.ssb.simplitend.patient_dashboard.DirectionToHomeActivity;
|
||||
import com.ssb.simplitend.welcome.activities.WelcomeActivity;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.models.ContactData;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -37,6 +44,8 @@ public class PatientDashboardFragment extends Fragment {
|
||||
|
||||
private PatientData patientData;
|
||||
|
||||
private ArrayList<ContactData> contactList;
|
||||
|
||||
// date suffixes
|
||||
String[] suffixes =
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
@@ -79,6 +88,11 @@ public class PatientDashboardFragment extends Fragment {
|
||||
setDetails();
|
||||
}), true);
|
||||
|
||||
PatientDataCache.getContactList(requireContext(),"Bearer " + AppUtil.getPatientToken(requireContext()),
|
||||
(contactList1 -> {
|
||||
this.contactList = contactList1;
|
||||
}), false);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@@ -140,7 +154,24 @@ public class PatientDashboardFragment extends Fragment {
|
||||
binding.closeReminder.setOnClickListener(v -> removeReminder());
|
||||
|
||||
binding.calls.setOnClickListener(v -> {
|
||||
PatientDataCache.getContactList(requireContext(),
|
||||
"Bearer " + AppUtil.getPatientToken(requireContext()), (contactList1 -> {
|
||||
this.contactList = contactList1;
|
||||
|
||||
if (contactList != null){
|
||||
Intent intent = new Intent(requireActivity(), CallsActivity.class);
|
||||
intent.putExtra(CALL_CONTACT_LIST_KEY, contactList);
|
||||
startActivity(intent);
|
||||
|
||||
}else{
|
||||
Toast.makeText(requireContext(), "Couldn't load contact list", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}), true);
|
||||
});
|
||||
|
||||
binding.calls.setOnLongClickListener(v -> {
|
||||
addReminder();
|
||||
return true;
|
||||
});
|
||||
|
||||
binding.profile.setOnClickListener(v -> {
|
||||
@@ -153,9 +184,21 @@ public class PatientDashboardFragment extends Fragment {
|
||||
});
|
||||
|
||||
binding.directions.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), DirectionToHomeActivity.class);
|
||||
startActivity(intent);
|
||||
if (patientData == null) return;
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(requireActivity(), DirectionToHomeActivity.class);
|
||||
double lat = Double.parseDouble(patientData.lat);
|
||||
double lng = Double.parseDouble(patientData.lng);
|
||||
intent.putExtra(LAT_KEY, lat);
|
||||
intent.putExtra(LNG_KEY, lng);
|
||||
startActivity(intent);
|
||||
}catch (Exception e){
|
||||
Toast.makeText(requireContext(), "Couldn't load your home location", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void updateTime() {
|
||||
|
||||
Reference in New Issue
Block a user