Skip to content

Commit

Permalink
fix: missing row & update mock scroll on totals update (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruskal committed Dec 7, 2022
1 parent 503b569 commit 7279816
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Expand Up @@ -138,13 +138,11 @@ public boolean updateWidth(float deltaWidth, int column) {
int currentWidth = dataProvider.dataColumns.get(column).width;
float newWidth = currentWidth + deltaWidth;

if(newWidth < dataProvider.minWidth) {
if(newWidth < DataProvider.minWidth) {
return false;
}

if (!updateNeighbour(deltaWidth, column)) {
return false;
}
updateNeighbour(deltaWidth, column);
ViewGroup.LayoutParams params = view.getLayoutParams();
params.width = (int) newWidth;
view.setLayoutParams(params);
Expand Down
Expand Up @@ -99,13 +99,21 @@ private void setMockScrollLayouts() {
FrameLayout.LayoutParams verticalFrameLayout = new FrameLayout.LayoutParams((int) PixelUtils.dpToPx(5), FrameLayout.LayoutParams.MATCH_PARENT);
verticalFrameLayout.gravity = Gravity.RIGHT;
int headerHeight = headerView.getMeasuredHeight() > 0 ? headerView.getMeasuredHeight() : tableView.headerHeight;
verticalFrameLayout.topMargin = headerHeight + extraTopMargin;
verticalFrameLayout.bottomMargin = TableTheme.DefaultRowHeight + extraBottomMargin;
int extraTop = 0;
int extraBottom = 0;
if (tableView.totalsPosition.equals("top")) {
extraTop = tableView.totalsHeight;
} else if(tableView.totalsPosition.equals("bottom")) {
extraBottom = tableView.totalsHeight;
}

verticalFrameLayout.topMargin = headerHeight + extraTop;
verticalFrameLayout.bottomMargin = TableTheme.DefaultRowHeight + extraBottom;
verticalScrollBar.setLayoutParams(verticalFrameLayout);

FrameLayout.LayoutParams horizontalFrameLayout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, (int) PixelUtils.dpToPx(5));
horizontalFrameLayout.gravity = Gravity.BOTTOM;
horizontalFrameLayout.bottomMargin = TableTheme.DefaultRowHeight;
horizontalFrameLayout.bottomMargin = tableView.totalsHeight;
horizontalFrameLayout.rightMargin = (int) PixelUtils.dpToPx(25);

horizontalScrollView.setLayoutParams(horizontalFrameLayout);
Expand Down Expand Up @@ -172,7 +180,6 @@ protected void createRecyclerViews() {
CustomLinearLayoutManger linearLayout = new CustomLinearLayoutManger(context);
coupledRecyclerView = new CustomRecyclerView(context, false, dataProvider, tableView, linearLayout, dragBox, firstColumnDragBox);
FrameLayout.LayoutParams recyclerViewLayoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
coupledRecyclerView.setLayoutParams(recyclerViewLayoutParams);
CustomLinearLayoutManger firstColumnLinearLayout = new CustomLinearLayoutManger(context);
firstColumnRecyclerView = new CustomRecyclerView(context, true, dataProvider, tableView, firstColumnLinearLayout, dragBox, firstColumnDragBox);
coupledRecyclerView.setZ(0);
Expand All @@ -185,6 +192,7 @@ protected void createRecyclerViews() {
coupledRecyclerView.setAdapter(dataProvider);

recyclerViewLayoutParams.topMargin = marginTop;
coupledRecyclerView.setLayoutParams(recyclerViewLayoutParams);
rootLayout.addView(coupledRecyclerView, recyclerViewLayoutParams);

firstColumnLinearLayout.recyclerView = firstColumnRecyclerView;
Expand Down Expand Up @@ -387,8 +395,11 @@ public void updateHeaderViewLineCount() {
headerView.setLayoutParams(params);
FrameLayout.LayoutParams recyclerParams = (FrameLayout.LayoutParams) coupledRecyclerView.getLayoutParams();
recyclerParams.topMargin = headerHeight;

if(headerViewFactory.topPosition && totalsView != null) {
recyclerParams.topMargin += tableView.totalsHeight;
} else if(!headerViewFactory.topPosition && totalsView != null) {
recyclerParams.bottomMargin = tableView.totalsHeight;
}
coupledRecyclerView.setLayoutParams(recyclerParams);

Expand Down

0 comments on commit 7279816

Please sign in to comment.