smartTable icon indicating copy to clipboard operation
smartTable copied to clipboard

请问注解模式下,怎么给column设置format

Open clj12081103 opened this issue 6 years ago • 3 comments

从服务器请求到数据后:

smartTable.setData(list) 

val transferStatusColumn = smartTable.tableData.getColumnByFieldName("transferStatus")
transferStatusColumn.format = IFormat<String> {
            when (it) {
                "transfer" -> "成功汇出"
                "transferPending" -> "等待汇出"
                "unTransfer" -> "未汇出"
                "transferRejected" -> "汇出失败"
                else -> "unknown"
            }
        } as IFormat<Any>

我这样设置,第一次进activity的时候没问题,退出activity第二次再进就会报transferStatusColumn must not be null错

clj12081103 avatar May 17 '19 06:05 clj12081103

public void notifyDataChanged() {

        if (tableData != null) {
            config.setPaint(paint);
            //开启线程
            isNotifying.set(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    //long start = System.currentTimeMillis();
                    parser.parse(tableData);
                    TableInfo info = measurer.measure(tableData, config);
                    xAxis.setHeight(info.getTopHeight());
                    yAxis.setWidth(info.getyAxisWidth());
                    requestReMeasure();
                    postInvalidate();
                    isNotifying.set(false);
                    //long end = System.currentTimeMillis();
                    //Log.e("smartTable","notifyDataChanged timeMillis="+(end-start));
                }

            }).start();

        }
    }

发现原因了,setData()方法最终会调用notifyDataChanged(),这个方法开启线程了。。。

clj12081103 avatar May 17 '19 08:05 clj12081103

有什么好的解决办法吗,我现在是用Handler.postDelayed()加了500毫秒的延迟

clj12081103 avatar May 17 '19 08:05 clj12081103

有什么好的解决办法吗,我现在是用Handler.postDelayed()加了500毫秒的延迟

老哥搞定了吗

nxnyk avatar Nov 01 '22 06:11 nxnyk