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

fix(md-3800): autochart crash #127

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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