evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.14k stars 459 forks source link

Error from Example #178

Open karasu1 opened 5 years ago

karasu1 commented 5 years ago

Hello dev, i would like to ask when I'm using implementation 'com.evrencoskun.library:tableview:0.8.8' , why i got error from the example when i try to used the pagination?, the code which i'm unblock is

if (mPaginationEnabled) {
    tableTestContainer.setVisibility(View.VISIBLE);
    itemsPerPage.setOnItemSelectedListener(onItemsPerPageSelectedListener);

    previousButton.setOnClickListener(mClickListener);
    nextButton.setOnClickListener(mClickListener);
    pageNumberField.addTextChangedListener(onPageTextChanged);
} else {
    tableTestContainer.setVisibility(View.GONE);
}

......

if (mPaginationEnabled) {
    mTableFilter = new Filter(mTableView); // Create an instance of a Filter and pass the
    // created TableView.

    // Create an instance for the TableView pagination and pass the created TableView.
    mPagination = new Pagination(mTableView);

    // Sets the pagination listener of the TableView pagination to handle
    // pagination actions. See onTableViewPageTurnedListener variable declaration below.
    mPagination.setOnTableViewPageTurnedListener(onTableViewPageTurnedListener);
}

The Error:

10-24 03:14:31.527 4878-4878/com.example.------- E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.-------, PID: 4878
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
    at com.evrencoskun.tableview.pagination.Pagination.paginateData(Pagination.java:120)
    at com.evrencoskun.tableview.pagination.Pagination.setItemsPerPage(Pagination.java:165)
    at com.example.-------.java.sample_table.MainFragment.setTableItemsPerPage(MainFragment.java:168)
    at com.example.-------.java.sample_table.MainFragment$4.onItemSelected(MainFragment.java:255)
    at android.widget.AdapterView.fireOnSelected(AdapterView.java:924)
    at android.widget.AdapterView.dispatchOnItemSelected(AdapterView.java:913)
    at android.widget.AdapterView.-wrap1(AdapterView.java)
    at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:883)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
alich65 commented 5 years ago

hello I have same problem with that, how to solved? please help me.

MGaetan89 commented 4 years ago

Hi @karasu1, @alich65. This should be fixed in master. Can you try and close this issue if it works for you?