Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/de.codecrafters.tableview.SortableTableView: Unable to sort column with index -1. Reason: no comparator set for this column. #49

Closed
boogerlad opened this issue Aug 14, 2016 · 2 comments
Assignees
Labels

Comments

@boogerlad
Copy link

boogerlad commented Aug 14, 2016

The example application from the google play store does not exhibit this issue. However, following the instructions from the readme.md file, any time the orientation of the screen changes, the warning (from the title) appears in the debug log. I'm using 2.2.1 on android 6.0

This is the view

<de.codecrafters.tableview.SortableTableView
        xmlns:table="http://schemas.android.com/apk/res-auto"
        android:id="@+id/tableView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

This is the code in a fragment

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_history, container, false);
        SortableTableView<String[]> tableView = (SortableTableView<String[]>) v.findViewById(R.id.tableView);

        String[] header = {"Scan", "Hardware ID", "Timestamp", "blood"};
        tableView.setHeaderAdapter(new SimpleTableHeaderAdapter(getActivity(), header));


        tableView.setColumnCount(4);

        String[][] data = {{"no", "data", "yet", ":("}};
        tableView.setDataAdapter(new SimpleTableDataAdapter(getActivity(), data));
        tableView.setColumnComparator(0, (String[] lhs, String[] rhs)->Integer.parseInt(lhs[0]) - Integer.parseInt(rhs[0]));
        tableView.setColumnComparator(1, (String[] lhs, String[] rhs)->lhs[1].compareTo(rhs[1]));
        tableView.setColumnComparator(2, (String[] lhs, String[] rhs)->lhs[2].compareTo(rhs[2]));
        tableView.setColumnComparator(3, (String[] lhs, String[] rhs)->Integer.parseInt(lhs[3]) - Integer.parseInt(rhs[3]));
        return v;
    }

Interestingly enough, the first instance of this fragment getting created won't display that error/warning onto the log.

@ISchwarz23
Copy link
Owner

Hi @boogerlad,

thanks for the hint. Seems to be a small issue in the restoreInstanceState method. There will be a bug fix for this :-)

Best regards,
Ingo

@ISchwarz23 ISchwarz23 added the bug label Aug 23, 2016
@ISchwarz23 ISchwarz23 self-assigned this Aug 23, 2016
@ISchwarz23
Copy link
Owner

Hi @boogerlad,

the new SortableTableView with the promissed bugfix is available. Have a try using
compile "de.codecrafters.tableview:tableview:2.2.2".

Best regards,
Ingo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants