Hide floating wallet on the Channel fragment

This commit is contained in:
Javi Rueda 2021-03-18 21:26:30 +01:00
parent 9ac216504d
commit 46af0b533a

View file

@ -91,6 +91,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
// if this is set, scroll to the specific comment on load // if this is set, scroll to the specific comment on load
private String commentHash; private String commentHash;
private float floatingWalletPositionY;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_channel, container, false); View root = inflater.inflate(R.layout.fragment_channel, container, false);
@ -122,6 +124,23 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
tabLayout = root.findViewById(R.id.channel_view_tabs); tabLayout = root.findViewById(R.id.channel_view_tabs);
tabPager.setSaveEnabled(false); tabPager.setSaveEnabled(false);
View floatingBalance = getActivity().findViewById(R.id.floating_balance_main_container);
floatingWalletPositionY = floatingBalance.getY();
tabPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
if (position > 0) {
// Hide floating wallet for the About and the Comment tabs as they are mostly text
((MainActivity) getContext()).translateFloatingWallet(floatingWalletPositionY);
} else {
((MainActivity) getContext()).restoreWalletContainerPosition();
}
}
});
buttonEdit.setOnClickListener(new View.OnClickListener() { buttonEdit.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -380,6 +399,14 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
super.onPause(); super.onPause();
} }
public void onStop() {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context ).restoreWalletContainerPosition();
}
super.onStop();
}
private void checkParams() { private void checkParams() {
boolean updateRequired = false; boolean updateRequired = false;
Map<String, Object> params = getParams(); Map<String, Object> params = getParams();