added new history screen

This commit is contained in:
MooN 2026-02-05 15:23:16 +06:30
parent 6669528fdb
commit 4867644d69
6 changed files with 322 additions and 18 deletions

View File

@ -973,6 +973,11 @@ public class MainFragment extends DataBindingFragment {
} }
} }
public void onClickHistory(){
routeId = R.id.action_nav_main_to_dashboardHistoryFragment;
safeRouteTo(currentId(), routeId, hostId());
}
public void onClickReport() { public void onClickReport() {
routeId = R.id.action_nav_main_to_manageFunctionFragment; routeId = R.id.action_nav_main_to_manageFunctionFragment;
safeRouteTo(currentId(), routeId, hostId()); safeRouteTo(currentId(), routeId, hostId());

View File

@ -0,0 +1,190 @@
package com.utsmm.kbz.ui.dashboard;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.utsmyanmar.baselib.fragment.DataBindingFragment;
import com.utsmyanmar.baselib.util.DataBindingConfig;
import com.utsmyanmar.baselib.util.DialogCallback;
import com.utsmyanmar.paylibs.model.PayDetail;
import com.utsmyanmar.paylibs.model.TradeData;
import com.utsmyanmar.paylibs.print.PrintHelper;
import com.utsmyanmar.paylibs.print.printx.PrintXReceipt;
import com.utsmyanmar.paylibs.print.printx.PrintXStatus;
import com.utsmyanmar.paylibs.utils.POSUtil;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
import com.utsmyanmar.paylibs.utils.enums.HostType;
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType;
import com.utsmyanmar.paylibs.utils.params.Params;
import com.nexgo.oaf.apiv3.SdkResult;
import com.utsmm.kbz.BR;
import com.utsmm.kbz.R;
import com.utsmm.kbz.config.Constants;
import com.utsmm.kbz.databinding.FragmentDashboardHistoryScreenBinding;
import com.utsmm.kbz.ui.core_viewmodel.SharedViewModel;
import com.utsmm.kbz.ui.management.HistoryAdapter;
import com.utsmm.kbz.ui.management.ManagementViewModel;
import java.util.ArrayList;
public class DashboardHistoryFragment extends DataBindingFragment {
private ManagementViewModel managementViewModel;
private SharedViewModel sharedViewModel;
private HistoryAdapter detailReportAdapter;
private int routeId;
private final ArrayList<PayDetail> lists = new ArrayList<>();
@Override
protected void initViewModel() {
managementViewModel = getFragmentScopeViewModel(ManagementViewModel.class);
sharedViewModel = getFragmentScopeViewModel(SharedViewModel.class);
}
@Override
protected DataBindingConfig getDataBindingConfig() {
return new DataBindingConfig(R.layout.fragment_dashboard_history_screen, BR.manageViewModel, managementViewModel)
.addBindingParam(BR.sharedViewModel, sharedViewModel)
.addBindingParam(BR.click, new ClickEvent());
}
@Override
protected int currentId() {
return R.id.dashboardHistoryFragment;
}
@Override
protected int hostId() {
return Constants.NAV_HOST_ID;
}
@Override
protected int routeId() {
return routeId;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
observeHistory();
}
@Override
public void onResume() {
super.onResume();
setToolBarTitleWithBackIcon(getString(R.string.title_history));
managementViewModel.detailReportLayoutVisibility.setValue(0);
managementViewModel.detailReportBottomLayoutVisibility.setValue(0);
}
private void observeHistory() {
managementViewModel.getTransactionHistory().observe(getViewLifecycleOwner(), payDetailList -> {
if (payDetailList == null) {
return;
}
lists.clear();
if (payDetailList.isEmpty()) {
managementViewModel.detailReportLayoutVisibility.setValue(0);
managementViewModel.detailReportBottomLayoutVisibility.setValue(8);
} else {
managementViewModel.detailReportLayoutVisibility.setValue(8);
managementViewModel.detailReportBottomLayoutVisibility.setValue(0);
}
HostType hostType = sharedViewModel.hostType.getValue();
for (PayDetail payDetail : payDetailList) {
if (hostType == HostType.MPU) {
if (payDetail.getTransactionType() != TransactionsType.MMQR.value
&& payDetail.getTransactionType() != TransactionsType.REVERSAL.value
&& payDetail.getTransactionType() != TransactionsType.SETTLEMENT.value
&& POSUtil.getInstance().getYesterdayDate()
.compareTo(POSUtil.getInstance().getDateByString(payDetail.transDate)) < 1) {
lists.add(payDetail);
}
} else if (hostType == HostType.QR) {
if (payDetail.getTransactionType() == TransactionsType.MMQR.value
&& payDetail.getQrTransStatus() == 1) {
lists.add(payDetail);
}
} else {
lists.add(payDetail);
}
}
if (lists.isEmpty()) {
managementViewModel.detailReportBottomLayoutVisibility.setValue(8);
managementViewModel.detailReportLayoutVisibility.setValue(0);
}
detailReportAdapter = new HistoryAdapter(lists);
((FragmentDashboardHistoryScreenBinding) mBinding).setAdapter(detailReportAdapter);
});
}
private void navigateMain() {
routeId = R.id.action_dashboardHistoryFragment_to_nav_main;
safeNavigateToRouteId();
}
public class ClickEvent {
public void onCancel() {
navigateMain();
}
public void onPrint() {
TradeData tradeData = Params.newTrade(false);
PayDetail payDetail = tradeData.getPayDetail();
payDetail.setTransType(TransactionsType.DETAIL_REPORT.name);
payDetail.setTransactionType(TransactionsType.DETAIL_REPORT.value);
if (PrintHelper.getInstance().paperRollStatus() == SdkResult.Printer_PaperLack) {
showPrinterAlertDialog(getString(R.string.txt_paper_roll_not_ready), new DialogCallback() {
@Override
public void onClickCancel() {
dismissPrinterAlertDialog();
}
@Override
public void onClickRetry() {
dismissPrinterAlertDialog();
if (PrintHelper.getInstance().paperRollStatus() != SdkResult.Success) {
return;
}
PrintXReceipt.getInstance().printDetailReport(payDetail, lists, sharedViewModel.hostType.getValue(), new PrintXStatus() {
@Override
public void onSuccess() {
}
@Override
public void onFailure() {
}
});
}
});
if (SystemParamsOperation.getInstance().isAlertSound()) {
startSound(getString(R.string.txt_audio_printer_alert));
}
} else if (PrintHelper.getInstance().paperRollStatus() == SdkResult.Success) {
PrintXReceipt.getInstance().printDetailReport(payDetail, lists, sharedViewModel.hostType.getValue(), new PrintXStatus() {
@Override
public void onSuccess() {
}
@Override
public void onFailure() {
}
});
}
}
}
}

View File

@ -157,9 +157,6 @@ public class DashboardTransFragment extends DataBindingFragment {
case CASH_ADVANCE: case CASH_ADVANCE:
new DashboardTransFragment.ClickEvent().onClickCashAdvance(); new DashboardTransFragment.ClickEvent().onClickCashAdvance();
break; break;
case HISTORY:
new DashboardTransFragment.ClickEvent().onClickHistory();
break;
case DEVICE_CONFIG: case DEVICE_CONFIG:
new DashboardTransFragment.ClickEvent().onClickDeviceConfig(); new DashboardTransFragment.ClickEvent().onClickDeviceConfig();
break; break;
@ -262,12 +259,6 @@ public class DashboardTransFragment extends DataBindingFragment {
safeRouteTo(currentId,routeId,hostId); safeRouteTo(currentId,routeId,hostId);
} }
public void onClickHistory() {
routeId = R.id.action_dashboardTransFragment_to_manageFunctionFragment;
safeRouteTo(currentId,routeId,hostId);
}
public void onClickDeviceConfig(){ public void onClickDeviceConfig(){
routeId = R.id.action_dashboardTransFragment_to_deviceConfig; routeId = R.id.action_dashboardTransFragment_to_deviceConfig;
safeRouteTo(currentId, routeId, hostId); safeRouteTo(currentId, routeId, hostId);

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="sharedViewModel"
type="com.utsmm.kbz.ui.core_viewmodel.SharedViewModel" />
<variable
name="manageViewModel"
type="com.utsmm.kbz.ui.management.ManagementViewModel" />
<variable
name="adapter"
type="com.utsmm.kbz.ui.management.HistoryAdapter" />
<variable
name="click"
type="com.utsmm.kbz.ui.dashboard.DashboardHistoryFragment.ClickEvent" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:padding="12dp"
android:layout_height="match_parent">
<LinearLayout
android:visibility="@{manageViewModel.detailReportLayoutVisibility}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lav_no_trans"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="8dp"
app:lottie_autoPlay="true"
app:lottie_fileName="lottie_no_trans.json"
app:lottie_loop="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/rubik_regular"
android:text="@string/txt_trans_not_found"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="22sp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lav_no_trans" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:adapter="@{adapter}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_view_history" />
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:orientation="horizontal"
android:visibility="@{manageViewModel.detailReportBottomLayoutVisibility}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_amount_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/bg_rounded_btn_cancel_cv"
android:onClick="@{()->click.onCancel()}"
android:text="@string/layout_cancel"
android:textColor="@color/colorPrimary" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_amount_confirm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/bg_rounded_btn_cv"
android:onClick="@{()->click.onPrint()}"
android:text="@string/layout_print"
android:textColor="@color/white" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -168,10 +168,7 @@
android:layout_width="120dp" android:layout_width="120dp"
android:layout_height="120dp" android:layout_height="120dp"
android:background="@drawable/honey" android:background="@drawable/honey"
android:clickable="@{mainViewModel.voidStatus}" android:onClick="@{() -> click.onClickHistory()}"
android:focusable="@{mainViewModel.voidStatus}"
android:alpha="@{mainViewModel.voidStatus ? 1f : 0.5f}"
android:onClick="@{() -> click.onClickVoid()}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/bt4" app:layout_constraintEnd_toStartOf="@+id/bt4"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -186,14 +183,14 @@
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:src="@drawable/ic_void_dash" android:src="@drawable/ic_history"
app:tint="@color/colorPrimary" /> app:tint="@color/colorPrimary" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@font/rubik_medium" android:fontFamily="@font/rubik_medium"
android:text="Void" android:text="History"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:textSize="14sp" android:textSize="14sp"

View File

@ -147,6 +147,9 @@
<action <action
android:id="@+id/action_nav_main_to_versionFragment" android:id="@+id/action_nav_main_to_versionFragment"
app:destination="@id/versionFragment" /> app:destination="@id/versionFragment" />
<action
android:id="@+id/action_nav_main_to_dashboardHistoryFragment"
app:destination="@id/dashboardHistoryFragment" />
<action <action
android:id="@+id/action_nav_main_to_QRTransactionFragment" android:id="@+id/action_nav_main_to_QRTransactionFragment"
app:destination="@id/QRTransactionFragment" /> app:destination="@id/QRTransactionFragment" />
@ -617,8 +620,8 @@
app:launchSingleTop="true" app:launchSingleTop="true"
app:popUpTo="@+id/dashboardTransFragment" app:popUpTo="@+id/dashboardTransFragment"
app:popUpToInclusive="true" app:popUpToInclusive="true"
android:id="@+id/action_dashboardTransFragment_to_manageFunctionFragment" android:id="@+id/action_dashboardTransFragment_to_dashboardHistoryFragment"
app:destination="@id/managementFunctionFragment" /> app:destination="@id/dashboardHistoryFragment" />
<action <action
app:launchSingleTop="true" app:launchSingleTop="true"
app:popUpTo="@+id/dashboardTransFragment" app:popUpTo="@+id/dashboardTransFragment"
@ -674,6 +677,18 @@
android:id="@+id/action_dashboardPreAuthCancelBottomSheet_to_inputPasswordFragment" android:id="@+id/action_dashboardPreAuthCancelBottomSheet_to_inputPasswordFragment"
app:destination="@id/inputPasswordFragment" /> app:destination="@id/inputPasswordFragment" />
</dialog> </dialog>
<fragment
tools:layout="@layout/fragment_dashboard_history_screen"
android:id="@+id/dashboardHistoryFragment"
android:name="com.utsmm.kbz.ui.dashboard.DashboardHistoryFragment"
android:label="@string/title_history" >
<action
app:launchSingleTop="true"
app:popUpTo="@+id/mobile_navigation"
app:popUpToInclusive="true"
android:id="@+id/action_dashboardHistoryFragment_to_nav_main"
app:destination="@id/nav_main" />
</fragment>
<fragment <fragment
tools:layout="@layout/fragment_print_receipt_screen" tools:layout="@layout/fragment_print_receipt_screen"
android:id="@+id/printReceiptFragment" android:id="@+id/printReceiptFragment"
@ -1225,4 +1240,4 @@
app:destination="@id/nav_main" /> app:destination="@id/nav_main" />
</fragment> </fragment>
</navigation> </navigation>