package kz.com.aman.kassa.bank;

import android.widget.Toast;

import java.util.List;

import ru.m4bank.mpos.library.external.transactions.ScanBarCodeCallbackHandler;
import ru.m4bank.mpos.service.result.Result;

public class ScanBarCodeCallbackHandlerImpl implements ScanBarCodeCallbackHandler {

    private final M4BankActivity activity;

    public ScanBarCodeCallbackHandlerImpl(M4BankActivity activity) {
        this.activity = activity;
    }

    @Override
    public void onCompleteBarCode(String result) {
        activity.runOnUiThread(() -> Toast.makeText(activity, result, Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onError(String result) {
        activity.runOnUiThread(() -> Toast.makeText(activity, result, Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onCardReaderForTransactionGettingCompleted() {

    }

    @Override
    public void onNoBoundedDevicesFound() {

    }

    @Override
    public void onConnectingProcessStarted(String s) {

    }

    @Override
    public void onDisconnectedEventReceivedOrCanNotEstablishConnection(boolean b, String s) {

    }

    @Override
    public void onDeviceToUseSelectionRequested(List list) {

    }

    @Override
    public void notAuthorized() {

    }

    @Override
    public void onDeviceToConnectSelectionRequested(List list) {

    }

    @Override
    public void onCompleted(Result result) {
        activity.runOnUiThread(() -> Toast.makeText(activity, (result.getDescription() == null ? "" : result.getDescription()), Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onWrongApiCalled() {

    }
}
