Skip to content

Commit

Permalink
fix: use same cell padding (#156)
Browse files Browse the repository at this point in the history
* fix: use same cell padding

* fix: cleanup
  • Loading branch information
gruskal committed Dec 1, 2022
1 parent d31f6b5 commit 3ce0604
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Expand Up @@ -33,8 +33,8 @@ public class CellView extends RelativeLayout implements SelectionsObserver {
final boolean isInFirstColumnRecyclerView;
final View.OnCreateContextMenuListener onCreateContextMenuListener;
GestureDetector gestureDetector;
int padding = (int)PixelUtils.dpToPx(16);
static int PADDING_X_2 = (int)PixelUtils.dpToPx(32);
static final int PADDING = TableTheme.CellPadding;
static final int PADDING_X_2 = TableTheme.CellPadding * 2;

@SuppressLint("ClickableViewAccessibility")
CellView(Context context, String type, SelectionsEngine selectionsEngine, TableView tableView, boolean isInFirstColumnRecyclerView, DataColumn dataColumn) {
Expand Down Expand Up @@ -75,7 +75,7 @@ private void createContent(String type, DataColumn dataColumn) {
switch (type) {
case "text":
ClickableTextView textView = new ClickableTextView(getContext(), selectionsEngine, tableView, this, dataColumn);
textView.setPadding(padding, 0, padding, 0);
textView.setPadding(PADDING, 0, PADDING, 0);
content = textView;
break;
case "image":
Expand All @@ -86,7 +86,7 @@ private void createContent(String type, DataColumn dataColumn) {
break;
case "miniChart":
content = new MiniChartView(getContext());
this.setPadding(padding, 0, padding, 0);
this.setPadding(PADDING, 0, PADDING, 0);
break;
}
}
Expand Down
Expand Up @@ -136,7 +136,7 @@ public HeaderText(Context context, DataColumn column, TableView tableView) {
this.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
textWrapper = new TextWrapper(column, tableView, this);
if(column.isDim) {
textWrapper.additionalPadding = (int)PixelUtils.dpToPx(16) * 5;
textWrapper.additionalPadding = TableTheme.CellPadding * 2;
}
this.setBackgroundColor(Color.TRANSPARENT);
this.setGravity(Gravity.CENTER_VERTICAL);
Expand Down
Expand Up @@ -60,7 +60,7 @@ public HeaderViewFactory(List<DataColumn> dataColumns, List<TotalsCell> totalsCe

public static HeaderCell buildFixedColumnCell(FrameLayout rootView, DataColumn column, TableView tableView, boolean topPosition) {
int headerHeight = tableView.headerHeight;
int padding = (int) PixelUtils.dpToPx(16);
int padding = TableTheme.CellPadding;

HeaderCell fixedFirstHeaderCell = new HeaderCell(rootView.getContext(), column, tableView);
TextView textView = fixedFirstHeaderCell.cell;
Expand Down Expand Up @@ -121,7 +121,7 @@ public static TotalsViewCell buildFixedTotalsCell(TableView tableView, DataColum
}

public static HeaderCell createHeaderCell(Context context, DataColumn column, HeaderContentStyle headerContentStyle, TableView tableView) {
int padding = CellView.PADDING_X_2;
int padding = TableTheme.CellPadding;
HeaderCell headerCell = new HeaderCell(context, column, tableView);
headerCell.setPadding(padding, 0, 0, 0);
TextView text = headerCell.cell;
Expand Down
Expand Up @@ -13,5 +13,6 @@ public class TableTheme {
static int borderBackgroundColor = Color.argb(0.1f, 0, 0, 0);
static int selectedBackground = Color.parseColor("#009845");
static Typeface iconFonts = null;
static int DefaultRowHeight =(int)PixelUtils.dpToPx(40);
static int CellPadding = (int)PixelUtils.dpToPx(8);
static int DefaultRowHeight = (int)PixelUtils.dpToPx(40);
}
Expand Up @@ -65,7 +65,7 @@ void measureLineCountNoUpdate() {
}

protected int calculateLineCount() {
int width = column.width - additionalPadding;
int width = column.width - additionalPadding;
measureTextPaint.setTypeface(textView.getTypeface());
StaticLayout.Builder builder = StaticLayout.Builder.obtain(textView.getText(), 0, textView.getText().length(), measureTextPaint, width);
builder.setIncludePad(true);
Expand Down

0 comments on commit 3ce0604

Please sign in to comment.