qr only history
This commit is contained in:
parent
d861c278a2
commit
efb0c76f69
6
.idea/copilot.data.migration.ask2agent.xml
Normal file
6
.idea/copilot.data.migration.ask2agent.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Ask2AgentMigrationStateService">
|
||||||
|
<option name="migrationStatus" value="COMPLETED" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.utsmm.kbz.ui.qr_pay;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.utsmm.kbz.R;
|
||||||
|
import com.utsmm.kbz.databinding.ItemQrHistoryBinding;
|
||||||
|
import com.utsmyanmar.paylibs.model.PayDetail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QRHistoryAdapter extends RecyclerView.Adapter<QRHistoryAdapter.ViewHolder> {
|
||||||
|
|
||||||
|
private List<PayDetail> items = new ArrayList<>();
|
||||||
|
|
||||||
|
public void setItems(List<PayDetail> list){
|
||||||
|
items = list;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
ItemQrHistoryBinding binding = DataBindingUtil.inflate(
|
||||||
|
LayoutInflater.from(parent.getContext()),
|
||||||
|
R.layout.item_qr_history,
|
||||||
|
parent,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
return new ViewHolder(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
holder.bind(items.get(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
private final ItemQrHistoryBinding binding;
|
||||||
|
|
||||||
|
public ViewHolder(@NonNull ItemQrHistoryBinding binding){
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bind(PayDetail item){
|
||||||
|
binding.setPayDetail(item);
|
||||||
|
binding.executePendingBindings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
package com.utsmm.kbz.ui.qr_pay;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.utsmm.kbz.BR;
|
||||||
|
import com.utsmm.kbz.R;
|
||||||
|
import com.utsmyanmar.baselib.fragment.DataBindingFragment;
|
||||||
|
import com.utsmyanmar.baselib.util.DataBindingConfig;
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
public class QRHistoryFragment extends DataBindingFragment {
|
||||||
|
|
||||||
|
private QRHistoryAdapter adapter;
|
||||||
|
private QRHistoryViewModel viewModel;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initViewModel() {
|
||||||
|
viewModel = new ViewModelProvider(this).get(QRHistoryViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DataBindingConfig getDataBindingConfig() {
|
||||||
|
DataBindingConfig bindingConfig = new DataBindingConfig(R.layout.fragment_qr_history, BR.viewModel, viewModel);
|
||||||
|
bindingConfig.addBindingParam(BR.adapter, adapter);
|
||||||
|
return bindingConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int currentId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int hostId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int routeId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume(){
|
||||||
|
super.onResume();
|
||||||
|
setToolBarTitleWithBackIcon("History");
|
||||||
|
observeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstance){
|
||||||
|
super.onViewCreated(view, savedInstance);
|
||||||
|
|
||||||
|
RecyclerView rvHistory = view.findViewById(R.id.qrRvHistory);
|
||||||
|
rvHistory.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
adapter = new QRHistoryAdapter();
|
||||||
|
rvHistory.setAdapter(adapter);
|
||||||
|
observeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void observeData(){
|
||||||
|
viewModel.getAllQrHistory().observe(getViewLifecycleOwner(), list -> {
|
||||||
|
adapter.setItems(list);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.utsmm.kbz.ui.qr_pay;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.utsmyanmar.baselib.repo.Repository;
|
||||||
|
import com.utsmyanmar.paylibs.model.PayDetail;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel;
|
||||||
|
|
||||||
|
@HiltViewModel
|
||||||
|
public class QRHistoryViewModel extends ViewModel {
|
||||||
|
private final Repository repository;
|
||||||
|
private final LiveData<List<PayDetail>> history;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public QRHistoryViewModel(Repository repository){
|
||||||
|
this.repository = repository;
|
||||||
|
this.history = repository.getAllQRHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<PayDetail>> getAllQrHistory(){
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -71,7 +71,7 @@ public class QRPayFragment extends DataBindingFragment {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "History":
|
case "History":
|
||||||
|
onClickHistory();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -384,4 +384,8 @@ public class QRPayFragment extends DataBindingFragment {
|
|||||||
NavHostFragment.findNavController(this)
|
NavHostFragment.findNavController(this)
|
||||||
.navigate(R.id.action_qrFragment_to_inputAmountFragment);
|
.navigate(R.id.action_qrFragment_to_inputAmountFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onClickHistory(){
|
||||||
|
NavHostFragment.findNavController(this).navigate(R.id.action_qrFragment_to_qrHistory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
19
app/src/main/res/layout/fragment_qr_history.xml
Normal file
19
app/src/main/res/layout/fragment_qr_history.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="vm"
|
||||||
|
type="com.utsmm.kbz.ui.qr_pay.QRHistoryViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/qrRvHistory"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</layout>
|
||||||
165
app/src/main/res/layout/item_qr_history.xml
Normal file
165
app/src/main/res/layout/item_qr_history.xml
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
>
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<import type="com.utsmyanmar.paylibs.utils.POSUtil"/>
|
||||||
|
<variable
|
||||||
|
name="payDetail"
|
||||||
|
type="com.utsmyanmar.paylibs.model.PayDetail" />
|
||||||
|
<variable
|
||||||
|
name="onItemClick"
|
||||||
|
type="com.utsmm.kbz.ui.management.ItemClickListener" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="4dp"
|
||||||
|
android:layout_marginVertical="6dp"
|
||||||
|
app:cardCornerRadius="12dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="@color/white"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
|
android:onClick="@{() -> onItemClick.onClickCard(payDetail)}">
|
||||||
|
|
||||||
|
<!-- Card with border -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="2dp"
|
||||||
|
android:background="@drawable/bg_edittext_primary_border"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<!-- Transaction Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/ic_custom_pos"
|
||||||
|
app:tint="@color/colorPrimary"
|
||||||
|
android:alpha="0.8"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_gravity="top" />
|
||||||
|
|
||||||
|
<!-- Transaction Details -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- Transaction Type and Amount Row -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
|
<!-- Transaction Type -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@{POSUtil.getInstance().getTransName(payDetail)}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
app:isColorChanges="@{payDetail}"
|
||||||
|
tools:text="SALE" />
|
||||||
|
|
||||||
|
<!-- Transaction Amount -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{POSUtil.getInstance().checkMinusSign(payDetail.transactionType)+POSUtil.getInstance().getDecimalAmountSeparatorFormat(payDetail.amount) + ` `+POSUtil.getInstance().currencyCodeToText(payDetail.currencyCode)}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
app:isColorChanges="@{payDetail}"
|
||||||
|
tools:text="1,000.00 MMK" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Transaction Date -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{POSUtil.getInstance().convertDateFormatByDateString(payDetail.transDate)}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:alpha="0.8"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
app:isColorChanges="@{payDetail}"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
|
tools:text="2022-11-26" />
|
||||||
|
|
||||||
|
<!-- Card Number -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{POSUtil.getInstance().getCardNumMasking(payDetail.cardNo)}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:alpha="0.8"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
tools:text="468785******9564" />
|
||||||
|
|
||||||
|
<!-- Trace and RRN Row -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- Trace Number -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:isTrace="@{payDetail}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:alpha="0.7"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
app:isColorChanges="@{payDetail}"
|
||||||
|
tools:text="TRC:000050" />
|
||||||
|
|
||||||
|
<!-- RRN -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@{`RRN:`+payDetail.referNo}"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:alpha="0.7"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:textAlignment="textEnd"
|
||||||
|
app:isColorChanges="@{payDetail}"
|
||||||
|
tools:text="RRN:233001786242" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Arrow Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:src="@drawable/ic_right_arrow"
|
||||||
|
app:tint="@color/colorPrimary"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="8dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</layout>
|
||||||
@ -1082,5 +1082,15 @@
|
|||||||
<action
|
<action
|
||||||
android:id="@+id/action_qrFragment_to_inputAmountFragment"
|
android:id="@+id/action_qrFragment_to_inputAmountFragment"
|
||||||
app:destination="@id/inputAmountFragment" />
|
app:destination="@id/inputAmountFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_qrFragment_to_qrHistory"
|
||||||
|
app:destination="@id/qrHistory"
|
||||||
|
/>
|
||||||
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/qrHistory"
|
||||||
|
tools:layout="@layout/fragment_qr_history"
|
||||||
|
android:name="com.utsmm.kbz.ui.qr_pay.QRHistoryFragment"
|
||||||
|
>
|
||||||
</fragment>
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
||||||
@ -442,7 +442,7 @@
|
|||||||
<string name="txt_disconnect">Disconnect</string>
|
<string name="txt_disconnect">Disconnect</string>
|
||||||
<string name="txt_sending_third_reversal">Trying reversal last time!</string>
|
<string name="txt_sending_third_reversal">Trying reversal last time!</string>
|
||||||
<string name="txt_trans_voided">Transaction Voided</string>
|
<string name="txt_trans_voided">Transaction Voided</string>
|
||||||
<!-- <string name="txt_void_not_found">Void Failed,01- No Transaction Details Found</string>-->
|
<!-- <string name="txt_void_not_found">Void Failed,01- No Transaction Details Found</string>-->
|
||||||
<string name="txt_void_not_found">Void Failed 914-ORIGINAL TRANSACTION NOT FOUND</string>
|
<string name="txt_void_not_found">Void Failed 914-ORIGINAL TRANSACTION NOT FOUND</string>
|
||||||
<string name="txt_qr_generate_failed">QR Generation Failed!</string>
|
<string name="txt_qr_generate_failed">QR Generation Failed!</string>
|
||||||
<string name="txt_qr_auth_failed">Auth Failed!</string>
|
<string name="txt_qr_auth_failed">Auth Failed!</string>
|
||||||
@ -593,5 +593,7 @@
|
|||||||
<item>PhaYaSa</item>
|
<item>PhaYaSa</item>
|
||||||
<item>YaTaNa</item>
|
<item>YaTaNa</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@ -149,4 +149,7 @@ public interface PayDetailDao {
|
|||||||
@Query("SELECT * FROM paydetail ORDER BY PID DESC")
|
@Query("SELECT * FROM paydetail ORDER BY PID DESC")
|
||||||
LiveData<List<PayDetail>> getAllTrans();
|
LiveData<List<PayDetail>> getAllTrans();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT * FROM paydetail WHERE transactionType = 20 ORDER BY PID DESC")
|
||||||
|
LiveData<List<PayDetail>> getAllQRHistory();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -226,4 +226,6 @@ public class Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<PayDetail>> getAllTrans() { return payDetailDao.getAllTrans(); }
|
public LiveData<List<PayDetail>> getAllTrans() { return payDetailDao.getAllTrans(); }
|
||||||
|
|
||||||
|
public LiveData<List<PayDetail>> getAllQRHistory(){ return payDetailDao.getAllQRHistory();}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user