Skip to content

Commit

Permalink
Parent RecyclerView of Cell Row Recyclerview didn't use to remeasure …
Browse files Browse the repository at this point in the history
…itself when it is necessary. This problem has been resolved. #24 issue has been fixed.
  • Loading branch information
evrencoskun committed Jan 21, 2018
1 parent 06edc9f commit 1c1723e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.evrencoskun.tableview.handler.VisibilityHandler;
import com.evrencoskun.tableview.layoutmanager.CellLayoutManager;
import com.evrencoskun.tableview.layoutmanager.ColumnHeaderLayoutManager;
import com.evrencoskun.tableview.listener.ColumnHeaderLayoutChangeListener;
import com.evrencoskun.tableview.listener.ITableViewListener;
import com.evrencoskun.tableview.listener.itemclick.ColumnHeaderRecyclerViewItemClickListener;
import com.evrencoskun.tableview.listener.itemclick.RowHeaderRecyclerViewItemClickListener;
Expand All @@ -36,6 +37,8 @@

public class TableView extends FrameLayout implements ITableView {

private static final String LOG_TAG = TableView.class.getSimpleName();

protected CellRecyclerView m_jCellRecyclerView;
protected CellRecyclerView m_jColumnHeaderRecyclerView;
protected CellRecyclerView m_jRowHeaderRecyclerView;
Expand Down Expand Up @@ -190,6 +193,11 @@ protected void initializeListeners() {
(m_jColumnHeaderRecyclerViewItemClickListener);
m_jRowHeaderRecyclerView.addOnItemTouchListener(m_jRowHeaderRecyclerViewItemClickListener);


//Add Layout change listener to Column Header recyclerView to detect changing size
m_jColumnHeaderRecyclerView.addOnLayoutChangeListener(new
ColumnHeaderLayoutChangeListener(this));

}

protected CellRecyclerView createColumnHeaderRecyclerView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.evrencoskun.tableview.listener.scroll.HorizontalRecyclerViewListener;
import com.evrencoskun.tableview.util.TableViewUtils;

import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

/**
* Created by evrencoskun on 24/06/2017.
*/
Expand Down Expand Up @@ -431,4 +433,13 @@ public AbstractViewHolder getCellViewHolder(int p_nXPosition, int p_nYPosition)
return null;
}

public void remeasureAllChild() {
for (int j = 0; j < getChildCount(); j++) {
CellRecyclerView recyclerView = (CellRecyclerView) getChildAt(j);

recyclerView.getLayoutParams().width = WRAP_CONTENT;
recyclerView.requestLayout();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.evrencoskun.tableview.listener;

import android.view.View;

import com.evrencoskun.tableview.ITableView;
import com.evrencoskun.tableview.adapter.recyclerview.CellRecyclerView;
import com.evrencoskun.tableview.layoutmanager.CellLayoutManager;

/**
* Created by evrencoskun on 21.01.2018.
*/

public class ColumnHeaderLayoutChangeListener implements View.OnLayoutChangeListener {

private CellRecyclerView mCellRecyclerView;
private CellRecyclerView mColumnHeaderRecyclerView;
private CellLayoutManager mCellLayoutManager;

public ColumnHeaderLayoutChangeListener(ITableView tableView) {
this.mCellRecyclerView = tableView.getCellRecyclerView();
this.mColumnHeaderRecyclerView = tableView.getColumnHeaderRecyclerView();
this.mCellLayoutManager = tableView.getCellLayoutManager();
}

@Override
public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6,
int i7) {
if (mCellRecyclerView.isShown() && mColumnHeaderRecyclerView.getWidth() >
mCellRecyclerView.getWidth()) {

// Remeasure all nested CellRow recyclerViews
mCellLayoutManager.remeasureAllChild();
}
}
}

0 comments on commit 1c1723e

Please sign in to comment.