mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +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);
|
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){
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue