DroidKaigi / conference-app-2020

The Official Conference App for DroidKaigi 2020 Tokyo
https://droidkaigi.jp/2020/en/
Apache License 2.0
775 stars 327 forks source link

[suggest]Remove isSameAs instead of Item.id #682

Closed koji-1009 closed 4 years ago

koji-1009 commented 4 years ago

Issue

Overview (Required)

com.xwray.groupie.Item.isSameAs is this code.

    /**
     * Whether two item objects represent the same underlying data when compared using DiffUtil,
     * even if there has been a change in that data.
     * <p>
     * The default implementation compares both view type and id.
     */
    public boolean isSameAs(Item other) {
        if (getLayout() != other.getLayout()) {
            return false;
        }
        return getId() == other.getId();
    }

getLayout() != other.getLayout() result is same as other is HogeItem result. So I delete that methods.

And, getId() is following.

    private static AtomicLong ID_COUNTER = new AtomicLong(0);
    private final long id;

    public Item() {
        this(ID_COUNTER.decrementAndGet());
    }

    protected Item(long id) {
        this.id = id;
    }

    /**
     * If you don't specify an id, this id is an auto-generated unique negative integer for each Item (the less
     * likely to conflict with your model IDs.)
     * <p>
     * You may prefer to override it with the ID of a model object, for example the primary key of
     * an object from a database that it represents.
     *
     * @return A unique id
     */
    public long getId() {
        return id;
    }

Therefore, I add unique id. (If we don't use a same layout, we don't request the uniqueness.)

Links

Screenshot

koji-1009 commented 4 years ago

see #684

takahirom commented 4 years ago

Can you merge from master for fxing CI?

koji-1009 commented 4 years ago

Thanks! Now merge it!

koji-1009 commented 4 years ago

Sorry, I was overlooked DividerItem class.

jmatsu-bot commented 4 years ago

Your apk has been deployed to https://deploygate.com/distributions/a43c35cae8b7ad6293fe93c3f3444bc34ddb5e24. Anyone can try your changes via the link.

Generated by :no_entry_sign: Danger

jmatsu-bot commented 4 years ago

No issue was reported. Cool!

Generated by :no_entry_sign: Danger