Commit b0437440 authored by Thomas's avatar Thomas
Browse files

Fix tab not hidden

parent 6b043fc4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public class BottomMenu implements Serializable {
        bottomNavigationView.getMenu().clear();
        BottomMenu bottomMenu = null;
        try {
            bottomMenu = getAllBottomMenu(account);
            bottomMenu = getBottomMenu(account);
        } catch (DBException e) {
            e.printStackTrace();
        }
+2 −2
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public class PinnedTimelineHelper {
        activityMainBinding.tabLayout.removeAllTabs();
        //Small hack to hide first tabs (they represent the item of the bottom menu)
        int toRemove = itemToRemoveInBottomMenu(activity);
        for (int i = 0; i < BOTTOM_TIMELINE_COUNT - toRemove; i++) {
        for (int i = 0; i < (BOTTOM_TIMELINE_COUNT - toRemove); i++) {
            activityMainBinding.tabLayout.addTab(activityMainBinding.tabLayout.newTab());
            ((ViewGroup) activityMainBinding.tabLayout.getChildAt(0)).getChildAt(i).setVisibility(View.GONE);
        }
@@ -216,7 +216,7 @@ public class PinnedTimelineHelper {

            @Override
            public void onPageSelected(int position) {
                if (position < BOTTOM_TIMELINE_COUNT) {
                if (position < BOTTOM_TIMELINE_COUNT - toRemove) {
                    activityMainBinding.bottomNavView.getMenu().getItem(position).setChecked(true);
                } else {
                    activityMainBinding.bottomNavView.getMenu().setGroupCheckable(0, true, false);
+6 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package app.fedilab.android.ui.pageadapter;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
@@ -74,10 +75,11 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
        FragmentMastodonTimeline fragment = new FragmentMastodonTimeline();
        Bundle bundle = new Bundle();
        //Position 3 is for notifications
        if (position < BOTTOM_TIMELINE_COUNT - toRemove) {
        Log.v(Helper.TAG, "position: " + position + " -> " + (BOTTOM_TIMELINE_COUNT - toRemove));
        if (position < (BOTTOM_TIMELINE_COUNT - toRemove)) {
            if (bottomMenu != null) {
                BottomMenu.ItemMenuType type = BottomMenu.getType(bottomMenu, position);

                Log.v(Helper.TAG, "type: " + type);
                if (type == null) {
                    return fragment;
                }
@@ -99,9 +101,10 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {

        } else {
            int pinnedPosition = position - (BOTTOM_TIMELINE_COUNT - toRemove); //Real position has an offset.
            Log.v(Helper.TAG, "pinnedPosition: " + pinnedPosition);
            PinnedTimeline pinnedTimeline = pinned.pinnedTimelines.get(pinnedPosition);
            bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, pinnedTimeline.type);

            Log.v(Helper.TAG, " pinnedTimeline.type: " + pinnedTimeline.type);
            if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST) {
                bundle.putString(Helper.ARG_LIST_ID, pinnedTimeline.mastodonList.id);
            } else if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) {
@@ -119,7 +122,6 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {

    @Override
    public int getCount() {

        if (pinned != null && pinned.pinnedTimelines != null) {
            return pinned.pinnedTimelines.size() + BOTTOM_TIMELINE_COUNT - toRemove;
        } else {