Skip to content

Commit

Permalink
修复删除时crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen2018 committed Jun 21, 2019
1 parent 0a20b66 commit d9a5a10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ private void toast(String content) {
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt1:
yList.add("3");
xList.add("3");
break;
case R.id.bt2:
yList.remove(0);
xList.remove(0);
break;
case R.id.bt3:
yList.set(xList.size()-1,"5");
xList.set(xList.size()-1,"5");
break;
}
railLineTableAdapter.notifyChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ protected View getViewByLayoutId(Context context,int layoutId){
}

public void addDataColumn(List<View> viewList, View xItemView) {
if(isRemoveXClear){
if(getTableView().isHideY()) {
getTableView().getGridLayoutXY().setVisibility(View.VISIBLE);
getTableView().getGridLayoutY().setVisibility(View.VISIBLE);
}
getTableView().getGridLayoutX().setVisibility(View.VISIBLE);
getTableView().getGridLayoutTable().setVisibility(View.VISIBLE);
isRemoveXClear = false;
return;
}
tableView.getGridLayoutTable().removeAllViews();
tableView.getMapItemViews().clear();
tableView.setItemCount(0);
Expand Down Expand Up @@ -182,16 +172,6 @@ public void addDataColumn(List<View> viewList, View xItemView) {
}

public void addDataRow(List<View> viewList, View yItemView) {
if(isRemoveYClear){
if(!getTableView().isHidenX()) {
getTableView().getGridLayoutXY().setVisibility(View.VISIBLE);
getTableView().getGridLayoutX().setVisibility(View.VISIBLE);
}
getTableView().getGridLayoutY().setVisibility(View.VISIBLE);
getTableView().getGridLayoutTable().setVisibility(View.VISIBLE);
isRemoveYClear = false;
return;
}
tableView.getGridLayoutTable().removeAllViews();
tableView.getMapItemViews().clear();
tableView.setItemCount(0);
Expand All @@ -209,6 +189,7 @@ public void addDataRow(List<View> viewList, View yItemView) {

//处理列
List<TableItemView> tableItemViewListColumn = tableView.getMapColumn().get(i);
Log.e("列数",i+"");
tableItemViewListColumn.add(tableItemView);
}
tableView.setRowNumber(tableView.getRowNumber() + 1);
Expand Down Expand Up @@ -266,22 +247,13 @@ public void updateRowData(int row, UpdateDataCallback updateDataCallback) {
}

protected void removeRow(int row) {
if(getTableView().getRowNumber() == 1){
if(!getTableView().isHidenX()){
getTableView().getGridLayoutX().setVisibility(View.GONE);
getTableView().getGridLayoutXY().setVisibility(View.GONE);
}
getTableView().getGridLayoutY().setVisibility(View.GONE);
getTableView().getGridLayoutTable().setVisibility(View.GONE);
isRemoveYClear = true;
return;
}
if ((!(row >= 0 && row <= tableView.getMapRow().size() - 1)) || getTableView().getRowNumber()<=0) {
return;
}
tableView.getGridLayoutTable().removeAllViews();
tableView.getMapItemViews().clear();
tableView.getGridLayoutY().removeAllViews();
if(getTableView().getRowNumber() > 1)
getTableView().getMapColumn().clear();
tableView.setItemCount(0);
//移除掉行集合中的此行
Expand Down Expand Up @@ -360,16 +332,12 @@ protected void removeRow(int row) {
}
}
getTableView().setRowNumber(getTableView().getRowNumber() - 1);
Log.e("列的个数",getTableView().getMapColumn().size()+"");
}

protected void removeColumn(int column) {
if(getTableView().getColumnNumber() == 1){
if(!getTableView().isHideY()){
getTableView().getGridLayoutY().setVisibility(View.GONE);
getTableView().getGridLayoutXY().setVisibility(View.GONE);
}
getTableView().getGridLayoutX().setVisibility(View.GONE);
getTableView().getGridLayoutTable().setVisibility(View.GONE);
getTableView().setVisibility(View.GONE);
isRemoveXClear = true;
return;
}
Expand Down

0 comments on commit d9a5a10

Please sign in to comment.