DimiDR / TI-ThermalPrinter-Android

Tasty Igniter Android App to help with POS printing
MIT License
0 stars 2 forks source link

Implement PopUp for reprinting #8

Closed DimiDR closed 2 months ago

DimiDR commented 3 months ago

Implement reprenting UI.

  1. Press a button to open a popup. Here you see the list with last 50 orders (all orders from API).
  2. In the list there is an additional button.
  3. Clicking on the button will brint the receipt

It should contain: Order Nr, Time, Name, Status of Order

DimiDR commented 3 months ago

TIJobPrintBluetooth method has

printedOrders.add(orderId);
IdManager.clearIds(context);
IdManager.saveIds(context, printedOrders);

This will save order IDs so they will not be reprinted. This should not happen. As this is only for automatic printing while service is running. The service will only print invoices, which were not yet printed and have the initial status.

In MainActivity there is this code:

public void onSuccess(String[] results) { ...
JSONObject jsonObjectOrders = new JSONObject(results[0]);
                JSONObject jsonObjectMenus = new JSONObject(results[1]);
                JSONObject jsonObjectCategories = new JSONObject(results[2]);
                JSONArray dataArrayOrders = DocketStringModeler.filterPrintableOrders(jsonObjectOrders.getJSONArray("data"), printedOrders);
                for (int i = 0; i < dataArrayOrders.length(); i++) {
                    dataObjectOrders = dataArrayOrders.getJSONObject(i);
                    orderID = dataObjectOrders.getString("id");
                    TIJobPrintBluetooth(docketStringModeler.startPrinting(dataObjectOrders, jsonObjectMenus, jsonObjectCategories, mediaPlayer, shop_name), orderID);
                }

The filterPrintableOrders will remove data from array, for the orders which were already printed. This method should not be used in forces printing. TIJobPrintBluetooth should execute the print, if the correct data is given. As only one print in the list view is selectable, it will be always one element.

I hope executing TIJobPrintBluetooth with correct data is enough.

DimiDR commented 2 months ago

Popup UI is in xml file orders_list.xml RePrintTask in Main activity

To show different data you can see OrdersAdapter.class This adapter is used in popup to display data

Logic in OrderAdapter.java