Android - Lock item of a GridLayout and unlock after a certain time

0

I have GridView that has a list with several items arranged. Clicking on one of the items my app triggers a request for a WS. I would like that at the moment of the click the item that was clicked was disabled or without the click function. After a while I wanted to make the click function return to the item.

I can now change the color of the backgroud and return it to normal after the configured time.

I tried to work with isEnable() on my% custom% but I could not do the implementation logic. I've also tried to set the adapter or setClickable(false) directly in the view that is in the parameters of setEnable(false) within onItemClick() and also did not succeed.

Do you know how I can implement a solution to solve this click issue?

Adapter from my list

public class AdapterBicosGridView extends BaseAdapter {

    Context context;
    ArrayList<bico> listaDosBicos;
    View view;
    LayoutInflater inflater;

    public AdapterBicosGridView(Context context, ArrayList<bico> listaDosBicos) {
        this.context = context;
        this.listaDosBicos = listaDosBicos;
    }

    @Override
    public int getCount() {
        return listaDosBicos.size();
    }

    @Override
    public Object getItem(int position) {
        return listaDosBicos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null){

            view = new View(context);
            view = inflater.inflate(R.layout.item_grid_bicos, parent, false);

            TextView numeroBico = (TextView) view.findViewById(R.id.txtNumeroBico);
            TextView descricao = (TextView) view.findViewById(R.id.txtCombustivel);
            ImageView bomba = (ImageView) view.findViewById(R.id.imageView4);
            bico bicoClicado = listaDosBicos.get(position);

            numeroBico.setText(Utils.zerosEsquerda(bicoClicado.getId(), 2));
            descricao.setText(bicoClicado.getDescricao());
            bomba.setImageResource(R.drawable.bomba_2);

        } else {
            view = convertView;
        }

        return view;
    }

    @Override
    public boolean isEnabled(int position) {
        return super.isEnabled(position);
    }
}

Setar adapter in GridView

final AdapterBicosGridView adapterBicosGridView = new AdapterBicosGridView(this, bicosExibir);

gridView.setAdapter(adapterBicosGridView);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
        bico b = (bico) adapterView.getItemAtPosition(position);
        requisicaoPost(String.valueOf(b.getId()), view);
    }
});
    
asked by anonymous 26.04.2018 / 02:14

0 answers