Fixes #3705 (Crash when viewing pic I just uploaded) (#3782)

* Fixes #3705
* Let the MediaDetailPager fragment know when the contributions have been updated

* Handle NPE, null check on adapter in MediaDetailPagerFragment
This commit is contained in:
Ashish Kumar 2020-06-02 22:49:38 +05:30 committed by GitHub
parent d950f72193
commit ac3e5158be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View file

@ -224,6 +224,14 @@ public class ContributionsFragment
Timber.d("Fetching thumbnail for %s", contribution.filename); Timber.d("Fetching thumbnail for %s", contribution.filename);
contributionsPresenter.fetchMediaDetails(contribution); contributionsPresenter.fetchMediaDetails(contribution);
} }
@Override
public void onContributionsUpdated() {
//If the contributions are updated, let the pager fragment know
if (null != mediaDetailPagerFragment) {
mediaDetailPagerFragment.notifyDataSetChanged();
}
}
}); });
if(null==mediaDetailPagerFragment){ if(null==mediaDetailPagerFragment){

View file

@ -77,5 +77,7 @@ public class ContributionsListAdapter extends RecyclerView.Adapter<ContributionV
Contribution getContributionForPosition(int position); Contribution getContributionForPosition(int position);
void fetchMediaUriFor(Contribution contribution); void fetchMediaUriFor(Contribution contribution);
void onContributionsUpdated();
} }
} }

View file

@ -188,6 +188,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment {
this.contributions.clear(); this.contributions.clear();
this.contributions.addAll(contributionList); this.contributions.addAll(contributionList);
adapter.setContributions(contributions); adapter.setContributions(contributions);
callback.onContributionsUpdated();
} }
public interface SourceRefresher { public interface SourceRefresher {

View file

@ -320,7 +320,9 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
* The method notify the viewpager that number of items have changed. * The method notify the viewpager that number of items have changed.
*/ */
public void notifyDataSetChanged(){ public void notifyDataSetChanged(){
adapter.notifyDataSetChanged(); if (null != adapter) {
adapter.notifyDataSetChanged();
}
} }
@Override @Override