java - weeex[android]list的实现itemview没有进行重用
大家讲道理
大家讲道理 2017-04-18 10:53:21
0
2
499

list的实现使用的是RecyclerView,但getItemViewType返回的是dom的ref,ref在一个dom树里应该是唯一的;

public int getItemViewType(int position) {
    return generateViewType(getChild(position));
  }
private int generateViewType(WXComponent component) {
    long id;
    try {
      id = Integer.parseInt(component.getDomObject().getRef());
      String type = component.getDomObject().getAttrs().getScope();

      if (!TextUtils.isEmpty(type)) {
        if (mRefToViewType == null) {
          mRefToViewType = new ArrayMap<>();
        }
        if (!mRefToViewType.containsKey(type)) {
          mRefToViewType.put(type, id);
        }
        id = mRefToViewType.get(type);

      }
    } catch (RuntimeException e) {
      WXLogUtils.eTag(TAG, e);
      id = RecyclerView.NO_ID;
      WXLogUtils.e(TAG, "getItemViewType: NO ID, this will crash the whole render system of WXListRecyclerView");
    }
    return (int) id;
  }
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
阿神

Reuse requires views of the same type.
According to the description, the type of each item is unique, that is, they are not the same thing. The code cannot tell whether it can be reused.
There should be confusion here. The unique identifier (id) required elsewhere is mixed with the type required by RecyclerView. If you want the Views of two Items to be shared, the types of the two Views should be the same (their IDs may be different)

巴扎黑

+1 The itemtype above is different and cannot be reused

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!