Search in sources :

Example 1 with OnItemChangeListener

use of net.iGap.libs.bottomNavigation.Event.OnItemChangeListener in project iGap-Android by KianIranian-STDG.

the class BottomNavigationFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomNavigation = view.findViewById(R.id.bn_main_bottomNavigation);
    bottomNavigation.setDefaultItem(currentTab == -1 ? START_TAB : currentTab);
    bottomNavigation.setOnItemChangeListener(new OnItemChangeListener() {

        @Override
        public void onSelectedItemChanged(int i) {
            if (i == 3) {
                isShowedAdd = false;
            }
            loadFragment(i);
        }

        @Override
        public void onSelectAgain(int i) {
            Fragment page = getChildFragmentManager().findFragmentById(R.id.viewpager);
            if (page instanceof BaseMainFragments) {
                ((BaseMainFragments) page).scrollToTopOfList();
            }
        }
    });
    bottomNavigation.setProfileOnLongClickListener(v -> {
        openAccountsDialog();
        return false;
    });
    RealmResults<RealmRoom> realmRooms = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmRoom.class).findAll();
    });
    int unreadCount = 0;
    if (realmRooms != null && realmRooms.size() > 0) {
        for (RealmRoom room : realmRooms) {
            if (!room.getMute() && !room.isDeleted() && room.getUnreadCount() > 0)
                unreadCount += room.getUnreadCount();
        }
    }
    RealmResults<RealmStory> realmStories = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmStory.class).findAll();
    });
    onChange(unreadCount, false);
    if (getMessageDataStorage().isHaveUnSeenStory()) {
        onChange(getMessageDataStorage().getUnSeenStoryCount(), true);
    } else {
        onChange(0, true);
    }
}
Also used : OnItemChangeListener(net.iGap.libs.bottomNavigation.Event.OnItemChangeListener) RealmStory(net.iGap.realm.RealmStory) RealmRoom(net.iGap.realm.RealmRoom) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) PopularMoreChannelFragment(net.iGap.fragments.populaChannel.PopularMoreChannelFragment) PopularChannelHomeFragment(net.iGap.fragments.populaChannel.PopularChannelHomeFragment) StoryFragment(net.iGap.story.liststories.StoryFragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)1 DiscoveryFragment (net.iGap.fragments.discovery.DiscoveryFragment)1 PopularChannelHomeFragment (net.iGap.fragments.populaChannel.PopularChannelHomeFragment)1 PopularMoreChannelFragment (net.iGap.fragments.populaChannel.PopularMoreChannelFragment)1 HelperFragment (net.iGap.helper.HelperFragment)1 OnItemChangeListener (net.iGap.libs.bottomNavigation.Event.OnItemChangeListener)1 RealmRoom (net.iGap.realm.RealmRoom)1 RealmStory (net.iGap.realm.RealmStory)1 StoryFragment (net.iGap.story.liststories.StoryFragment)1