diff --git a/app/src/main/java/com/remit/jmecustomer/common/customwidgets/CustomAlertDialog.java b/app/src/main/java/com/remit/jmecustomer/common/customwidgets/CustomAlertDialog.java index 62af17bf..fe474c30 100644 --- a/app/src/main/java/com/remit/jmecustomer/common/customwidgets/CustomAlertDialog.java +++ b/app/src/main/java/com/remit/jmecustomer/common/customwidgets/CustomAlertDialog.java @@ -64,10 +64,11 @@ public class CustomAlertDialog extends DialogFragment { break; case FAILED: - String walletNumber = RemitApplication.getStorage().getString(PrefKeys.USER_WALLET_NUMBER, ""); + //String walletNumber = RemitApplication.getStorage().getString(PrefKeys.USER_WALLET_NUMBER, ""); + String memberShipId = RemitApplication.getStorage().getString(PrefKeys.USER_REFERRAL_CODE, ""); String message = getString(R.string.error_text); - if (walletNumber.length() > 0) - message += " - (" + walletNumber + ")"; + if (memberShipId.length() > 0) + message += " - (" + memberShipId + ")"; dialogTitleTxt.setText(message); logo = AnimatedVectorDrawableCompat.create(getActivity(), R.drawable.avd_fail_transition); break; diff --git a/app/src/main/java/com/remit/jmecustomer/features/home/model/HomeViewRelatedDTOV2.java b/app/src/main/java/com/remit/jmecustomer/features/home/model/HomeViewRelatedDTOV2.java index 9b229377..1b046fc5 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/home/model/HomeViewRelatedDTOV2.java +++ b/app/src/main/java/com/remit/jmecustomer/features/home/model/HomeViewRelatedDTOV2.java @@ -2,17 +2,17 @@ package com.remit.jmecustomer.features.home.model; public class HomeViewRelatedDTOV2 { - private boolean shouldShowTermsAndCondition; - private String bankName; - private String walletNo; - private String yearlyLimit; + private boolean shouldShowTermsAndCondition; + private String bankName; + private String walletNo; + private String yearlyLimit; private HomeNotificationViewDTO homeNotificationViewDTO; private String userName; private String availableBalance; private String rewardPoint; private String referralCode; - + private String notificationCount; public HomeViewRelatedDTOV2(boolean shouldShowKycView, String kycMessage, String kycTitle, boolean disableKYCViewClick, String userName, String availableBalance, String rewardPoint, boolean isPennyTestPending, boolean hasRequestedPennyTest, String pennyTestTitle, String pennyTestMessage, boolean shouldShowAutoDebitNotice, String autoDebitTitle, String autoDebitBody) { @@ -22,18 +22,20 @@ public class HomeViewRelatedDTOV2 { } - public HomeViewRelatedDTOV2(String userName, String availableBalance,String yearlyLimit, String rewardPoint , String bankName,String walletNo, HomeNotificationViewDTO homeNotificationViewDTO,boolean shouldShowTermsAndCondition,String referralCode) { + public HomeViewRelatedDTOV2(String userName, String availableBalance, String yearlyLimit, String rewardPoint, String bankName, String walletNo, HomeNotificationViewDTO homeNotificationViewDTO, boolean shouldShowTermsAndCondition, String referralCode, String notificationCount) { this.userName = userName; this.availableBalance = availableBalance; - this.yearlyLimit=yearlyLimit; + this.yearlyLimit = yearlyLimit; this.rewardPoint = rewardPoint; - this.homeNotificationViewDTO =homeNotificationViewDTO; - this.bankName=bankName; - this.walletNo=walletNo; - this.shouldShowTermsAndCondition=shouldShowTermsAndCondition; - this.referralCode=referralCode; + this.homeNotificationViewDTO = homeNotificationViewDTO; + this.bankName = bankName; + this.walletNo = walletNo; + this.shouldShowTermsAndCondition = shouldShowTermsAndCondition; + this.referralCode = referralCode; + this.notificationCount = notificationCount; } + public String getUserName() { return userName; } @@ -47,7 +49,6 @@ public class HomeViewRelatedDTOV2 { } - public HomeNotificationViewDTO getHomeNotificationViewDTO() { return homeNotificationViewDTO; } @@ -71,4 +72,8 @@ public class HomeViewRelatedDTOV2 { public String getReferralCode() { return referralCode; } + + public String getNotificationCount() { + return notificationCount; + } } diff --git a/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeV2PresenterInterface.java b/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeV2PresenterInterface.java index 1ef3a1b9..616d92bf 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeV2PresenterInterface.java +++ b/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeV2PresenterInterface.java @@ -41,6 +41,7 @@ public interface HomeV2PresenterInterface extends BasePresenterInterface { void setNewToken(String newToken); + void showChangedNotification(String noticeCount); LiveData subscribeToHomeRelatedDataEvent(); @@ -75,6 +76,7 @@ public interface HomeV2PresenterInterface extends BasePresenterInterface { void showFingerprintAvailablityToUser(); + void showChangedNotification(String noticeCount); } } diff --git a/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeViewModel.java b/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeViewModel.java index 5236b4d8..d73e2312 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeViewModel.java +++ b/app/src/main/java/com/remit/jmecustomer/features/home/presenter/HomeViewModel.java @@ -121,6 +121,10 @@ public class HomeViewModel extends BaseViewModel implements HomeV2PresenterInter } } + @Override + public void showChangedNotification(String noticeCount) { + view.showChangedNotification(noticeCount); + } @Override public void postEmailCodeToVerify(String OTP) { @@ -303,7 +307,8 @@ public class HomeViewModel extends BaseViewModel implements HomeV2PresenterInter userInfoModelV2.getWalletNumber(), notificationViewDTO, shouldShowTermsAndCondition, - userInfoModelV2.getReferralCode() + userInfoModelV2.getReferralCode(), + userInfoModelV2.getNotificationCount() )); //If no notification is generated then we can show privileged Operation View diff --git a/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java b/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java index 589b38eb..4b545f7a 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java +++ b/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java @@ -130,8 +130,10 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra ImageView iv_close; @BindView(R.id.content_view) ViewGroup content_view; + @BindView(R.id.notificationCountTxtView) TextView notificationCountTxtView; + private Fragment currentFragment; private FragmentManager manager; // private HomeV2PresenterInterface presenter; @@ -164,11 +166,6 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra RemitApplication.getStorage().edit().putString(PrefKeys.USER_FCM_ID, token); } }); - String noticeCount = RemitApplication.getStorage().getString(PrefKeys.NOTIFICATION_COUNT, ""); - if (!noticeCount.isEmpty()) { - notificationCountTxtView.setText(RemitApplication.getStorage().getString(PrefKeys.NOTIFICATION_COUNT, "")); - notificationCountTxtView.setVisibility(View.VISIBLE); - } } private void performDefaultAction(Bundle savedInstanceState) { @@ -702,5 +699,13 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra showExitConfirmationDialog(); } } + + @Override + public void showChangedNotification(String noticeCount) { + if (!noticeCount.isEmpty()) { + notificationCountTxtView.setText(RemitApplication.getStorage().getString(PrefKeys.NOTIFICATION_COUNT, "")); + notificationCountTxtView.setVisibility(View.VISIBLE); + } + } } diff --git a/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeFragmentV2.java b/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeFragmentV2.java index 533964ad..fd4351f9 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeFragmentV2.java +++ b/app/src/main/java/com/remit/jmecustomer/features/home/view/HomeFragmentV2.java @@ -22,6 +22,8 @@ import androidx.transition.Transition; import androidx.transition.TransitionListenerAdapter; import androidx.transition.TransitionManager; +import com.remit.jmecustomer.RemitApplication; +import com.remit.jmecustomer.base.PrefKeys; import com.remit.jmecustomer.features.home.adapters.HomeMenuRvAdapterV2; import com.remit.jmecustomer.features.home.model.HomeNotificationViewDTO; import com.remit.jmecustomer.features.home.model.HomeViewRelatedDTOV2; @@ -234,6 +236,7 @@ public class HomeFragmentV2 extends BaseFragment implements tv_namelabel.setText(homeViewRelatedDTOV2.getUserName()); tv_yearly_remaining.setText(homeViewRelatedDTOV2.getAvailableBalance()); tv_wallet_no.setText(homeViewRelatedDTOV2.getReferralCode()); + homeViewModel.showChangedNotification(homeViewRelatedDTOV2.getNotificationCount()); } @@ -269,7 +272,7 @@ public class HomeFragmentV2 extends BaseFragment implements } private void showPennyTestView() { - KYCV3Activity.startActivity(getActivity(), true, "", "",false); + KYCV3Activity.startActivity(getActivity(), true, "", "", false); } diff --git a/app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java b/app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java index aca52302..6476df8d 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java +++ b/app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java @@ -147,7 +147,7 @@ public class MyNotificationViewModel extends BaseViewModel implements MyNotifica @Override protected void onSuccess(GenericResponseDataModel> t) { if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { - //sortNoticeList(gateway.mockNoticeList()); + // sortNoticeList(gateway.mockNoticeList()); if (t.getData() != null && t.getData().size() > 0) { view.lazyInitViews(); sortNoticeList(t.getData()); @@ -246,15 +246,18 @@ public class MyNotificationViewModel extends BaseViewModel implements MyNotifica } } - public class UpdateNoticeObserver extends GenericApiObserverResponseV2> { - @Override - protected Type getDataType() { - return TypeToken.getParameterized(UpdateNoticeObserver.class).getType(); - } + public class UpdateNoticeObserver extends GenericApiObserverResponseV2 { @Override - protected void onSuccess(GenericResponseDataModel> t) { + protected void onSuccess(GenericResponseDataModel t) { if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { + List list = noticeListLiveData.getValue(); + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getRowId().equals(selectedNotice.getRowId())) { + list.get(i).setIsRead("1"); + } + } + noticeListLiveData.setValue(list); //noticeListLiveData.setValue(t.); } else { view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null); diff --git a/app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java b/app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java index 6b14d0a5..78ac276e 100644 --- a/app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java +++ b/app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java @@ -73,11 +73,11 @@ public class MyNotificationListingFragment extends BaseFragment implements MyNot } private void handleNoticeClicked(MyNotificationDTO itemModel) { - if (itemModel.getIsClickable() != null && itemModel.getIsClickable().equals("Y")) { - new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).updateNotification(itemModel.getRowId()); + if (itemModel.getIsClickable() != null && itemModel.getIsClickable().equals("Y") && !itemModel.getUrl().isEmpty()) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(itemModel.getUrl())); startActivity(browserIntent); } + new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).updateNotification(itemModel.getRowId()); // if (itemModel.getType().equals("0")) { // new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).fetchNoticeDetail(itemModel); // } else if (itemModel.getType().equals("1")) {