зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400072: Specify card size in onBind instead of onCreate. r=liuche
I believe this doesn't affect this bug because I think the ViewHolders are recreated on rotation but for any other type of change, only bind will be called so for correctness, we should update the size in bind. MozReview-Commit-ID: 3ojO4TF89i4 --HG-- extra : rebase_source : 6376aca2f6858261ca913fa0f613cbdb9be2b4bf
This commit is contained in:
Родитель
37a2bf0cba
Коммит
ed9f361a69
|
@ -88,19 +88,18 @@ import java.util.List;
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TopSitesCard holder, int position) {
|
public void onBindViewHolder(TopSitesCard holder, int position) {
|
||||||
holder.bind(topSites.get(position), getTopSiteAbsolutePosition(position));
|
holder.bind(topSites.get(position), getTopSiteAbsolutePosition(position));
|
||||||
|
|
||||||
|
final View card = holder.itemView;
|
||||||
|
final ViewGroup.LayoutParams layoutParams = card.getLayoutParams();
|
||||||
|
layoutParams.width = tilesSize;
|
||||||
|
layoutParams.height = tilesSize;
|
||||||
|
card.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TopSitesCard onCreateViewHolder(ViewGroup parent, int viewType) {
|
public TopSitesCard onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||||
|
|
||||||
final FrameLayout card = (FrameLayout) inflater.inflate(R.layout.activity_stream_topsites_card, parent, false);
|
final FrameLayout card = (FrameLayout) inflater.inflate(R.layout.activity_stream_topsites_card, parent, false);
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = card.getLayoutParams();
|
|
||||||
layoutParams.width = tilesSize;
|
|
||||||
layoutParams.height = tilesSize;
|
|
||||||
card.setLayoutParams(layoutParams);
|
|
||||||
|
|
||||||
return new TopSitesCard(card, onUrlOpenListener, onUrlOpenInBackgroundListener);
|
return new TopSitesCard(card, onUrlOpenListener, onUrlOpenInBackgroundListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче