Skip to content

Commit

Permalink
fix: autochart crash (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruskal committed Nov 10, 2022
1 parent 3006905 commit dfe208a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Expand Up @@ -87,7 +87,7 @@ private int resizeColumnByAverage(DataColumn column, List<DataRow> rows) {
Paint paint = new Paint();
for(DataRow row : rows) {
if (row != null) {
String text = row.cells.get(column.dataColIdx).qText;
String text = row.cells.get(column.columnIndex).qText;
if(text != null) {
runningTotal += text.length();
}
Expand Down
Expand Up @@ -18,6 +18,7 @@ public class DataColumn {

public Boolean isDim = false;
public int width = 0;
public int columnIndex = 0;
public String label;
public String id;
public String sortDirection;
Expand All @@ -28,7 +29,7 @@ public class DataColumn {
public boolean active = false;
public int textAlignment = Gravity.LEFT;
public int rowHeight = TableTheme.rowHeightFactor;
public DataColumn(ReadableMap source) {
public DataColumn(ReadableMap source, int index) {
ReadableMap representationMap = source.getMap("representation");
representation = new Representation(representationMap);
stylingInfo = source.getArray("stylingInfo").toArrayList();
Expand All @@ -38,6 +39,7 @@ public DataColumn(ReadableMap source) {
id = source.getString("id");
sortDirection = source.getString("sortDirection");
dataColIdx = source.getInt("dataColIdx");
columnIndex = index;
if (source.hasKey("active")) {
active = source.getBoolean("active");
}
Expand Down
Expand Up @@ -318,7 +318,7 @@ public void invalidateLayout() {
for(DataColumn column : dataColumns) {
for (RecyclerView.ViewHolder holder : cachedViewHolders) {
RowViewHolder viewHolder = (RowViewHolder) holder;
viewHolder.setWidth(column.width, column.dataColIdx);
viewHolder.setWidth(column.width, column.columnIndex);
}
}
this.notifyDataSetChanged();
Expand Down
Expand Up @@ -83,7 +83,7 @@ public void setCols(View view, @Nullable ReadableMap source) {

List<DataColumn> dataColumns = new ArrayList<>();
for(int i = 0; i < columns.size(); i++) {
DataColumn column = new DataColumn(columns.getMap(i));
DataColumn column = new DataColumn(columns.getMap(i), i);
dataColumns.add(column);
}
tableView.setDataColumns(dataColumns);
Expand Down
Expand Up @@ -168,7 +168,7 @@ private void checkNeighbourTextWrap(int column) {

private void checkTextWrap(DataColumn dataColumn) {
if(dataColumn.isDim && dataColumn.isText() ) {
CellView cellView = (CellView) row.getChildAt(dataColumn.dataColIdx);
CellView cellView = (CellView) row.getChildAt(dataColumn.columnIndex);
ClickableTextView textView = (ClickableTextView)cellView.content;
textView.testTextWrap(dataColumn);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ private boolean updateNeighbour(float deltaWidth, int column) {
}

public int getLineCount(DataColumn column) {
CellView cellView = (CellView) row.getChildAt(column.dataColIdx);
CellView cellView = (CellView) row.getChildAt(column.columnIndex);
ClickableTextView textView = (ClickableTextView) cellView.content;
return textView.getMeasuredLineCount();
}
Expand All @@ -220,7 +220,7 @@ public int initialMeasure() {
int maxLines = 0;
for (DataColumn column: dataProvider.dataColumns) {
if(column.isText() && column.isDim) {
CellView cellView = (CellView) row.getChildAt(column.dataColIdx);
CellView cellView = (CellView) row.getChildAt(column.columnIndex);
if(cellView != null) {
ClickableTextView clickableTextView = (ClickableTextView) cellView.content;
maxLines = Math.max(clickableTextView.measureLines(column), maxLines);
Expand All @@ -235,8 +235,8 @@ public void initializeHeight(int rowHeight) {

for (DataColumn column: dataProvider.dataColumns) {
if(column.isText() && column.isDim) {
if(column.dataColIdx < row.getChildCount()) {
CellView cellView = (CellView) row.getChildAt(column.dataColIdx);
if(column.columnIndex < row.getChildCount()) {
CellView cellView = (CellView) row.getChildAt(column.columnIndex);
ClickableTextView clickableTextView = (ClickableTextView) cellView.content;
clickableTextView.setMaxLines(lines);
clickableTextView.setGravity(column.textAlignment | Gravity.CENTER_VERTICAL);
Expand Down
Expand Up @@ -14,6 +14,7 @@ public class SearchButton extends androidx.appcompat.widget.AppCompatImageButton
final TableView tableView;
final int defaultColor = Color.TRANSPARENT;
final int pressedColor = Color.parseColor("#595959");
final int textColor = Color.parseColor("#404040");

public SearchButton(Context context, TableView tableView, DataColumn column) {
super(context);
Expand All @@ -37,7 +38,7 @@ public void handleTouchDown(){
public void handleTouchUp(){
this.setBackgroundColor(defaultColor);

icon.setTint(Color.BLACK);
icon.setTint(textColor);
this.setImageDrawable(icon);
}

Expand Down

0 comments on commit dfe208a

Please sign in to comment.