package it.integry.integrywmsnative.core.wifi;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import it.integry.integrywmsnative.core.REST.consumers.ISingleValueOperationCallback;

public class WiFiCheckerViewHolder implements ISingleValueOperationCallback<WiFiStatusChecker.SIGNAL>{

    private TextView mWifiSignalTextView;

    private WiFiStatusChecker mWiFiStatusChecker;

    public WiFiCheckerViewHolder(Context context, View view, int rsid){
        mWifiSignalTextView = view.findViewById(rsid);

        mWiFiStatusChecker = new WiFiStatusChecker(context);
    }


    public void startMonitoring(){
        mWiFiStatusChecker.startMonitoring(this);
    }

    public void stopMonitoring(){
        mWiFiStatusChecker.stopMonitoring();
    }


    @Override
    public void onResult(WiFiStatusChecker.SIGNAL value) {
        switch (value){
            case EXCELLENT:
                mWifiSignalTextView.setText("EXCELLENT");
                break;
            case GOOD:
                mWifiSignalTextView.setText("GOOD");
                break;
            case FAIR:
                mWifiSignalTextView.setText("FAIR");
                break;
            case WEAK:
                mWifiSignalTextView.setText("WEAK");
                break;
            case NONE:
                mWifiSignalTextView.setText("NONE");
                break;
        }
    }
}
