package com.tool.applockpro.tool;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.tool.applockpro.R;
import com.tool.applockpro.adapter.NumberAdapter;
import com.tool.applockpro.adapter.PinAdapter;


public class MyinputPWD extends FrameLayout {
    private Context mcontext;
    private RecyclerView numberrv;
    private StringBuilder builder;
    private NumberAdapter numberAdapter;
    private PinAdapter pinAdapter;
    private RecyclerView pinrv;

    public MyinputPWD(@NonNull Context context) {
        super(context);
        initView(context);
    }

    public MyinputPWD(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    @SuppressLint("MissingInflatedId")
    private void initView(Context context) {
        mcontext = context;
        View view = LayoutInflater.from(mcontext).inflate(R.layout.number_input, null);
        numberrv = view.findViewById(R.id.number_rv);
        pinrv = view.findViewById(R.id.pin_rv);
        addView(view);


        pinAdapter = new PinAdapter(mcontext);
        pinrv.setAdapter(pinAdapter);
        pinrv.setLayoutManager(new LinearLayoutManager(mcontext, RecyclerView.HORIZONTAL, false));
//        SpaceItem spaceItem1 = new SpaceItem(20, 0, 20);
//        pinrv.addItemDecoration(spaceItem1);

        numberAdapter = new NumberAdapter(mcontext, pinAdapter);
//        SpaceItem spaceItem = new SpaceItem(100, 90, 100);
        numberrv.setAdapter(numberAdapter);
        numberrv.setLayoutManager(new GridLayoutManager(mcontext, 3));
//        numberrv.addItemDecoration(spaceItem);
    }

    public PinAdapter getPinAdapter() {
        return pinAdapter;
    }


}
