mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* 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:
parent
d950f72193
commit
ac3e5158be
4 changed files with 14 additions and 1 deletions
|
|
@ -224,6 +224,14 @@ public class ContributionsFragment
|
|||
Timber.d("Fetching thumbnail for %s", contribution.filename);
|
||||
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){
|
||||
|
|
|
|||
|
|
@ -77,5 +77,7 @@ public class ContributionsListAdapter extends RecyclerView.Adapter<ContributionV
|
|||
Contribution getContributionForPosition(int position);
|
||||
|
||||
void fetchMediaUriFor(Contribution contribution);
|
||||
|
||||
void onContributionsUpdated();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment {
|
|||
this.contributions.clear();
|
||||
this.contributions.addAll(contributionList);
|
||||
adapter.setContributions(contributions);
|
||||
callback.onContributionsUpdated();
|
||||
}
|
||||
|
||||
public interface SourceRefresher {
|
||||
|
|
|
|||
|
|
@ -320,7 +320,9 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
* The method notify the viewpager that number of items have changed.
|
||||
*/
|
||||
public void notifyDataSetChanged(){
|
||||
adapter.notifyDataSetChanged();
|
||||
if (null != adapter) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue