mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Enable support toolbar for ProfileActivity and added a couple of unit… (#5188)
* Enable support toolbar for ProfileActivity and added a couple of unit tests * Nit fixes * Nit Fixes * Minor styling changes in ContributionsFragment
This commit is contained in:
parent
fc672dbd9b
commit
07616485ae
7 changed files with 97 additions and 50 deletions
|
|
@ -78,10 +78,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
return removedItems;
|
||||
}
|
||||
|
||||
public MediaDetailPagerFragment() {
|
||||
this(false, false);
|
||||
}
|
||||
|
||||
private MediaDetailPagerFragment() {}; // Constructor calls made to be explicit
|
||||
@SuppressLint("ValidFragment")
|
||||
public MediaDetailPagerFragment(Boolean editable, boolean isFeaturedImage) {
|
||||
this.editable = editable;
|
||||
|
|
@ -107,11 +104,13 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
|
||||
adapter = new MediaDetailAdapter(getChildFragmentManager());
|
||||
|
||||
if (getActivity() != null) {
|
||||
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
// ActionBar is now supported in both activities - if this crashes something is quite wrong
|
||||
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
else {
|
||||
throw new AssertionError("Action bar should not be null!");
|
||||
}
|
||||
|
||||
// If fragment is associated with ProfileActivity, then hide the tabLayout
|
||||
|
|
@ -119,6 +118,11 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
((ProfileActivity)getActivity()).tabLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Else if fragment is associated with MainActivity then hide that tab layout
|
||||
else if (getActivity() instanceof MainActivity) {
|
||||
((MainActivity)getActivity()).hideTabs();
|
||||
}
|
||||
|
||||
pager.setAdapter(adapter);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
|
|
@ -127,9 +131,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
if (getActivity() instanceof MainActivity) {
|
||||
((MainActivity)getActivity()).hideTabs();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue