Cleveroad / Cleveroad/AdaptiveTableLayout

Table not updating with multiple textviews in item_card

未关闭
#30 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Java
星标
1.9k
派生
238
PR 合并指标
30 天内没有已合并 PR

描述

Hello,
I've wanted to display a table with 4 TextViews per item, but the table isn't getting updated when I use my modified version of EditItemDialog(to support the 4 TVs I mentioned above).
The data in the csv gets updated immediately, also if I switch to another fragment and back to the table-fragment, the data's displayed correctly!

How can I fix that?

Code handling EditItemDialog response(GH is bugging...):

`

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == EditItemDialog.REQUEST_CODE_EDIT_ITEM && resultCode == Activity.RESULT_OK && data != null) {
int columnIndex = data.getIntExtra(EditItemDialog.EXTRA_COLUMN_NUMBER, 0);
int rowIndex = data.getIntExtra(EditItemDialog.EXTRA_ROW_NUMBER, 0);
String s = data.getStringExtra(EditItemDialog.EXTRA_SUBJECT);
String t = data.getStringExtra(EditItemDialog.EXTRA_TEACHER);
String r = data.getStringExtra(EditItemDialog.EXTRA_ROOM);

// My attempts to update the layout:
mCsvFileDataSource.updateItem(rowIndex, columnIndex,
CsvFileDataSourceImpl.prepItem(s, t, r));
mTableAdapter.notifyItemChanged(rowIndex, columnIndex);
mTableLayout.notifyItemChanged(rowIndex, columnIndex);
mCsvFileDataSource.applyChanges(getLoaderManager(),
mTableLayout.getLinkedAdapterRowsModifications(),
mTableLayout.getLinkedAdapterColumnsModifications(),
mTableLayout.isSolidRowHeader(),
ScheduleFragment.this);
mTableLayout.setVisibility(View.GONE);
mTableLayout.setVisibility(View.VISIBLE);
//mTableLayout.invalidate();
onFileUpdated(StorageUtils.getScheduleFile(getActivity()).getAbsolutePath(), true); // .getScheduleFile() returns File object
}
}
`

`

public static String prepItem(String s, String t, String r) {
return s + ";" + t + ";" + r;
}

//...

public String getItemData(int rowIndex, int columnIndex, int position) { // helper method for schedule, splits item and returns data at position's index
try {
List rowList = getRow(rowIndex);
return (rowList == null ? "" : rowList.get(columnIndex)).split(";")[position];
} catch (Exception e) {
Log.e(TAG, "get rowIndex=" + rowIndex + "; colIndex=" + columnIndex + "; position:" + position + "\ncache = " +
mItemsCache.toString(), e);
return null;
}
}
`

Best regards,
Felipe

PS: Except for above issue, it works like a charm!

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先跟踪 schedule fragment 中的 onActivityResult,包括对 mTableAdapter、mTableLayout 和 onFileUpdated 的调用,然后检查 getItemData 如何为四个 TextViews 拆分更新后的 CSV 值。完成的标准是:编辑后的项目无需切换 fragment,就能立即刷新所有显示的 TextViews,同时 CSV 数据仍保持更新。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, java
领域
mobile
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。