Bug 1317631 - Post: add more cursor position sanity checks r=sebastian

MozReview-Commit-ID: 7CBnLZDkExI

--HG--
extra : rebase_source : e53b55da4dec0490cd64078fb196ed457f86da66
This commit is contained in:
Andrzej Hunt 2016-11-15 17:03:03 +08:00
Родитель adc6f3ec51
Коммит c8796d19d6
1 изменённых файлов: 4 добавлений и 2 удалений

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

@ -49,8 +49,10 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamItem> impl
return TopPanel.LAYOUT_ID;
} else if (position == 1) {
return StreamItem.HighlightsTitle.LAYOUT_ID;
} else {
} else if (position < getItemCount()) {
return HighlightItem.LAYOUT_ID;
} else {
throw new IllegalArgumentException("Requested position does not exist");
}
}
@ -70,7 +72,7 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamItem> impl
}
private int translatePositionToCursor(int position) {
if (position == 0) {
if (getItemViewType(position) != HighlightItem.LAYOUT_ID) {
throw new IllegalArgumentException("Requested cursor position for invalid item");
}