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.13k stars 453 forks source link

New Lib tableviewutil; reduce number of required app specific Classes; added generic parameter POJO; Updated Demo-App #406

Open k3b opened 1 year ago

k3b commented 1 year ago

The current implementation at https://github.com/evrencoskun/TableView requires a lot of copy&paste from example code to use the TableView in a clientapp.

Product vision: reduce the amount of (copied) code to integrate TableView into a clientapp.

Additional Requirements

Some differences between old and new style app that uses tableview

old style:

build.gradle dependencies:

implementation "com.evrencoskun.library:tableview:$tableview_version"

Mainfragment.java

private void initializeTableView(TableView tableView){
    // Create TableView Adapter
    mTableAdapter = new MyTableAdapter(getContext());
    tableView.setAdapter(mTableAdapter);

    // Create listener
    tableView.setTableViewListener(new MyTableViewListener(tableView));
}

Define app specific classes and resources

new style:

build.gradle dependencies:

implementation "com.evrencoskun.library:tableview:$tableview_version"
implementation "com.evrencoskun.library:tableviewutil:$tableview_version"

Mainfragment.java

private void initializeTableView(TableView tableView){
    List<ColumnDefinition<MySamplePojo>> columnDefinitions = TestData.createColumnDefinitions();
    List<MySamplePojo> pojos = TestData.createSampleData();
    // Create TableView View model class  to group view models of TableView
    TableViewModel<MySamplePojo> tableViewModel = new TableViewModel(columnDefinitions, pojos);

    // Create TableView Adapter
    TableViewAdapter<MySamplePojo> tableViewAdapter = new TableViewAdapter<>(columnDefinitions);

    tableView.setAdapter(tableViewAdapter);
    tableView.setTableViewListener(new MyTableViewListener(tableView));

    // Create an instance of a Filter and pass the TableView.
    //mTableFilter = new Filter(tableView);

    // Load the dummy data to the TableView
    tableViewAdapter.setAllItems(tableViewModel.getColumnHeaderList(), tableViewModel
            .getRowHeaderList(), tableViewModel.getCellList());

}

Define app specific classes and resources