Giter VIP home page Giter VIP logo

Comments (4)

drakeet avatar drakeet commented on June 18, 2024

My conclusion is: No.

If an Items container has many types of Items, our position would be meaningless. Because it should be in the same position, so it could makes sense.

And if you really need a position param, my suggestion is that: You can extend MultiTypeAdapter and ItemViewProvider to achieve. It will serve as a concrete use case.

from multitype.

drakeet avatar drakeet commented on June 18, 2024

Chinese version:
"我们是否需要传递 position 到 provider 层面?"

我觉得是不需要,首先几乎所有需要 position 的需求,都可以 以不需要 position 的方式实现;其次,position 造成了耦合、对外依赖;而且,因为我们的 Items 容器中可能有多种类型的 items,如果直接取在 Items 中的位置,这是没有意义的,我们需要的是它们在同类中的位置;最后,如果你实在需要 position,完全可以通过继承源码来实现,MultiType 几乎所有的部件都是可拓展可替换的,我们不应该直接去修改源码。

from multitype.

drakeet avatar drakeet commented on June 18, 2024

上次说到 MultiType 是否需要给 ViewProvider 传递 position 的事情,我找到了许多理由来支持"不需要",但实际上有一种情况下很可能是需要的,就是当 item type 只有一种的时候,于是我继承了 MultiTypeAdapter 非常容易地自行传递了 position,如图。position 主要用于判断是否是第一个 item,如果是,将 item 的顶部加上圆角度数。

snip20161208_6

from multitype.

drakeet avatar drakeet commented on June 18, 2024

最终,在 2.3.0 加入了获取 position 接口方法:

  • Added getPosition() to ItemViewProvider(#43):
/**
 * Get the adapter position of current item,
 * the internal position is equals RecyclerView.ViewHolder#getAdapterPosition().
 *
 * @return the adapter position
 * @since v2.3.0
 */
protected final int getPosition() {
    return position;
}

from multitype.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.