.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@@ -24,10 +25,17 @@ import com.daimajia.androidanimations.library.Techniques;
|
||||
import com.daimajia.androidanimations.library.YoYo;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.databinding.RegisterationDoneFragmentBinding;
|
||||
import com.ssb.simplitend.patient_dashboard.DashBoardActivity;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
|
||||
public class RegisterCompleteFragment extends Fragment {
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class RegisterCompleteFragment extends Fragment implements ProfileContracts.ProfileProgressCallback{
|
||||
|
||||
public RegisterationDoneFragmentBinding binding;
|
||||
|
||||
@@ -36,6 +44,8 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
|
||||
int profile_progress, is_connect_to_caregiver;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public RegisterCompleteFragment() {
|
||||
// required
|
||||
}
|
||||
@@ -44,6 +54,7 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RegisterationDoneFragmentBinding.inflate(inflater, container, false);
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
if (getArguments() != null) {
|
||||
profile_progress = getArguments().getInt(PROFILE_PROGRESS, 20);
|
||||
@@ -83,28 +94,75 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
|
||||
binding.proceed.setOnClickListener(v -> {
|
||||
|
||||
if (is_connect_to_caregiver == 1) {
|
||||
gotoPatientDashBoard();
|
||||
} else {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Ask Caregiver to register",
|
||||
"Kindly ask CareGiver to complete registeration.",
|
||||
"OK",
|
||||
((dialogInterface, i) -> {
|
||||
|
||||
}), null, null);
|
||||
}
|
||||
checkConnectionStatus();
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void checkConnectionStatus() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we check the Caregiver connection status.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
PatientProfileAPIService apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
|
||||
String token = "Bearer " + AppUtil.getPatientToken(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 gotoPatientDashBoard() {
|
||||
Intent intent = new Intent(requireActivity(), DashBoardActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileProgressFetched(PatientData patientData) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (patientData.isCareGiverConnectedWithPatient == 1) {
|
||||
gotoPatientDashBoard();
|
||||
} else {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Ask Caregiver to register",
|
||||
"Kindly ask CareGiver to complete registeration.",
|
||||
"OK",
|
||||
((dialogInterface, i) -> {
|
||||
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileProgressFetchFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
//binding.animIv.setAnimation(R.raw.done_anim_2);
|
||||
|
||||
Reference in New Issue
Block a user