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:
Michael Comella 2017-09-15 14:05:21 -07:00
Родитель 37a2bf0cba
Коммит ed9f361a69
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -88,19 +88,18 @@ import java.util.List;
@Override
public void onBindViewHolder(TopSitesCard holder, int 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
public TopSitesCard onCreateViewHolder(ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
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);
}