.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
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;
|
||||
@@ -12,15 +14,25 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.careperson_dashboard.DashBoardActivityCP;
|
||||
import com.ssb.simplitend.databinding.ProfileProgressFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
|
||||
public class ProfileProgressFragment extends Fragment {
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ProfileProgressFragment extends Fragment implements ProfileContracts.ProfileProgressCallback {
|
||||
|
||||
// view binding
|
||||
protected ProfileProgressFragmentBinding binding;
|
||||
|
||||
public ProfileProgressFragment(){
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public ProfileProgressFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@@ -29,9 +41,6 @@ public class ProfileProgressFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ProfileProgressFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
// binding.medReminderImg.setImageResource(0);
|
||||
// binding.medReminderImg.setBackgroundResource(R.drawable.ic_done);
|
||||
|
||||
initProgress();
|
||||
|
||||
clickEvents();
|
||||
@@ -40,10 +49,46 @@ public class ProfileProgressFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initProgress() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we load the profile progress.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
PatientProfileAPIService apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
apiService.getUsrProfileProgress(token)
|
||||
.enqueue(new Callback<CallResponse<PatientData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientData>> call, Response<CallResponse<PatientData>> response) {
|
||||
if (response.body() != null) {
|
||||
if (response.body().status != 200 || response.body().result == null) {
|
||||
onProfileProgressFetchFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
onProfileProgressFetched(response.body().result);
|
||||
} else {
|
||||
onProfileProgressFetchFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<PatientData>> call, Throwable t) {
|
||||
onProfileProgressFetchFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.addContact.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_addContactFragment)
|
||||
);
|
||||
|
||||
binding.medicReminder.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_reminderFragment)
|
||||
);
|
||||
@@ -64,4 +109,34 @@ public class ProfileProgressFragment extends Fragment {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileProgressFetched(@NonNull PatientData patientData) {
|
||||
if (patientData.isCareGiverLink == 1) {
|
||||
// TODO: 25-07-2023 look into this
|
||||
}
|
||||
|
||||
if (patientData.isPatientReminderData == 1) {
|
||||
binding.medReminderImg.setImageResource(0);
|
||||
binding.medReminderImg.setBackgroundResource(R.drawable.ic_done);
|
||||
}
|
||||
|
||||
if (patientData.isPatientMedicalData == 1) {
|
||||
binding.medInfoImg.setImageResource(0);
|
||||
binding.medInfoImg.setBackgroundResource(R.drawable.ic_done);
|
||||
}
|
||||
|
||||
if (patientData.isPatientRoutineData == 1) {
|
||||
binding.setupRoutineImg.setImageResource(0);
|
||||
binding.setupRoutineImg.setBackgroundResource(R.drawable.ic_done);
|
||||
}
|
||||
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileProgressFetchFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), "Couldn't load profile progress.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user