Browse Source

add my notification screen

new_design
Mukesh Dhungana 2 years ago
parent
commit
883b0162d6
  1. 5
      app/src/main/AndroidManifest.xml
  2. 5
      app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java
  3. 27
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/MyNotificationViewModelFactory.java
  4. 71
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/adapter/MyNotificationListingRVAdapter.java
  5. 33
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/adapter/MyNotificationListingRVViewholder.java
  6. 100
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/gateway/MyNotificationGateway.java
  7. 90
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/model/MyNotificationDTO.java
  8. 53
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/model/MyNotificationDetailDTO.java
  9. 28
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationGatewayInterface.java
  10. 41
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationPresenterInterface.java
  11. 233
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java
  12. 127
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationActivity.java
  13. 107
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationFragment.java
  14. 97
      app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java
  15. 121
      app/src/main/res/layout/activity_home_v2.xml
  16. 13
      app/src/main/res/layout/activity_my_notifications.xml
  17. 4
      app/src/main/res/values/strings.xml

5
app/src/main/AndroidManifest.xml

@ -283,6 +283,11 @@
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name="com.remit.jmecustomer.features.mynotifications.view.MyNotificationActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden" />
<service
android:name="com.remit.jmecustomer.services.JMEFcmMessagingService"

5
app/src/main/java/com/remit/jmecustomer/features/home/view/HomeActivityV2.java

@ -36,6 +36,7 @@ import com.remit.jmecustomer.features.home.gateway.HomeV2Gateway;
import com.remit.jmecustomer.features.home.presenter.HomeV2PresenterInterface;
import com.remit.jmecustomer.features.home.presenter.HomeViewModel;
import com.remit.jmecustomer.features.home.view.notifications.DimBackgroundView;
import com.remit.jmecustomer.features.mynotifications.view.MyNotificationActivity;
import com.remit.jmecustomer.features.notice.view.NoticeActivity;
import com.remit.jmecustomer.features.recipientlisting.view.recipientlisting.RecipientListingActivity;
import com.remit.jmecustomer.features.recipientmanagement.view.recipientlistingV3.RecipientListingV3Activity;
@ -77,6 +78,8 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra
NavigationView nav_drawer;
@BindView(R.id.iv_help)
ImageView iv_help;
@BindView(R.id.iv_notification)
ImageView iv_notification;
@BindView(R.id.iv_nav)
ImageView iv_nav;
@BindView(R.id.drawer_home)
@ -242,6 +245,8 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra
break;
case R.id.view_account_statement:
startActivity(new Intent(this, WalletStatementV2Activity.class));
case R.id.iv_notification:
startActivity(new Intent(this, MyNotificationActivity.class));
break;
}
}

27
app/src/main/java/com/remit/jmecustomer/features/mynotifications/MyNotificationViewModelFactory.java

@ -0,0 +1,27 @@
package com.remit.jmecustomer.features.mynotifications;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import com.remit.jmecustomer.features.mynotifications.gateway.MyNotificationGateway;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationPresenterInterface;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationViewModel;
public class MyNotificationViewModelFactory implements ViewModelProvider.Factory {
private final MyNotificationPresenterInterface.NoticeViewContractInterface view;
public MyNotificationViewModelFactory(MyNotificationPresenterInterface.NoticeViewContractInterface view) {
this.view = view;
}
@SuppressWarnings("unchecked")
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new MyNotificationViewModel(view,new MyNotificationGateway());
}
}

71
app/src/main/java/com/remit/jmecustomer/features/mynotifications/adapter/MyNotificationListingRVAdapter.java

@ -0,0 +1,71 @@
package com.remit.jmecustomer.features.mynotifications.adapter;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.remit.jmecustomer.R;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import java.util.ArrayList;
import java.util.List;
public class MyNotificationListingRVAdapter extends RecyclerView.Adapter<MyNotificationListingRVViewholder> {
private final NoticeClickListener listener;
private List<MyNotificationDTO> noticeList;
public MyNotificationListingRVAdapter(NoticeClickListener listener) {
this.listener = listener;
noticeList = new ArrayList<>();
}
@NonNull
@Override
public MyNotificationListingRVViewholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new MyNotificationListingRVViewholder(LayoutInflater.from(parent.getContext()).inflate(R.layout.notice_list_viewholder_v3, parent, false));
}
@Override
public void onBindViewHolder(@NonNull MyNotificationListingRVViewholder holder, int position) {
MyNotificationDTO myNotificationDTO = noticeList.get(holder.getAdapterPosition());
holder.notice_title.setText(myNotificationDTO.getTitle());
holder.notice_date.setText(myNotificationDTO.getCreateDate());
if ("1".equalsIgnoreCase(myNotificationDTO.getIsRead()))
holder.imgNotificationStat.setBackgroundResource(R.drawable.ic_read);
else
holder.imgNotificationStat.setBackgroundResource(R.drawable.ic_unread);
holder.itemView.setOnClickListener(view -> {
if (listener != null)
listener.onNoticeClicked(noticeList.get(holder.getAdapterPosition()));
});
}
@Override
public int getItemCount() {
return noticeList.size();
}
public void setData(List<MyNotificationDTO> data) {
if (data != null && data.size() > 0) {
this.noticeList.clear();
this.noticeList.addAll(data);
notifyDataSetChanged();
}
}
public void resetData() {
this.noticeList = null;
notifyDataSetChanged();
}
public interface NoticeClickListener {
void onNoticeClicked(MyNotificationDTO itemModel);
}
}

33
app/src/main/java/com/remit/jmecustomer/features/mynotifications/adapter/MyNotificationListingRVViewholder.java

@ -0,0 +1,33 @@
package com.remit.jmecustomer.features.mynotifications.adapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.remit.jmecustomer.R;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MyNotificationListingRVViewholder extends RecyclerView.ViewHolder {
@BindView(R.id.tv_notification_title)
TextView notice_title;
@BindView(R.id.tv_status)
TextView notice_status;
@BindView(R.id.tv_notification_date)
TextView notice_date;
@BindView(R.id.imgNotificationStat)
ImageView imgNotificationStat;
public MyNotificationListingRVViewholder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this,itemView);
}
}

100
app/src/main/java/com/remit/jmecustomer/features/mynotifications/gateway/MyNotificationGateway.java

@ -0,0 +1,100 @@
package com.remit.jmecustomer.features.mynotifications.gateway;
import com.google.gson.JsonObject;
import com.remit.jmecustomer.base.PrivilegedGateway;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDetailDTO;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationGatewayInterface;
import com.remit.jmecustomer.utils.https.HttpClientV2;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public class MyNotificationGateway extends PrivilegedGateway implements MyNotificationGatewayInterface {
@Override
public Observable<ResponseBody> getNoticeList(String auth, String customerID) {
JsonObject jsonObject=new JsonObject() ;
jsonObject.addProperty("customerId",customerID);
return HttpClientV2.getInstance().getNoticeList(auth,jsonObject);
}
@Override
public Observable<ResponseBody> getNoticeDetail(String auth, String noticeId) {
JsonObject jsonObject=new JsonObject() ;
jsonObject.addProperty("rowId",noticeId);
return HttpClientV2.getInstance().getNoticeDetail(auth,jsonObject);
}
@Override
public Observable<ResponseBody> setNoticeStatus(String auth, String tranId, String yesNo) {
return HttpClientV2.getInstance().setNoticeReadStatus(auth,tranId,yesNo);
}
@Override
public List<MyNotificationDTO> mockNoticeList() {
List<MyNotificationDTO> noticeList=new ArrayList<>();
MyNotificationDTO myNotificationDTO0 =new MyNotificationDTO();
myNotificationDTO0.setRowId("0");
myNotificationDTO0.setTitle("Title 1");
myNotificationDTO0.setCreateDate("2077/01/01");
myNotificationDTO0.setIsRead("0");
myNotificationDTO0.setType("1");
myNotificationDTO0.setExtra("12");
noticeList.add(myNotificationDTO0);
MyNotificationDTO myNotificationDTO1 =new MyNotificationDTO();
myNotificationDTO1.setRowId("1");
myNotificationDTO1.setTitle("Title 2");
myNotificationDTO1.setCreateDate("2077/01/02");
myNotificationDTO1.setIsRead("1");
myNotificationDTO1.setType("0");
noticeList.add(myNotificationDTO1);
MyNotificationDTO myNotificationDTO2 =new MyNotificationDTO();
myNotificationDTO2.setRowId("2");
myNotificationDTO2.setTitle("Title 3");
myNotificationDTO2.setCreateDate("2077/01/02");
myNotificationDTO2.setIsRead("0");
myNotificationDTO2.setType("1");
myNotificationDTO2.setExtra("13");
noticeList.add(myNotificationDTO2);
MyNotificationDTO myNotificationDTO3 =new MyNotificationDTO();
myNotificationDTO3.setRowId("3");
myNotificationDTO3.setTitle("Title 4");
myNotificationDTO3.setCreateDate("2077/01/03");
myNotificationDTO3.setIsRead("1");
myNotificationDTO3.setType("1");
myNotificationDTO3.setExtra("14");
noticeList.add(myNotificationDTO3);
MyNotificationDTO myNotificationDTO4 =new MyNotificationDTO();
myNotificationDTO4.setRowId("4");
myNotificationDTO4.setTitle("Title 5");
myNotificationDTO4.setCreateDate("2077/01/04");
myNotificationDTO4.setIsRead("1");
myNotificationDTO4.setType("0");
noticeList.add(myNotificationDTO4);
return noticeList;
}
@Override
public MyNotificationDetailDTO mockNoticeDetail() {
MyNotificationDetailDTO myNotificationDetailDTO =new MyNotificationDetailDTO();
myNotificationDetailDTO.setTitle("Title 1");
myNotificationDetailDTO.setBody("This is Detail body of Title 1");
myNotificationDetailDTO.setCreateDate("2077/01/01");
myNotificationDetailDTO.setImageURL("https://p18cdn4static.sharpschool.com/UserFiles/Servers/Server_414551/Image/News/District%20News/Title%201.jpg");
return myNotificationDetailDTO;
}
}

90
app/src/main/java/com/remit/jmecustomer/features/mynotifications/model/MyNotificationDTO.java

@ -0,0 +1,90 @@
package com.remit.jmecustomer.features.mynotifications.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class MyNotificationDTO {
@SerializedName("rowId")
@Expose
private String rowId;
@SerializedName("title")
@Expose
private String title;
@SerializedName("createDate")
@Expose
private String createDate;
@SerializedName("isRead")// 0 => Not Read, 1=> Read,
@Expose
private String isRead;
@SerializedName("type")//0 => General Notice, 1=> Txn Notice
@Expose
private String type;
@SerializedName("extra")//If type==1, then extra will have Txn id
@Expose
private String extra;
@SerializedName("DisplayActions")
@Expose
private String displayActions;
public String getRowId() {
return rowId;
}
public void setRowId(String rowId) {
this.rowId = rowId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getIsRead() {
return isRead;
}
public void setIsRead(String isRead) {
this.isRead = isRead;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getExtra() {
return extra;
}
public void setExtra(String extra) {
this.extra = extra;
}
public String getDisplayActions() {
return displayActions;
}
public void setDisplayActions(String displayActions) {
this.displayActions = displayActions;
}
}

53
app/src/main/java/com/remit/jmecustomer/features/mynotifications/model/MyNotificationDetailDTO.java

@ -0,0 +1,53 @@
package com.remit.jmecustomer.features.mynotifications.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class MyNotificationDetailDTO {
@SerializedName("title")
@Expose
private String title;
@SerializedName("body")
@Expose
private String body;
@SerializedName("createDate")
@Expose
private String createDate;
@SerializedName("imageURL")
@Expose
private String imageURL;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getImageURL() {
return imageURL;
}
public void setImageURL(String imageURL) {
this.imageURL = imageURL;
}
}

28
app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationGatewayInterface.java

@ -0,0 +1,28 @@
package com.remit.jmecustomer.features.mynotifications.presenter;
import com.remit.jmecustomer.base.PrivilegedGatewayInterface;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDetailDTO;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public interface MyNotificationGatewayInterface extends PrivilegedGatewayInterface {
Observable<ResponseBody> getNoticeList(String auth, String customerID);
Observable<ResponseBody> getNoticeDetail(String auth, String noticeId);
Observable<ResponseBody> setNoticeStatus(String auth,String tranId,String noticeStat);
List<MyNotificationDTO> mockNoticeList();
MyNotificationDetailDTO mockNoticeDetail();
}

41
app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationPresenterInterface.java

@ -0,0 +1,41 @@
package com.remit.jmecustomer.features.mynotifications.presenter;
import androidx.lifecycle.LiveData;
import com.remit.jmecustomer.base.BaseContractInterface;
import com.remit.jmecustomer.base.BasePresenterInterface;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDetailDTO;
import java.util.List;
public interface MyNotificationPresenterInterface extends BasePresenterInterface {
void fetchNoticeListLiveData();
void fetchNoticeDetail(MyNotificationDTO selectedNotice);
LiveData<List<MyNotificationDTO>> getNoticeListLiveData();
LiveData<MyNotificationDetailDTO> getNoticeDetailLiveData();
void changeNoticeStat();
MyNotificationDTO getSelectedNotice();
void setSelectedNotice(MyNotificationDTO noticeState);
interface NoticeViewContractInterface extends BaseContractInterface {
void lazyInitViews();
void showDetailScreen();
NoticeListContractInterface getNoticeListContract();
interface NoticeListContractInterface extends BaseContractInterface {
void showTranSendComplete();
}
}
}

233
app/src/main/java/com/remit/jmecustomer/features/mynotifications/presenter/MyNotificationViewModel.java

@ -0,0 +1,233 @@
package com.remit.jmecustomer.features.mynotifications.presenter;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.google.gson.reflect.TypeToken;
import com.remit.jmecustomer.R;
import com.remit.jmecustomer.base.BaseViewModel;
import com.remit.jmecustomer.common.customwidgets.CustomAlertDialog;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDetailDTO;
import com.remit.jmecustomer.features.sendmoney.model.SendMoneyTransactionCompleteV2ResponseBody;
import com.remit.jmecustomer.utils.Constants;
import com.remit.jmecustomer.utils.https.GenericApiObserverResponseV2;
import com.remit.jmecustomer.utils.https.GenericResponseDataModel;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
public class MyNotificationViewModel extends BaseViewModel implements MyNotificationPresenterInterface {
private final NoticeViewContractInterface view;
private final MyNotificationGatewayInterface gateway;
private final CompositeDisposable compositeDisposable;
MutableLiveData<List<MyNotificationDTO>> noticeListLiveData;
MutableLiveData<MyNotificationDetailDTO> noticeDetailLiveData;
private MyNotificationDTO selectedNotice;
public MyNotificationViewModel(NoticeViewContractInterface view, MyNotificationGatewayInterface gatewayInterface) {
this.view = view;
this.gateway = gatewayInterface;
noticeListLiveData = new MutableLiveData<>();
noticeDetailLiveData = new MutableLiveData<>();
this.compositeDisposable = new CompositeDisposable();
}
@Override
public void onViewReady() {
}
@Override
public void onViewNotReady() {
}
@Override
public void fetchNoticeListLiveData() {
this.compositeDisposable.add(
this.gateway.getNoticeList(gateway.getAuth(), gateway.getUserIDNumber())
.doOnSubscribe(subs -> view.showProgressBar(true, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new NoticeListObserver())
);
}
@Override
public void fetchNoticeDetail(MyNotificationDTO selectedNotice) {
this.compositeDisposable.add(
this.gateway.getNoticeDetail(gateway.getAuth(), selectedNotice.getRowId())
.doOnSubscribe(subs -> view.showProgressBar(true, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new NoticeDetailObserver())
);
}
@Override
public LiveData<List<MyNotificationDTO>> getNoticeListLiveData() {
return noticeListLiveData;
}
@Override
public LiveData<MyNotificationDetailDTO> getNoticeDetailLiveData() {
return noticeDetailLiveData;
}
@Override
public void changeNoticeStat() {
this.compositeDisposable.add(
this.gateway.setNoticeStatus(gateway.getAuth(), selectedNotice.getExtra(), "Y")
.doOnSubscribe(subs -> view.showProgressBar(true, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new NoticeStatUpdateObserver())
);
}
@Override
public MyNotificationDTO getSelectedNotice() {
return selectedNotice;
}
@Override
public void setSelectedNotice(MyNotificationDTO noticeState) {
this.selectedNotice = noticeState;
}
private void sortNoticeList(List<MyNotificationDTO> data) {
// DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
// Collections.sort(data, (o1, o2) -> {
// try {
// return df.parse(o1.getCreateDate()).compareTo(df.parse(o2.getCreateDate()));
// } catch (Exception pe) {
// Collections.reverse(data);
// }
// return 0;
// });
if (data != null)
Collections.reverse(data);
noticeListLiveData.setValue(data);
}
public class NoticeListObserver extends GenericApiObserverResponseV2<List<MyNotificationDTO>> {
@Override
protected Type getDataType() {
return TypeToken.getParameterized(List.class, MyNotificationDTO.class).getType();
}
@Override
protected void onSuccess(GenericResponseDataModel<List<MyNotificationDTO>> t) {
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
if (t.getData() != null && t.getData().size() > 0) {
view.lazyInitViews();
sortNoticeList(t.getData());
} else
view.showPopUpMessage(view.getContext().getResources().getString(R.string.donot_have_notification_text), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
} else {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
}
@Override
public void onFailed(String message) {
// view.lazyInitViews();
// sortNoticeList(gateway.mockNoticeList());
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
@Override
protected void unauthorizedAccess(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.logout());
}
}
public class NoticeDetailObserver extends GenericApiObserverResponseV2<MyNotificationDetailDTO> {
@Override
protected Type getDataType() {
return TypeToken.getParameterized(MyNotificationDetailDTO.class).getType();
}
@Override
protected void onSuccess(GenericResponseDataModel<MyNotificationDetailDTO> t) {
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
noticeDetailLiveData.setValue(t.getData());
view.showDetailScreen();
} else {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
}
}
@Override
public void onFailed(String message) {
// noticeDetailLiveData.setValue(gateway.mockNoticeDetail());
// view.showDetailScreen();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void unauthorizedAccess(String message) {
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.logout());
}
}
public class NoticeStatUpdateObserver extends GenericApiObserverResponseV2<SendMoneyTransactionCompleteV2ResponseBody> {
@Override
protected Type getDataType() {
return TypeToken.getParameterized(MyNotificationDetailDTO.class).getType();
}
@Override
protected void onSuccess(GenericResponseDataModel<SendMoneyTransactionCompleteV2ResponseBody> t) {
if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
view.getNoticeListContract().showTranSendComplete();
} else {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
}
}
@Override
public void onFailed(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void unauthorizedAccess(String message) {
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.logout());
}
}
}

127
app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationActivity.java

@ -0,0 +1,127 @@
package com.remit.jmecustomer.features.mynotifications.view;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager;
import com.remit.jmecustomer.R;
import com.remit.jmecustomer.base.BaseActivity;
import com.remit.jmecustomer.common.customwidgets.GenericViewPagerAdapter;
import com.remit.jmecustomer.features.home.view.HomeActivityV2;
import com.remit.jmecustomer.features.mynotifications.MyNotificationViewModelFactory;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationPresenterInterface;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationViewModel;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MyNotificationActivity extends BaseActivity implements MyNotificationPresenterInterface.NoticeViewContractInterface, ViewPager.OnPageChangeListener {
@BindView(R.id.noticeViewPager)
ViewPager noticeViewPager;
@BindView(R.id.toolbar_title)
TextView toolbar_title;
private GenericViewPagerAdapter noticeViewPagerAdapter;
private MyNotificationListingFragment noticeListingFragment;
private MyNotificationFragment noticeDetailFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notice);
ButterKnife.bind(this);
initialize();
}
private void initialize() {
toolbar_title.setText(getString(R.string.my_notification_text));
MyNotificationViewModelFactory noticeViewModelFactory = new MyNotificationViewModelFactory(this);
MyNotificationViewModel viewModel = new ViewModelProvider(this, noticeViewModelFactory).get(MyNotificationViewModel.class);
viewModel.fetchNoticeListLiveData();
// setupViewPager();
}
private void setupViewPager() {
List<Fragment> fragments = new ArrayList<>();
noticeListingFragment = new MyNotificationListingFragment();
noticeDetailFragment = new MyNotificationFragment();
fragments.add(noticeListingFragment);
fragments.add(noticeDetailFragment);
noticeViewPagerAdapter = new GenericViewPagerAdapter(getSupportFragmentManager(),fragments);
noticeViewPager.setOffscreenPageLimit(2);
noticeViewPager.addOnPageChangeListener(this);
noticeViewPager.setAdapter(noticeViewPagerAdapter);
}
@OnClick(R.id.iv_back)
public void backButtonPressed() {
this.onBackPressed();
}
@Override
public void lazyInitViews() {
setupViewPager();
}
@Override
public void showDetailScreen() {
noticeViewPager.setCurrentItem(1);
}
@Override
public NoticeListContractInterface getNoticeListContract() {
return noticeListingFragment;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
@Override
public void onBackPressed() {
if (noticeViewPager.getCurrentItem() == 0) {
Intent redirectIntent = new Intent(this, HomeActivityV2.class);
redirectIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
redirectIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(redirectIntent);
finish();
} else
noticeViewPager.setCurrentItem(noticeViewPager.getCurrentItem() - 1);
}
}

107
app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationFragment.java

@ -0,0 +1,107 @@
package com.remit.jmecustomer.features.mynotifications.view;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.remit.jmecustomer.R;
import com.remit.jmecustomer.base.BaseFragment;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDetailDTO;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationViewModel;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MyNotificationFragment extends BaseFragment {
@BindView(R.id.tv_notification_date)
TextView noticeDate;
@BindView(R.id.tv_notification_title)
TextView noticeTitle;
@BindView(R.id.tv_notification_body)
TextView noticeBody;
@BindView(R.id.notice_image)
ImageView noticeImage;
@BindView(R.id.progressBar)
ProgressBar imageProgessBar;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_notice_detail, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
init();
performDefaultAction(savedInstanceState);
}
private void init() {
}
private void performDefaultAction(Bundle savedInstance) {
MyNotificationViewModel myNotificationViewModel = new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class);
myNotificationViewModel.getNoticeDetailLiveData().observe(getViewLifecycleOwner(),this::updateNoticeDEtail);
}
private void updateNoticeDEtail(MyNotificationDetailDTO noticeDetail)
{
String date=getActivity().getResources().getString(R.string.date_text)+": "+noticeDetail.getCreateDate();
noticeDate.setText(date);
noticeTitle.setText(noticeDetail.getTitle());
noticeBody.setText(noticeDetail.getBody());
if(noticeDetail.getImageURL()==null||noticeDetail.getImageURL().length()==0)
{
imageProgessBar.setVisibility(View.GONE);
noticeImage.setVisibility(View.GONE);
}
else
{
imageProgessBar.setVisibility(View.VISIBLE);
Glide.with(this)
.asBitmap()
.load(noticeDetail.getImageURL())
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
// imageProgessBar.setVisibility(View.GONE);
// noticeImage.setImageBitmap(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
}
}
}

97
app/src/main/java/com/remit/jmecustomer/features/mynotifications/view/MyNotificationListingFragment.java

@ -0,0 +1,97 @@
package com.remit.jmecustomer.features.mynotifications.view;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.remit.jmecustomer.R;
import com.remit.jmecustomer.base.BaseFragment;
import com.remit.jmecustomer.features.mynotifications.adapter.MyNotificationListingRVAdapter;
import com.remit.jmecustomer.features.mynotifications.model.MyNotificationDTO;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationPresenterInterface;
import com.remit.jmecustomer.features.mynotifications.presenter.MyNotificationViewModel;
import com.remit.jmecustomer.features.sendmoney.view.SendMoneyV2TransactionCompleteActivity;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MyNotificationListingFragment extends BaseFragment implements MyNotificationListingRVAdapter.NoticeClickListener, MyNotificationPresenterInterface.NoticeViewContractInterface.NoticeListContractInterface {
@BindView(R.id.noticeRv)
RecyclerView noticeRv;
MyNotificationListingRVAdapter myNotificationListingRVAdapter;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_notice_listing, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
init();
performDefaultAction(savedInstanceState);
}
private void init() {
myNotificationListingRVAdapter = new MyNotificationListingRVAdapter(this);
noticeRv.setAdapter(myNotificationListingRVAdapter);
// noticeRv.addItemDecoration(new LineDividerItemDecoration(noticeRv.getContext(), LineDividerItemDecoration.VERTICAL_LIST));
}
private void performDefaultAction(Bundle savedInstance) {
MyNotificationViewModel myNotificationViewModel = new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class);
;
myNotificationViewModel.getNoticeListLiveData().observe(getViewLifecycleOwner(), this::updateNoticeList);
}
private void updateNoticeList(List<MyNotificationDTO> noticeList) {
myNotificationListingRVAdapter.setData(noticeList);
}
@Override
public void onNoticeClicked(MyNotificationDTO itemModel) {
new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).setSelectedNotice(itemModel);
handleNoticeClicked(itemModel);
}
private void handleNoticeClicked(MyNotificationDTO itemModel) {
if (itemModel.getType().equals("0")) {
new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).fetchNoticeDetail(itemModel);
} else if (itemModel.getType().equals("1")) {
if(itemModel.getIsRead().equals("1")){
showTranSendComplete();
}else{
new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).changeNoticeStat();
}
}
}
@Override
public void showTranSendComplete() {
MyNotificationDTO selectedNotice=new ViewModelProvider(getActivity()).get(MyNotificationViewModel.class).getSelectedNotice();
Intent startReceiptActivity = new Intent(getActivity(), SendMoneyV2TransactionCompleteActivity.class);
startReceiptActivity.putExtra(SendMoneyV2TransactionCompleteActivity.SEND_MONEY_TID_BUNDLE_KEY, selectedNotice.getExtra());
startReceiptActivity.putExtra(SendMoneyV2TransactionCompleteActivity.DISPLAY_ACTIONS_BUNDLE_KEY, selectedNotice.getDisplayActions());
startActivity(startReceiptActivity);
}
}

121
app/src/main/res/layout/activity_home_v2.xml

@ -23,76 +23,105 @@
android:layout_height="match_parent">
<ImageView
android:layout_marginStart="@dimen/_13sdp"
android:id="@+id/iv_nav"
android:layout_width="@dimen/_17sdp"
android:layout_height="@dimen/_22sdp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/icv_home_nav_icon"
android:layout_alignParentStart="true" />
android:layout_marginStart="@dimen/_13sdp"
app:srcCompat="@drawable/icv_home_nav_icon" />
<ImageView
android:layout_width="@dimen/_80sdp"
android:layout_height="@dimen/_25sdp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/vd_jme_logo_only"
/>
app:srcCompat="@drawable/vd_jme_logo_only" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/_13sdp"
android:layout_toLeftOf="@+id/iv_help">
<ImageView
android:id="@+id/iv_notification"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:layout_centerVertical="true"
android:padding="@dimen/_3sdp"
app:srcCompat="@drawable/icv_home_notification_badge" />
<com.remit.jmecustomer.common.customwidgets.JmeTextView
android:id="@+id/notificationCountTxtView"
android:layout_width="@dimen/_15sdp"
android:layout_height="@dimen/_15sdp"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/_12sdp"
android:layout_marginTop="-1dp"
android:background="@drawable/circular_white_bg"
android:gravity="center"
android:text="1"
android:textColor="@color/colorAccent"
android:textSize="@dimen/_10ssp"
android:visibility="visible" />
</RelativeLayout>
<ImageView
android:layout_alignParentRight="true"
android:id="@+id/iv_help"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/icv_help"
android:layout_marginEnd="@dimen/_13sdp"
android:layout_alignParentEnd="true" />
app:srcCompat="@drawable/icv_help" />
<com.remit.jmecustomer.common.customwidgets.JmeTextView
android:id="@+id/notificationCounterTxtView"
android:layout_width="@dimen/_15sdp"
android:layout_height="@dimen/_15sdp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:background="@drawable/circular_white_bg"
android:gravity="center"
android:visibility="invisible"
android:layout_marginTop="@dimen/_4sdp"
android:layout_marginEnd="@dimen/_4sdp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:background="@drawable/circular_white_bg"
android:gravity="center"
android:textColor="@color/colorAccent"
android:textSize="@dimen/_7ssp"/>
android:textSize="@dimen/_7ssp"
android:visibility="invisible" />
<RelativeLayout
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true">
<ImageView
android:visibility="invisible"
android:id="@+id/iv_notification"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
app:srcCompat="@drawable/icv_home_notification_badge" />
<View
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignEnd="@+id/iv_notification"
android:layout_alignRight="@+id/iv_notification"
android:layout_alignTop="@+id/iv_notification"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="15dp"
android:background="@drawable/notification_dot"
android:gravity="center"
android:visibility="gone" />
android:visibility="gone">
<!-- <ImageView
android:id="@+id/iv_notification"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:visibility="invisible"
app:srcCompat="@drawable/icv_home_notification_badge" />-->
<!-- <View-->
<!-- android:layout_width="12dp"-->
<!-- android:layout_height="12dp"-->
<!-- android:layout_alignEnd="@+id/iv_notification"-->
<!-- android:layout_alignRight="@+id/iv_notification"-->
<!-- android:layout_alignTop="@+id/iv_notification"-->
<!-- android:layout_marginEnd="8dp"-->
<!-- android:layout_marginRight="8dp"-->
<!-- android:layout_marginTop="15dp"-->
<!-- android:background="@drawable/notification_dot"-->
<!-- android:gravity="center"-->
<!-- android:visibility="gone" />-->
</RelativeLayout>
</RelativeLayout>
@ -128,15 +157,15 @@
</RelativeLayout>
<!--<jmecustomer.support.design.widget.NavigationView-->
<!--jmecustomer:id="@+id/nav_drawer"-->
<!--jmecustomer:layout_width="match_parent"-->
<!--jmecustomer:layout_height="match_parent"-->
<!--jmecustomer:layout_gravity="start"-->
<!--jmecustomer:layout_marginLeft="-64dp"-->
<!--jmecustomer:layout_marginStart="-64dp"-->
<!--jmecustomer:fitsSystemWindows="true">-->
<!--jmecustomer:id="@+id/nav_drawer"-->
<!--jmecustomer:layout_width="match_parent"-->
<!--jmecustomer:layout_height="match_parent"-->
<!--jmecustomer:layout_gravity="start"-->
<!--jmecustomer:layout_marginLeft="-64dp"-->
<!--jmecustomer:layout_marginStart="-64dp"-->
<!--jmecustomer:fitsSystemWindows="true">-->
<!--<include layout="@layout/nav_drawer_fragment" />-->
<!--<include layout="@layout/nav_drawer_fragment" />-->
<!--</jmecustomer.support.design.widget.NavigationView>-->
@ -148,9 +177,9 @@
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_drawer"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"

13
app/src/main/res/layout/activity_my_notifications.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/layout_sendmoney_toolbar" />
<com.remit.jmecustomer.common.customwidgets.SwipeDisabledViewPager
android:id="@+id/noticeViewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</androidx.appcompat.widget.LinearLayoutCompat>

4
app/src/main/res/values/strings.xml

@ -611,4 +611,8 @@
<string name="invalid_deposit_slip_text" translatable="false">Invalid Deposit Slip</string>
<string name="deposit_slip_remarks_text">Message to JME (optional)</string>
<string name="sample_text" translatable="false">Sample</string>
<!-- my notification -->
<string name="my_notification_text" translatable="false">My Notification</string>
</resources><!---->
Loading…
Cancel
Save