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);
}
}
Aggregations