.
This commit is contained in:
@@ -67,7 +67,7 @@ public class ArticlesAdapter extends ListAdapter<ArticleResult, ArticlesAdapter.
|
||||
public void setData(ArticleResult articleResult){
|
||||
if (articleResult == null) return;
|
||||
|
||||
Glide.with(itemView.getContext())
|
||||
Glide.with(binding.articleImg)
|
||||
.load(AppUtil.IMAGE_BASE_URL + articleResult.large_image)
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
.error(android.R.color.darker_gray)
|
||||
|
||||
@@ -178,6 +178,24 @@ public class CaregiverDashActivity extends AppCompatActivity implements
|
||||
.error(R.drawable.caregiver_img)
|
||||
.into(menuBinding.cgImage);
|
||||
}
|
||||
|
||||
// changing title if current fragment is
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentByTag("dashboard");
|
||||
if (fragment != null) {
|
||||
if (fragment instanceof CgDashBoardFragment) {
|
||||
|
||||
String first_name = "";
|
||||
if (careGiverData != null && careGiverData.first_name != null){
|
||||
String[] name = careGiverData.first_name.split(" ");
|
||||
if (name.length > 0){
|
||||
first_name = name[0];
|
||||
}
|
||||
}
|
||||
|
||||
binding.toolbar.setTitle("Welcome " + first_name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void replaceFragment(Fragment fragment, String tag){
|
||||
@@ -216,8 +234,8 @@ public class CaregiverDashActivity extends AppCompatActivity implements
|
||||
binding.toolbar.setNavigationIconTint(getResources().getColor(R.color.black));
|
||||
|
||||
String first_name = "";
|
||||
if (careGiverData != null && careGiverData.patientDetails != null && careGiverData.patientDetails.first_name != null){
|
||||
String[] name = careGiverData.patientDetails.first_name.split(" ");
|
||||
if (careGiverData != null && careGiverData.first_name != null){
|
||||
String[] name = careGiverData.first_name.split(" ");
|
||||
if (name.length > 0){
|
||||
first_name = name[0];
|
||||
}
|
||||
|
||||
@@ -1,25 +1,35 @@
|
||||
package com.ssb.simplitend.caregiverdashboard.activities;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.caregiverdashboard.activities.deactivateacc.DeActivateAccountActivity;
|
||||
import com.ssb.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
import com.ssb.simplitend.caregiverdashboard.mvvm.CgHomeContracts;
|
||||
import com.ssb.simplitend.databinding.ActivityCgSettingsBinding;
|
||||
import com.ssb.simplitend.welcome.activities.WelcomeActivity;
|
||||
|
||||
public class CaregiverSettingsActivity extends AppCompatActivity {
|
||||
public class CaregiverSettingsActivity extends AppCompatActivity implements CgHomeContracts.SignOutCallback {
|
||||
|
||||
private ActivityCgSettingsBinding binding;
|
||||
|
||||
private CaregiverMainViewModel viewModel;
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityCgSettingsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
viewModel = new ViewModelProvider(this).get(CaregiverMainViewModel.class);
|
||||
progressDialog = new ProgressDialog(this);
|
||||
|
||||
initViews();
|
||||
|
||||
@@ -40,12 +50,13 @@ public class CaregiverSettingsActivity extends AppCompatActivity {
|
||||
((dialogInterface, i) -> {}),
|
||||
getString(R.string.yes),
|
||||
((dialogInterface, i) -> {
|
||||
AppUtil.cgSignOut(this);
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we sign you out");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Intent intent = new Intent(this, WelcomeActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
viewModel.signOut("Bearer " + AppUtil.getCgToken(this),
|
||||
this);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -54,4 +65,23 @@ public class CaregiverSettingsActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignOutSuccess() {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.cgSignOut(this);
|
||||
|
||||
Intent intent = new Intent(this, WelcomeActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignOutFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class EditProfileInfoActivity extends AppCompatActivity implements
|
||||
}
|
||||
|
||||
// load patient data
|
||||
if (careGiverData.profile_photo != null){
|
||||
if (patientData.profile_photo != null){
|
||||
Glide.with(this)
|
||||
.load(AppUtil.IMAGE_BASE_URL + patientData.profile_photo)
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
|
||||
@@ -87,7 +87,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.d("aditya", "onResume: ");
|
||||
CaregiverDataCache.getCaregiverData(requireActivity(), (careGiverData1 -> {
|
||||
this.careGiverData = careGiverData1;
|
||||
|
||||
@@ -124,12 +123,12 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
Glide.with(requireActivity())
|
||||
Glide.with(binding.activityGif)
|
||||
.asGif()
|
||||
.load(R.raw.anim_pulse)
|
||||
.into(binding.activityGif);
|
||||
|
||||
Glide.with(requireActivity())
|
||||
Glide.with(binding.upComingGif)
|
||||
.asGif()
|
||||
.load(R.raw.anim_pulse)
|
||||
.into(binding.upComingGif);
|
||||
@@ -145,7 +144,7 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
public void setArticleDetails(ArticleResult articleResult){
|
||||
if (articleResult == null) return;
|
||||
|
||||
Glide.with(requireActivity())
|
||||
Glide.with(binding.articleImg)
|
||||
.load(AppUtil.IMAGE_BASE_URL + articleResult.large_image)
|
||||
.centerCrop()
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
@@ -242,6 +241,7 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
private void loadPatientData() {
|
||||
LatLng latLng;
|
||||
String patient_name;
|
||||
|
||||
// loading patient's location
|
||||
try {
|
||||
@@ -251,9 +251,11 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
double lng = Double.parseDouble(patientData.lng);
|
||||
|
||||
latLng = new LatLng(lat, lng);
|
||||
patient_name = patientData.first_name + "";
|
||||
}catch (Exception e){
|
||||
// near marine drive
|
||||
latLng = new LatLng(18.93294274664527, 72.82806102186441);
|
||||
patient_name = "Default location";
|
||||
}
|
||||
|
||||
if (mGoogleMap == null) return;
|
||||
@@ -262,7 +264,7 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(latLng)
|
||||
.title(patientData.first_name + "");
|
||||
.title(patient_name);
|
||||
|
||||
mGoogleMap.addMarker(markerOptions);
|
||||
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));;
|
||||
|
||||
@@ -81,4 +81,8 @@ public class CaregiverMainViewModel extends ViewModel {
|
||||
cgHomeRepository.updateCgPassword(cg_xid, body, token, passwordCallback);
|
||||
}
|
||||
|
||||
public void signOut(String token, @NonNull CgHomeContracts.SignOutCallback signOutCallback){
|
||||
cgHomeRepository.signOut(token, signOutCallback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,4 +53,8 @@ public interface CgDashboardApiService {
|
||||
Call<CallResponse<CareGiverData>> updateCgPassword(@Path("id") int cg_xid,
|
||||
@PartMap Map<String, RequestBody> body,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@POST("api/logout")
|
||||
Call<CallResponse<Object>> signOut(@Header("Authorization") String token);
|
||||
|
||||
}
|
||||
|
||||
@@ -48,5 +48,9 @@ public interface CgHomeContracts {
|
||||
void onPasswordUpdateFailed(Throwable throwable, String message);
|
||||
}
|
||||
|
||||
interface SignOutCallback{
|
||||
void onSignOutSuccess();
|
||||
void onSignOutFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -218,4 +218,29 @@ public class CgHomeRepository {
|
||||
|
||||
}
|
||||
|
||||
public void signOut(String token,
|
||||
@NonNull CgHomeContracts.SignOutCallback signOutCallback){
|
||||
dash_apiService.signOut(token)
|
||||
.enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
signOutCallback.onSignOutFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
signOutCallback.onSignOutSuccess();
|
||||
}else{
|
||||
signOutCallback.onSignOutFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<Object>> call, Throwable t) {
|
||||
signOutCallback.onSignOutFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,7 +147,9 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
geofence_bs_binding.unitSpinner.setLifecycleOwner(this);
|
||||
geofence_bs_binding.unitSpinner.setIsFocusable(true);
|
||||
|
||||
geofence_bs_binding.radius.setText("" + radius);
|
||||
if (radius != 0){
|
||||
geofence_bs_binding.radius.setText("" + radius);
|
||||
}
|
||||
geofence_bs_binding.message.setText(geoFenceDetails.message);
|
||||
geofence_bs_binding.location.setText(geoFenceDetails.location_name);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class SignInFragment extends Fragment implements WelcomeContracts.Registe
|
||||
|
||||
Toast.makeText(requireContext(), "Log in successful.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
if (patientResult.isCareGiverConnectedWithPatient == 1){
|
||||
if (patientResult.isCareGiverConnectedWithPatient == 1 && patientResult.isCaregiverTakeSubscription == 1){
|
||||
// connected to caregiver
|
||||
// thus, sending it to dashboard
|
||||
Intent intent = new Intent(requireActivity(), DashBoardActivity.class);
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.ssb.simplitend.welcome.welcomepatient.fragments.register;
|
||||
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgConnectFragment.CAREGIVER_EMAIL;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -87,7 +90,7 @@ public class SplashFragment extends Fragment
|
||||
|
||||
onProfileProgressFetched(response.body().result);
|
||||
} else {
|
||||
onProfileProgressFetchFailed(new Exception(), "Please try again later.");
|
||||
sessionExpired();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +116,7 @@ public class SplashFragment extends Fragment
|
||||
|
||||
onCgDataFetched(response.body().result);
|
||||
} else {
|
||||
onCgDataFetchFailed(new Exception(), "Please try again later.");
|
||||
sessionExpired();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +132,23 @@ public class SplashFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
private void sessionExpired(){
|
||||
binding.retry.setVisibility(View.VISIBLE);
|
||||
binding.loadAnim.setVisibility(View.GONE);
|
||||
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Session Expired")
|
||||
.setMessage("Your login session has expired.\nPlease login again.")
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("OKAY", (dialogInterface, i) -> {
|
||||
AppUtil.patientSignOut(requireContext());
|
||||
AppUtil.cgSignOut(requireContext());
|
||||
|
||||
gotoWelcomeFragment();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void gotoPatientProfileProgress(){
|
||||
NavOptions navOptions = new NavOptions.Builder()
|
||||
.setPopUpTo(R.id.splashFragment, true)
|
||||
|
||||
Reference in New Issue
Block a user