mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-31 23:03:54 +01:00
MediaDetailFragment.java: add helper method to retrieve ContributionFragment instance
Before this commit, there was no easy way to check for and retrieve the ContributionFragment instance that was either the parent or grandparent (parent's parent) fragment. A complicated if check was required to retrieve it. After this commit, there is a simple helper method which will retrieve the ContributionFragment instance. Existing code can now be replaced by calling this method.
This commit is contained in:
parent
16a1375800
commit
408f5a3b57
1 changed files with 21 additions and 0 deletions
|
|
@ -445,6 +445,27 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the ContributionsFragment that is potentially the parent, grandparent, etc
|
||||||
|
* fragment of this fragment.
|
||||||
|
*
|
||||||
|
* @return The ContributionsFragment instance. If the ContributionsFragment instance could not
|
||||||
|
* be found, null is returned.
|
||||||
|
*/
|
||||||
|
private ContributionsFragment getContributionsFragmentParent(){
|
||||||
|
Fragment f = this;
|
||||||
|
|
||||||
|
while(f != null && !(f instanceof ContributionsFragment)){
|
||||||
|
f = f.getParentFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(f != null){
|
||||||
|
return (ContributionsFragment)f;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void displayMediaDetails() {
|
private void displayMediaDetails() {
|
||||||
setTextFields(media);
|
setTextFields(media);
|
||||||
compositeDisposable.addAll(
|
compositeDisposable.addAll(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue