From f7785c97aa2696ab1c2410c24b9ebdbcd91c2e3a Mon Sep 17 00:00:00 2001 From: evrencoskun Date: Sun, 26 Nov 2017 13:05:52 +0300 Subject: [PATCH] Sample app model ids has been changed to be prepared for sorting process. --- app/build.gradle | 1 + .../tableviewsample/MainFragment.java | 17 ++++++++----- .../tableviewsample/tableview/model/Cell.java | 24 +++++++++---------- .../tableview/model/ColumnHeader.java | 8 +++---- .../tableview/model/RowHeader.java | 8 +++---- tableview/build.gradle | 2 +- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3638a944..93abe526 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,6 +10,7 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } buildTypes { release { diff --git a/app/src/main/java/com/evrencoskun/tableviewsample/MainFragment.java b/app/src/main/java/com/evrencoskun/tableviewsample/MainFragment.java index eb49f209..1f2716fa 100644 --- a/app/src/main/java/com/evrencoskun/tableviewsample/MainFragment.java +++ b/app/src/main/java/com/evrencoskun/tableviewsample/MainFragment.java @@ -71,7 +71,6 @@ private TableView createTableView() { // Set adapter m_iTableViewAdapter = new TableViewAdapter(getContext()); - //m_iTableViewAdapter = new MDTableViewAdapter(getContext()); tableView.setAdapter(m_iTableViewAdapter); // Set layout params @@ -113,7 +112,7 @@ private void loadData() { private List getRowHeaderList() { List list = new ArrayList<>(); for (int i = 0; i < ROW_SIZE; i++) { - RowHeader header = new RowHeader(i, "row " + i); + RowHeader header = new RowHeader(String.valueOf(i), "row " + i); list.add(header); } @@ -128,7 +127,7 @@ private List getColumnHeaderList() { if (i % 6 == 2) { strTitle = "large column " + i; } - ColumnHeader header = new ColumnHeader(i, strTitle); + ColumnHeader header = new ColumnHeader(String.valueOf(i), strTitle); list.add(header); } @@ -144,7 +143,8 @@ private List getRandomColumnHeaderList() { if (nRandom % 4 == 0 || nRandom % 3 == 0 || nRandom == i) { strTitle = "large column " + i; } - ColumnHeader header = new ColumnHeader(i, strTitle); + + ColumnHeader header = new ColumnHeader(String.valueOf(i), strTitle); list.add(header); } @@ -160,7 +160,9 @@ private List> getCellList() { if (j % 4 == 0 && i % 5 == 0) { strText = "large cell " + j + " " + i + "."; } - Cell cell = new Cell(j, strText); + String strID = j + "-" + i; + + Cell cell = new Cell(strID, strText); cellList.add(cell); } list.add(cellList); @@ -180,7 +182,10 @@ private List> getRandomCellList() { if (nRandom % 2 == 0 || nRandom % 5 == 0 || nRandom == j) { strText = "large cell " + j + " " + i + getRandomString() + "."; } - Cell cell = new Cell(j, strText); + + String strID = j + "-" + i; + + Cell cell = new Cell(strID, strText); cellList.add(cell); } } diff --git a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/Cell.java b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/Cell.java index b2565d8b..9a53aa73 100644 --- a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/Cell.java +++ b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/Cell.java @@ -6,29 +6,29 @@ public class Cell { - private long m_nId; - private String m_nData; + private String m_strId; + private String m_strData; - public Cell(long p_nId) { - this(p_nId, ""); + public Cell(String p_strId) { + this.m_strId = p_strId; + this.m_strData = ""; } - public Cell(long p_nId, String p_strData) { - this.m_nId = p_nId; - this.m_nData = p_strData; + public Cell(String p_strId, String p_strData) { + this.m_strId = p_strId; + this.m_strData = p_strData; } - public long getId() { - return m_nId; + public String getId() { + return m_strId; } public String getData() { - return m_nData; + return m_strData; } public void setData(String p_strData) { - m_nData = p_strData; + m_strData = p_strData; } - } diff --git a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/ColumnHeader.java b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/ColumnHeader.java index 6a610bc8..5f56c6de 100644 --- a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/ColumnHeader.java +++ b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/ColumnHeader.java @@ -6,12 +6,12 @@ public class ColumnHeader extends Cell { - public ColumnHeader(int p_nId) { - super(p_nId); + public ColumnHeader(String p_strId) { + super(p_strId); } - public ColumnHeader(int p_nId, String p_strData) { - super(p_nId, p_strData); + public ColumnHeader(String p_strId, String p_strData) { + super(p_strId, p_strData); } } diff --git a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/RowHeader.java b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/RowHeader.java index 6a4bbea3..f63d8e4c 100644 --- a/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/RowHeader.java +++ b/app/src/main/java/com/evrencoskun/tableviewsample/tableview/model/RowHeader.java @@ -6,11 +6,11 @@ public class RowHeader extends Cell { - public RowHeader(int p_nId) { - super(p_nId); + public RowHeader(String p_strId) { + super(p_strId); } - public RowHeader(int p_nId, String p_strData) { - super(p_nId, p_strData); + public RowHeader(String p_strId, String p_strData) { + super(p_strId, p_strData); } } diff --git a/tableview/build.gradle b/tableview/build.gradle index 6303a58c..b153fc94 100644 --- a/tableview/build.gradle +++ b/tableview/build.gradle @@ -38,7 +38,7 @@ publish { userOrg = 'evrencoskun'//user name of bintray.com groupId = 'com.evrencoskun.library'//jcenter's url artifactId = 'tableview'//project name - publishVersion = '0.8.2'//version code + publishVersion = '0.8.3'//version code desc = 'TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.' website = 'https://github.com/evrencoskun/TableView'//website } \ No newline at end of file