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

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

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
71d8e4e
Removed id from ColumnHeader
k3b Mar 1, 2023
3342e90
Replaced ColumnHeader with String; Removed ColumnHeader
k3b Mar 1, 2023
622575c
Replaced ColumnHeader with String; Removed ColumnHeader
k3b Mar 1, 2023
a58ad24
Removed CellBase
k3b Mar 1, 2023
1f22340
For Sorting to work id must be unique per row. Unique per cell is not…
k3b Mar 1, 2023
fb773c9
reverted changes in Cell
k3b Mar 1, 2023
f3d32a7
Fixed inline docs
k3b Mar 1, 2023
35360c2
Fixed inline docs
k3b Mar 1, 2023
3fd73ed
Redesign: made Cell generic using new Itemtype MyItem
k3b Mar 1, 2023
ca97dea
refactored colors: renamed to default_table_xxx and moved to lib
k3b Mar 1, 2023
ae0cdb1
Revert "refactored colors: renamed to default_table_xxx and moved to …
k3b Mar 1, 2023
2028ad2
docs updated; renamed app specific MyItem to MySamplePojo
k3b Mar 2, 2023
b569ddb
customized TableViewAdapter inherits from new generic TableViewAdapte…
k3b Mar 2, 2023
80044dd
Introduced (I)Row as a replacement for List(i.e. List<List<Cell<Pojo>…
k3b Mar 2, 2023
71f2ca0
Introduced (I)Row as a replacement for List(i.e. List<List<Cell<Pojo>…
k3b Mar 6, 2023
799fe06
fix: match show/hide postition with menutext
k3b Mar 6, 2023
e9eb42f
refactored:
k3b Mar 7, 2023
5507a57
added empty androidlib tableviewutil
k3b Mar 7, 2023
a2e7ecb
moved app resources to lib tableviewutil
k3b Mar 8, 2023
96fb3f4
moved Cell, (I)Row to com.evrencoskun.tableview.modell
k3b Mar 8, 2023
1abb020
renamed modell to model; moved com.evrencoskun.tableviewsample.holder…
k3b Mar 8, 2023
0ae521b
moved TableViewAdapterBase + holder.ColumnHeaderViewHolder from com.e…
k3b Mar 8, 2023
20462f0
introduced ColumnDefinition
k3b Mar 8, 2023
a7fb62f
POJO must only implement IModelWithId
k3b Mar 8, 2023
aaa11ab
removed column-Index : getContent(int column) -> getContent()
k3b Mar 8, 2023
44f5d41
Seperated new TestData plus generic tableviewutil.TableViewModel
k3b Mar 9, 2023
7fa68d6
Made TableViewAdapter generic. All column definitions come from Colum…
k3b Mar 10, 2023
dc4f95f
Updated docs
k3b Mar 10, 2023
aad1660
Updated docs
k3b Mar 10, 2023
0c87e22
fixed Header-Menu. Added pojo to ViewHolder and app showToast
k3b Mar 10, 2023
0219600
Removed obsolete (I)Row
k3b Mar 11, 2023
1b90399
Fixed Rowheader-pojo
k3b Mar 11, 2023
d724d1e
Fixed ColumnHeader
k3b Mar 11, 2023
08cd721
Reverted ColumnHeader from String back to ColumnDefinition
k3b Mar 13, 2023
a254f2f
fix: reimplemented ViewHolderTypId so that show/hide column works
k3b Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {

dependencies {
implementation project(path: ':tableview')
implementation project(path: ':tableviewutil')

implementation "androidx.annotation:annotation:$androidx_annotation_version"
implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@
import com.evrencoskun.tableview.TableView;
import com.evrencoskun.tableview.filter.Filter;
import com.evrencoskun.tableview.pagination.Pagination;
import com.evrencoskun.tableviewsample.tableview.TableViewAdapter;
import com.evrencoskun.tableviewsample.tableview.TableViewListener;
import com.evrencoskun.tableviewsample.tableview.TableViewModel;
import com.evrencoskun.tableviewutil.TableViewAdapter;
import com.evrencoskun.tableviewutil.TableViewModel;
import com.evrencoskun.tableviewsample.tableview.TestData;
import com.evrencoskun.tableviewsample.tableview.model.MySamplePojo;
import com.evrencoskun.tableview.model.ColumnDefinition;

import java.util.List;

/**
* A simple {@link Fragment} subclass.
*
* * Display the TableView.
* * Implements filtering, paging, selection, onClick-handling, menue-commands
*/
public class MainFragment extends Fragment {
private Spinner moodFilter, genderFilter;
Expand Down Expand Up @@ -115,11 +123,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
}

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

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

mTableView.setAdapter(tableViewAdapter);
mTableView.setTableViewListener(new TableViewListener(mTableView));
Expand Down Expand Up @@ -158,15 +168,15 @@ public void filterTableForMood(@NonNull String filter) {
// Sets a filter to the table, this will only filter a specific column.
// In the example data, this will filter the mood column.
if (mTableFilter != null) {
mTableFilter.set(TableViewModel.MOOD_COLUMN_INDEX, filter);
mTableFilter.set(TestData.COLUMN_INDEX_MOOD_HAPPY, filter);
}
}

public void filterTableForGender(@NonNull String filter) {
// Sets a filter to the table, this will only filter a specific column.
// In the example data, this will filter the gender column.
if (mTableFilter != null) {
mTableFilter.set(TableViewModel.GENDER_COLUMN_INDEX, filter);
mTableFilter.set(TestData.COLUMN_INDEX_GENDER_MALE, filter);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
package com.evrencoskun.tableviewsample.tableview;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.evrencoskun.tableview.TableView;
import com.evrencoskun.tableview.adapter.recyclerview.holder.AbstractViewHolder;
import com.evrencoskun.tableview.listener.ITableViewListener;
import com.evrencoskun.tableviewsample.tableview.holder.ColumnHeaderViewHolder;
import com.evrencoskun.tableviewutil.holder.ColumnHeaderViewHolder;
import com.evrencoskun.tableviewsample.tableview.popup.ColumnHeaderLongPressPopup;
import com.evrencoskun.tableviewsample.tableview.popup.RowHeaderLongPressPopup;

Expand Down Expand Up @@ -60,10 +62,21 @@ public TableViewListener(@NonNull TableView tableView) {
*/
@Override
public void onCellClicked(@NonNull RecyclerView.ViewHolder cellView, int column, int row) {
showToast("onCellClicked" + getMessageContext(cellView, column, row));

// Do what you want.
showToast("Cell " + column + " " + row + " has been clicked.");
}

@NonNull
private String getMessageContext(RecyclerView.ViewHolder cellView, int column, int row) {
String data = "";
if (cellView instanceof AbstractViewHolder) {
final Object pojo = ((AbstractViewHolder) cellView).getPojo();
if (pojo != null) {
data = pojo.toString();
}
}
return "(c=" + column + ",r=" + row + ") for " + data + " [" +
cellView.getClass().getSimpleName() + ".]";
}

/**
Expand All @@ -76,7 +89,7 @@ public void onCellClicked(@NonNull RecyclerView.ViewHolder cellView, int column,
@Override
public void onCellDoubleClicked(@NonNull RecyclerView.ViewHolder cellView, int column, int row) {
// Do what you want.
showToast("Cell " + column + " " + row + " has been double clicked.");
showToast("onCellDoubleClicked" + getMessageContext(cellView, column, row));
}

/**
Expand All @@ -90,7 +103,7 @@ public void onCellDoubleClicked(@NonNull RecyclerView.ViewHolder cellView, int c
public void onCellLongPressed(@NonNull RecyclerView.ViewHolder cellView, final int column,
int row) {
// Do What you want
showToast("Cell " + column + " " + row + " has been long pressed.");
showToast("onCellLongPressed" + getMessageContext(cellView, column, row));
}

/**
Expand All @@ -103,7 +116,7 @@ public void onCellLongPressed(@NonNull RecyclerView.ViewHolder cellView, final i
public void onColumnHeaderClicked(@NonNull RecyclerView.ViewHolder columnHeaderView, int
column) {
// Do what you want.
showToast("Column header " + column + " has been clicked.");
showToast("onColumnHeaderClicked" + getMessageContext(columnHeaderView, column, -1));
}

/**
Expand All @@ -115,7 +128,7 @@ public void onColumnHeaderClicked(@NonNull RecyclerView.ViewHolder columnHeaderV
@Override
public void onColumnHeaderDoubleClicked(@NonNull RecyclerView.ViewHolder columnHeaderView, int column) {
// Do what you want.
showToast("Column header " + column + " has been double clicked.");
showToast("onColumnHeaderDoubleClicked" + getMessageContext(columnHeaderView, column, -1));
}

/**
Expand All @@ -127,11 +140,12 @@ public void onColumnHeaderDoubleClicked(@NonNull RecyclerView.ViewHolder columnH
@Override
public void onColumnHeaderLongPressed(@NonNull RecyclerView.ViewHolder columnHeaderView, int
column) {
showToast("onColumnHeaderLongPressed" + getMessageContext(columnHeaderView, column, -1));

if (columnHeaderView instanceof ColumnHeaderViewHolder) {
// Create Long Press Popup
ColumnHeaderLongPressPopup popup = new ColumnHeaderLongPressPopup(
(ColumnHeaderViewHolder) columnHeaderView, mTableView);
(ColumnHeaderViewHolder) columnHeaderView, mTableView, column);
// Show
popup.show();
}
Expand All @@ -146,7 +160,7 @@ public void onColumnHeaderLongPressed(@NonNull RecyclerView.ViewHolder columnHea
@Override
public void onRowHeaderClicked(@NonNull RecyclerView.ViewHolder rowHeaderView, int row) {
// Do whatever you want.
showToast("Row header " + row + " has been clicked.");
showToast("onRowHeaderClicked" + getMessageContext(rowHeaderView, -1, row));
}

/**
Expand All @@ -158,7 +172,7 @@ public void onRowHeaderClicked(@NonNull RecyclerView.ViewHolder rowHeaderView, i
@Override
public void onRowHeaderDoubleClicked(@NonNull RecyclerView.ViewHolder rowHeaderView, int row) {
// Do whatever you want.
showToast("Row header " + row + " has been double clicked.");
showToast("onRowHeaderDoubleClicked" + getMessageContext(rowHeaderView, -1, row));
}

/**
Expand All @@ -169,15 +183,17 @@ public void onRowHeaderDoubleClicked(@NonNull RecyclerView.ViewHolder rowHeaderV
*/
@Override
public void onRowHeaderLongPressed(@NonNull RecyclerView.ViewHolder rowHeaderView, int row) {
showToast("onRowHeaderLongPressed" + getMessageContext(rowHeaderView, -1, row));

// Create Long Press Popup
RowHeaderLongPressPopup popup = new RowHeaderLongPressPopup(rowHeaderView, mTableView);
RowHeaderLongPressPopup popup = new RowHeaderLongPressPopup(rowHeaderView, mTableView, row);
// Show
popup.show();
}


private void showToast(String p_strMessage) {
Toast.makeText(mContext, p_strMessage, Toast.LENGTH_SHORT).show();
Log.d(this.getClass().getSimpleName(), p_strMessage);
Toast.makeText(mContext, p_strMessage, Toast.LENGTH_LONG).show();
}
}

This file was deleted.

Loading