getItemCountでインスタンス変数の中身を軽くチェックするように

This commit is contained in:
r-ca 2024-01-29 01:56:57 +09:00
parent 9084613e38
commit 7086582fad
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -34,7 +34,13 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter {
@Override @Override
public int getItemCount() { public int getItemCount() {
return fragmentTargetIdList == null ? 0 : fragmentTargetIdList.size(); if (fragmentTargetIdList == null || fragmentTitleList == null) {
return 0;
} else if (fragmentTargetIdList.size() != fragmentTitleList.size()) {
throw new IllegalStateException("fragmentTargetIdList.size() != fragmentTitleList.size()");
} else {
return fragmentTargetIdList.size();
}
} }
@Nullable @Nullable