N
N
Neonoviiwolf2017-07-17 03:28:48
Java
Neonoviiwolf, 2017-07-17 03:28:48

Why doesn't Log.i work in this code?

Good
, here's the code, I'm dealing with my adapter, I stumbled upon an incomprehensible moment

private ArrayList<String> allMyForArrayAdapter = new ArrayList<>(); //он не пустой, там 26 значений
    @Override
    public Filter getFilter() {
        Log.i("Test", "getFilter");
        Log.i("Test", "aaaaaaaa" + allMyForArrayAdapter.size()); //тут нормально
        Filter filter = new Filter() {
            @Override
            protected FilterResults performFiltering(CharSequence charSequence) {
//                Log.i("Test", "performFiltering " + charSequence);
                charSequence = charSequence.toString().toLowerCase();
                FilterResults filterResults = new FilterResults();
                if (charSequence.toString().length() > 0) {

                    Log.i("Test", charSequence.toString().length() + "");
                    Log.i("Test", "а это не работает" + allMyForArrayAdapter.size());//а это не работает


                    ArrayList<String> strings = new ArrayList<>();
                    for (int i = 0; allMyForArrayAdapter.size() > i; ++i) {
                        String m = allMyForArrayAdapter.get(i).toLowerCase();
                        Log.i("Test", allMyForArrayAdapter.get(i).toLowerCase());
                        if (m.contains(charSequence)) {
                            strings.add(m);
                        }
                    }
                    filterResults.values = strings;
                    filterResults.count = strings.size();
                } else {
                    synchronized (this) {
                        filterResults.values = list;
                        filterResults.count = list.size();
                    }
                }
                return filterResults;
            }

            @Override
            protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
//                Log.i("Test", "publishResults " + charSequence);
                allMyForArrayAdapter = (ArrayList<String>) filterResults.values;
                notifyDataSetChanged();
                clear();
                for (int i = 0; list.size() > i; ++i)
                    add(list.get(i));
                notifyDataSetInvalidated();
            }
        };
        return filter;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-07-17
@aol-nnov

how does it not work? not performed? obviously charSequence.toString().length() > 0 is false.
if it falls, then the stack trace will not hurt to add to the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question