package com.example.beijing_daxing;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.example.beijing_daxing.adapter.CheckListAdapter;
import com.example.beijing_daxing.base.BaseActivity;
import com.example.beijing_daxing.base.MyRecultCall;
import com.example.beijing_daxing.base.MyResult;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ActivityCheckListBinding;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;

import java.util.List;

public class CheckListActivity extends BaseActivity {
    private CheckListAdapter checkListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityCheckListBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_check_list);
        checkListAdapter = new CheckListAdapter(this);
        binding.setAdapter(checkListAdapter);
    }

    @Override
    protected void sanRfid(List<Reader.TAGINFO> epcs) {

    }

    public void check_start(View view) {
        OkGo.<MyResult>post(url + "/xj/createTask")
                .params("user", SharedPreferencesUtils.getstring("user", ""))
                .execute(new MyRecultCall(dialog, this) {
            @Override
            public void onSuccess(Response<MyResult> response) {
                super.onSuccess(response);
                var body = response.body();
                if (body.getCode() == 0) {
                    // list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
                    // }.getType());
                    // if (list == null || list.isEmpty()) {
                    //     Toast.makeText(CheckActivity.this, "没有维护巡检区域", Toast.LENGTH_SHORT).show();
                    //     return;
                    // }
                    // adapter.setList(list);
                    // adapter.notifyDataSetChanged();
                    return;
                }
                // Toast.makeText(this, body.getMsg(), Toast.LENGTH_SHORT).show();
            }
        });
    }
}