Skip to content

Commit 3f5bf86

Browse files
author
Ingo Schwarz
committed
Merge branch 'develop'
2 parents add5808 + 44614aa commit 3f5bf86

File tree

8 files changed

+38
-42
lines changed

8 files changed

+38
-42
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ An Android library providing a TableView and a SortableTableView.
44

55
![SortableTableView Example](https://raw.githubusercontent.com/ISchwarz23/SortableTableView/develop/README/SortableTableView-Example.gif)
66

7-
**Minimum SDK-Version:** 11 | **Compile SDK-Version:** 23 | **Latest Library Version:** 1.1.1
7+
**Minimum SDK-Version:** 11 | **Compile SDK-Version:** 23 | **Latest Library Version:** 2.0.0
88

99
## Repository Content
1010
**tableview** - contains the android library sources and resources
@@ -17,7 +17,7 @@ To use the this library in your project simply add the following dependency to y
1717
```
1818
dependencies {
1919
...
20-
compile 'de.codecrafters.tableview:tableview:1.1.1'
20+
compile 'de.codecrafters.tableview:tableview:2.0.0'
2121
...
2222
}
2323
```
@@ -32,7 +32,7 @@ The provided TableView is very easy to adapt to your needs. To set the column co
3232
android:id="@+id/tableView"
3333
android:layout_width="match_parent"
3434
android:layout_height="match_parent"
35-
table:columnCount="4" />
35+
table:tableView_columnCount="4" />
3636
```
3737
A second possibility to define the column count of your TableView is to set it directly in the code.
3838
```java
@@ -183,7 +183,7 @@ The table view provides several possibilities to style its header. One possibili
183183
android:id="@+id/tableView"
184184
android:layout_width="match_parent"
185185
android:layout_height="match_parent"
186-
table:headerColor="@color/primary" />
186+
table:tableView_headerColor="@color/primary" />
187187
```
188188
```java
189189
tableView.setHeaderBackgroundColor(getResources().getColor(R.color.primary));
@@ -199,7 +199,7 @@ In addition you can set an **elevation** of the table header. To achieve this yo
199199
android:id="@+id/tableView"
200200
android:layout_width="match_parent"
201201
android:layout_height="match_parent"
202-
table:headerElevation="10" />
202+
table:tableView_headerElevation="10" />
203203
```
204204
```java
205205
tableView.setHeaderElevation(10);
@@ -213,7 +213,7 @@ For SortableTableViews it is also possible to replace the default **sortable ind
213213
super.onCreate(savedInstanceState);
214214
setContentView(R.layout.activity_main);
215215
// ...
216-
sortbaleTableView.setHeaderSortStateViewProvider(new MySortStateViewProvider());
216+
sortableTableView.setHeaderSortStateViewProvider(new MySortStateViewProvider());
217217
}
218218

219219
private static class MySortStateViewProvider implements SortStateViewProvider {
@@ -248,7 +248,7 @@ This Factory contains for example an alternating-table-data-row colorizer that w
248248
// ...
249249
int colorEvenRows = getResources().getColor(R.color.white);
250250
int colorOddRows = getResources().getColor(R.color.gray);
251-
tableView.setDataRowColoriser(TableDataRowColorizers.alternatingRows(colorEvenRows, colorOddRows));
251+
tableView.setDataRowColorizer(TableDataRowColorizers.alternatingRows(colorEvenRows, colorOddRows));
252252
}
253253
```
254254
If the implementations of `TableDataRowColorizer` contained in the `TableDataRowColorizers` factory don't fulfil you needs you can create your own implementation of `TableDataRowColorizer`. Here is a small example of how to do so.
@@ -258,7 +258,7 @@ If the implementations of `TableDataRowColorizer` contained in the `TableDataRow
258258
super.onCreate(savedInstanceState);
259259
setContentView(R.layout.activity_main);
260260
// ...
261-
tableView.setDataRowColoriser(new CarPriceRowColorizer());
261+
tableView.setDataRowColorizer(new CarPriceRowColorizer());
262262
}
263263

264264
private static class CarPriceRowColorizer implements TableDataRowColorizer<Car> {

app/src/main/java/de/codecrafters/tableviewexample/SortableCarTableView.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
import android.content.Context;
44
import android.util.AttributeSet;
5-
import android.widget.Toast;
6-
7-
import java.util.Comparator;
85

96
import de.codecrafters.tableview.SortableTableView;
10-
import de.codecrafters.tableview.listeners.TableDataClickListener;
117
import de.codecrafters.tableview.toolkit.SimpleTableHeaderAdapter;
128
import de.codecrafters.tableview.toolkit.SortStateViewProviders;
139
import de.codecrafters.tableview.toolkit.TableDataRowColorizers;
@@ -35,7 +31,7 @@ public SortableCarTableView(Context context, AttributeSet attributes, int styleA
3531

3632
int rowColorEven = context.getResources().getColor(R.color.table_data_row_even);
3733
int rowColorOdd = context.getResources().getColor(R.color.table_data_row_odd);
38-
setDataRowColoriser(TableDataRowColorizers.alternatingRows(rowColorEven, rowColorOdd));
34+
setDataRowColorizer(TableDataRowColorizers.alternatingRows(rowColorEven, rowColorOdd));
3935
setHeaderSortStateViewProvider(SortStateViewProviders.brightArrows());
4036

4137
setColumnWeight(0, 2);

app/src/main/res/layout/activity_main.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
android:layout_width="match_parent"
1919
android:layout_height="match_parent"
2020
android:layout_below="@id/toolbar"
21-
custom:columnCount="4"
22-
custom:headerElevation="10"
23-
custom:headerColor="@color/primary" />
21+
custom:tableView_columnCount="4"
22+
custom:tableView_headerElevation="10"
23+
custom:tableView_headerColor="@color/primary" />
2424

2525
</RelativeLayout>

tableview/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'com.android.library'
22

3-
def final tableViewLibraryVersion = '1.1.1'
3+
def final tableViewLibraryVersion = '2.0.0'
44

55
ext {
66
bintrayRepo = 'maven'
@@ -34,7 +34,7 @@ android {
3434
defaultConfig {
3535
minSdkVersion 11
3636
targetSdkVersion 23
37-
versionCode 9
37+
versionCode 10
3838
versionName tableViewLibraryVersion
3939
}
4040
buildTypes {

tableview/src/main/java/de/codecrafters/tableview/TableDataAdapter.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class TableDataAdapter<T> extends ArrayAdapter<T> {
3232

3333
private TableColumnModel columnModel;
3434
private final List<T> data;
35-
private TableDataRowColorizer<? super T> rowColoriser;
35+
private TableDataRowColorizer<? super T> rowColorizer;
3636

3737

3838
/**
@@ -159,7 +159,7 @@ public final View getView(final int rowIndex, final View convertView, final View
159159
Log.w(LOG_TAG, "No row date available for row with index " + rowIndex + ". " +
160160
"Caught Exception: " + e.getMessage());
161161
}
162-
rowView.setBackgroundColor(rowColoriser.getRowColor(rowIndex, rowData));
162+
rowView.setBackgroundColor(rowColorizer.getRowColor(rowIndex, rowData));
163163

164164
final int widthUnit = (parent.getWidth() / columnModel.getColumnWeightSum());
165165

@@ -181,13 +181,13 @@ public final View getView(final int rowIndex, final View convertView, final View
181181
}
182182

183183
/**
184-
* Sets the {@link TableDataRowColorizer} that will be used to colorise the table data rows.
184+
* Sets the {@link TableDataRowColorizer} that will be used to colorize the table data rows.
185185
*
186186
* @param rowColorizer
187187
* The {@link TableDataRowColorizer} that shall be used.
188188
*/
189-
protected void setRowColoriser(final TableDataRowColorizer<? super T> rowColorizer) {
190-
this.rowColoriser = rowColorizer;
189+
protected void setRowColorizer(final TableDataRowColorizer<? super T> rowColorizer) {
190+
this.rowColorizer = rowColorizer;
191191
}
192192

193193
/**

tableview/src/main/java/de/codecrafters/tableview/TableView.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class TableView<T> extends LinearLayout {
4545
private TableHeaderView tableHeaderView;
4646
private ListView tableDataView;
4747
private TableHeaderAdapter tableHeaderAdapter;
48-
private TableDataRowColorizer<? super T> dataRowColoriser = TableDataRowColorizers.similarRowColor(0x00000000);
48+
private TableDataRowColorizer<? super T> dataRowColorizer = TableDataRowColorizers.similarRowColor(0x00000000);
4949

5050
private int headerElevation;
5151
private int headerColor;
@@ -151,12 +151,12 @@ public void setHeaderElevation(final int elevation) {
151151
* Sets the given {@link TableDataRowColorizer} that will be used to define the background color for
152152
* every table data row.
153153
*
154-
* @param coloriser
154+
* @param colorizer
155155
* The {@link TableDataRowColorizer} that shall be used.
156156
*/
157-
public void setDataRowColoriser(final TableDataRowColorizer<? super T> coloriser) {
158-
dataRowColoriser = coloriser;
159-
tableDataAdapter.setRowColoriser(coloriser);
157+
public void setDataRowColorizer(final TableDataRowColorizer<? super T> colorizer) {
158+
dataRowColorizer = colorizer;
159+
tableDataAdapter.setRowColorizer(colorizer);
160160
}
161161

162162
/**
@@ -239,7 +239,7 @@ public TableDataAdapter<T> getDataAdapter() {
239239
public void setDataAdapter(final TableDataAdapter<T> dataAdapter) {
240240
tableDataAdapter = dataAdapter;
241241
tableDataAdapter.setColumnModel(columnModel);
242-
tableDataAdapter.setRowColoriser(dataRowColoriser);
242+
tableDataAdapter.setRowColorizer(dataRowColorizer);
243243
tableDataView.setAdapter(tableDataAdapter);
244244
forceRefresh();
245245
}
@@ -307,9 +307,9 @@ private void forceRefresh() {
307307
private void setAttributes(final AttributeSet attributes) {
308308
final TypedArray styledAttributes = getContext().obtainStyledAttributes(attributes, R.styleable.TableView);
309309

310-
headerColor = styledAttributes.getInt(R.styleable.TableView_headerColor, DEFAULT_HEADER_COLOR);
311-
headerElevation = styledAttributes.getInt(R.styleable.TableView_headerElevation, DEFAULT_HEADER_ELEVATION);
312-
final int columnCount = styledAttributes.getInt(R.styleable.TableView_columnCount, DEFAULT_COLUMN_COUNT);
310+
headerColor = styledAttributes.getInt(R.styleable.TableView_tableView_headerColor, DEFAULT_HEADER_COLOR);
311+
headerElevation = styledAttributes.getInt(R.styleable.TableView_tableView_headerElevation, DEFAULT_HEADER_ELEVATION);
312+
final int columnCount = styledAttributes.getInt(R.styleable.TableView_tableView_columnCount, DEFAULT_COLUMN_COUNT);
313313
columnModel = new TableColumnModel(columnCount);
314314

315315
styledAttributes.recycle();
@@ -334,7 +334,7 @@ private void setupTableDataView(final AttributeSet attributes, final int styleAt
334334
} else {
335335
tableDataAdapter = new DefaultTableDataAdapter(getContext());
336336
}
337-
tableDataAdapter.setRowColoriser(dataRowColoriser);
337+
tableDataAdapter.setRowColorizer(dataRowColorizer);
338338

339339
tableDataView = new ListView(getContext(), attributes, styleAttributes);
340340
tableDataView.setOnItemClickListener(new InternalDataClickListener());

tableview/src/main/java/de/codecrafters/tableview/toolkit/TableDataRowColorizers.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@
1111
public final class TableDataRowColorizers {
1212

1313
/**
14-
* Gives an implementation of {link TableDataRowColoriser} that will return the given color
14+
* Gives an implementation of {@link TableDataRowColorizer} that will return the given color
1515
* for every row.
1616
*
1717
* @param color
1818
* The color that shall be applied to every table data row.
19-
* @return The described {link TableDataRowColoriser}.
19+
* @return The described {@link TableDataRowColorizer}.
2020
*/
2121
public static TableDataRowColorizer<Object> similarRowColor(final int color) {
2222
return new SimpleTableDataRowColorizer(color);
2323
}
2424

2525
/**
26-
* Gives an implementation of {link TableDataRowColoriser} that will return alternately the two
26+
* Gives an implementation of {@link TableDataRowColorizer} that will return alternately the two
2727
* given colors.
2828
*
2929
* @param colorEvenRows
3030
* The color that will be returned for rows with an even index.
3131
* @param colorOddRows
3232
* The color that will be returned for rows with an odd index.
33-
* @return The described {link TableDataRowColoriser}.
33+
* @return The described {@link TableDataRowColorizer}.
3434
*/
3535
public static TableDataRowColorizer<Object> alternatingRows(final int colorEvenRows, final int colorOddRows) {
3636
return new AlternatingTableDataRowColorizer(colorEvenRows, colorOddRows);
3737
}
3838

3939

4040
/**
41-
* An implementation of {link TableDataRowColoriser} that will return the given color
41+
* An implementation of {@link TableDataRowColorizer} that will return the given color
4242
* for every row.
4343
*
4444
* @author ISchwarz
@@ -58,7 +58,7 @@ public int getRowColor(final int rowIndex, final Object rowData) {
5858
}
5959

6060
/**
61-
* An implementation of {link TableDataRowColoriser} that will return alternately the two
61+
* An implementation of {@link TableDataRowColorizer} that will return alternately the two
6262
* given colors.
6363
*
6464
* @author ISchwarz
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<declare-styleable name="TableView">
4-
<attr name="columnCount" format="integer"/>
5-
<attr name="headerElevation" format="integer"/>
6-
<attr name="headerColor" format="color"/>
4+
<attr name="tableView_columnCount" format="integer"/>
5+
<attr name="tableView_headerElevation" format="integer"/>
6+
<attr name="tableView_headerColor" format="color"/>
77
</declare-styleable>
88
</resources>
99

0 commit comments

Comments
 (0)