Hide floating wallet on the Channel fragment #1177
1 changed files with 31 additions and 0 deletions
|
@ -73,6 +73,7 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
private TextView textFollowerCount;
|
||||
private TabLayout tabLayout;
|
||||
private ViewPager2 tabPager;
|
||||
ViewPager2.OnPageChangeCallback opcc;
|
||||
|
||||
private View buttonEdit;
|
||||
private View buttonDelete;
|
||||
|
@ -91,6 +92,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
// if this is set, scroll to the specific comment on load
|
||||
private String commentHash;
|
||||
|
||||
private float floatingWalletPositionY;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.fragment_channel, container, false);
|
||||
|
@ -122,6 +125,25 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
tabLayout = root.findViewById(R.id.channel_view_tabs);
|
||||
tabPager.setSaveEnabled(false);
|
||||
|
||||
View floatingBalance = getActivity().findViewById(R.id.floating_balance_main_container);
|
||||
floatingWalletPositionY = floatingBalance.getY();
|
||||
|
||||
opcc = 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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tabPager.registerOnPageChangeCallback(opcc);
|
||||
|
||||
buttonEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -380,6 +402,15 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
super.onPause();
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context ).restoreWalletContainerPosition();
|
||||
}
|
||||
tabPager.unregisterOnPageChangeCallback(opcc);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void checkParams() {
|
||||
boolean updateRequired = false;
|
||||
Map<String, Object> params = getParams();
|
||||
|
|
Loading…
Reference in a new issue