fixed the contribution crash on scroll (#4128)

* fixed the contribution crash on scroll

* Investigation

Just to get the Log of the issue

* fixed null data causing scroll to top

* Removed unneeded log import.
This commit is contained in:
Aditya-Srivastav 2021-01-01 20:40:10 +05:30 committed by GitHub
parent e1be458821
commit 7730112807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -64,6 +64,12 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
}
public void init(final int position, final Contribution contribution) {
//handling crashes when the contribution is null.
if( null == contribution) {
return;
}
this.contribution = contribution;
this.position = position;
titleView.setText(contribution.getMedia().getMostRelevantCaption());

View file

@ -150,7 +150,9 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
public void onItemRangeInserted(int positionStart, int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
if (itemCount > 0 && positionStart == 0) {
rvContributionsList.scrollToPosition(0);//Newly upload items are always added to the top
if(adapter.getContributionForPosition(positionStart)!=null) {
rvContributionsList.scrollToPosition(0);//Newly upload items are always added to the top
}
}
}
});