New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
お気に入り画面のアイテムタブの作成 一個前のプルリクはクローズしました #29
Conversation
@@ -16,4 +17,13 @@ class FavoriteItemNoItem : BindableItem<FavoriteItemNoItemRegisteredBinding>(), | |||
override fun initializeViewBinding(view: View): FavoriteItemNoItemRegisteredBinding { | |||
return FavoriteItemNoItemRegisteredBinding.bind(view) | |||
} | |||
|
|||
/**現状FavoriteItemNoItemは一つしか表示しないので classが等しければ更新は不要*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
残したコメントこちらです!
} | ||
|
||
private class CustomGroupieAdapter : GroupieAdapter() { | ||
private var _itemList: List<BindableItem<out ViewBinding>> = makeDefaultList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これはなくせそう
private val adapter: CustomGroupieAdapter | ||
) : GridLayoutManager.SpanSizeLookup() { | ||
override fun getSpanSize(position: Int) = | ||
(adapter.getItem(position) as SpanSizeInterface).spanSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpanSizeInterfaceを継承してるものしか入ってこないのは明確ですが念のため
(adapter.getItem(position) as? SpanSizeInterface)?.spanSize ?: 0
みたいな感じでnull安全にcastして欲しいです
return FavoriteItemDescriptionBinding.bind(view) | ||
} | ||
|
||
override fun isSameAs(other: Item<*>): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(other as? FavoriteItemDescription)?.model == model
かな
return other.model.id == this.model.id | ||
} | ||
|
||
override fun hasSameContentAs(other: Item<*>): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こっちが同じ要素を持ってるかどうか
return other is FavoriteItemNoItem | ||
} | ||
|
||
override fun hasSameContentAs(other: Item<*>): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こっちのロジックはisSameAsと一緒なので
= isSameAs(other)
でよさそう
return other is FavoriteItemNowPopular | ||
} | ||
|
||
override fun hasSameContentAs(other: Item<*>): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -0,0 +1,5 @@ | |||
package com.nemo.androiduitraining.view.fragment.favorite.entity.item | |||
|
|||
interface SpanSizeInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interfaceにinterfaceと名前をつけることはあまりないので今回は
HasSpanSizeItem
とかでいいんじゃないかなと
hasSameContentAs周りに関してなんですけど、
みたいな時 == が equalsと同じだから、要素が同じかどうかの比較だと思ってたんですけどここってどうなんですかね? |
modelが持ってる要素が同じかどうかを比べたいですね |
model自体がdata classなんですけど、other.model == this.modelだとmodelの比較にならないですかね? |
model同士の比較はisSameAsの方ですかね |
なるほど! |
…ndroidUITrain into create_favorite_item
…toString().toLongとするとException発生)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:lgtm:
概要
お気に入りのアイテムタブを実装
関連情報
関連するPR,issueがあればここにリンクを貼る
スクリーンショット
見た目の変更があるならそれを貼る
懸念点
またもgit操作でミスったのでプルリク作り直しました!!🙇♂️
まだ修正終わっていない点
① FavoriteItemFragmentのそれぞれのItemViewModelに対する isSameAs hasSameContentの定義
自身がないので考えをコメントで残しておきました!ご確認お願いします!!