导航菜单

页面标题

页面副标题

Aptoide v9.22.5.3 - BottomNavigationNavigator.java 源代码

正在查看: Aptoide v9.22.5.3 应用的 BottomNavigationNavigator.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package cm.aptoide.pt.bottomNavigation;

import androidx.fragment.app.Fragment;
import cm.aptoide.pt.dataprovider.model.v7.Event;
import cm.aptoide.pt.dataprovider.ws.v7.store.StoreContext;
import cm.aptoide.pt.editorialList.EditorialListFragment;
import cm.aptoide.pt.home.HomeContainerFragment;
import cm.aptoide.pt.home.apps.AppsFragment;
import cm.aptoide.pt.navigator.FragmentNavigator;
import cm.aptoide.pt.search.analytics.SearchAnalytics;
import cm.aptoide.pt.search.analytics.SearchSource;
import cm.aptoide.pt.search.view.SearchResultFragment;
import cm.aptoide.pt.store.view.my.MyStoresFragment;
import cm.aptoide.pt.themes.ThemeManager;
import java.util.ArrayList;
import java.util.Collections;

public class BottomNavigationNavigator {
    private static final String EVENT_ACTION = "https://ws75-cache.aptoide.com/api/7.20240701/getStoreWidgets/store_id=15/context=stores";
    private final BottomNavigationAnalytics bottomNavigationAnalytics;
    private ArrayList<Integer> bottomNavigationItems = new ArrayList<>();
    private final FragmentNavigator fragmentNavigator;
    private final SearchAnalytics searchAnalytics;
    private final ThemeManager themeManager;

    public BottomNavigationNavigator(FragmentNavigator fragmentNavigator, BottomNavigationAnalytics bottomNavigationAnalytics, SearchAnalytics searchAnalytics, ThemeManager themeManager) {
        this.bottomNavigationAnalytics = bottomNavigationAnalytics;
        this.searchAnalytics = searchAnalytics;
        this.fragmentNavigator = fragmentNavigator;
        this.themeManager = themeManager;
    }

    private Event getStoreEvent() {
        Event event = new Event();
        event.setAction(EVENT_ACTION);
        event.setData(null);
        event.setName(Event.Name.myStores);
        event.setType(Event.Type.CLIENT);
        return event;
    }

    private void navigateBackToBottomNavigationItem(int i) {
        Fragment appsFragment = i != 0 ? i != 1 ? i != 2 ? i != 3 ? i != 4 ? null : new AppsFragment() : MyStoresFragment.newInstance(getStoreEvent(), "", "stores", StoreContext.home) : SearchResultFragment.newInstance(true) : new EditorialListFragment() : new HomeContainerFragment();
        if (appsFragment != null) {
            this.fragmentNavigator.navigateToCleaningBackStack(appsFragment, true);
        }
    }

    private void navigateToSelectedFragment(int i, Fragment fragment) {
        Fragment fragment2 = this.fragmentNavigator.getFragment();
        if (fragment2 == null || fragment2.getClass() != fragment.getClass()) {
            if (this.bottomNavigationItems.size() <= 0 || this.bottomNavigationItems.get(0).intValue() != i) {
                this.fragmentNavigator.cleanBackStack();
                this.fragmentNavigator.navigateToWithoutBackSave(fragment, true);
            } else {
                this.fragmentNavigator.cleanBackStack();
            }
            updateBottomNavigationItemsList(i);
            Collections.rotate(this.bottomNavigationItems, 1);
        }
    }

    private void updateBottomNavigationItemsList(int i) {
        int indexOf = this.bottomNavigationItems.indexOf(Integer.valueOf(i));
        if (indexOf != -1) {
            this.bottomNavigationItems.remove(indexOf);
        }
        this.bottomNavigationItems.add(Integer.valueOf(i));
    }

    public boolean canNavigateBack() {
        return this.bottomNavigationItems.size() > 1;
    }

    public ArrayList<Integer> getBottomNavigationItems() {
        return this.bottomNavigationItems;
    }

    public void navigateBack() {
        int intValue = this.bottomNavigationItems.get(1).intValue();
        this.bottomNavigationItems.remove(0);
        navigateBackToBottomNavigationItem(intValue);
    }

    public void navigateToApps() {
        navigateToSelectedFragment(4, new AppsFragment());
    }

    public void navigateToBottomNavigationItem(int i) {
        if (i == 0) {
            this.bottomNavigationAnalytics.sendNavigateToHomeClickEvent();
            navigateToHome();
            return;
        }
        if (i == 1) {
            this.bottomNavigationAnalytics.sendNavigateToCurationClickEvent();
            navigateToCuration();
            return;
        }
        if (i == 2) {
            this.bottomNavigationAnalytics.sendNavigateToSearchClickEvent();
            this.searchAnalytics.searchStart(SearchSource.BOTTOM_NAVIGATION, true);
            navigateToSearch(SearchResultFragment.newInstance(true));
        } else if (i == 3) {
            this.bottomNavigationAnalytics.sendNavigateToStoresClickEvent();
            navigateToStore();
        } else {
            if (i != 4) {
                return;
            }
            this.bottomNavigationAnalytics.sendNavigateToAppsClickEvent();
            navigateToApps();
        }
    }

    public void navigateToCuration() {
        navigateToSelectedFragment(1, new EditorialListFragment());
    }

    public void navigateToHome() {
        navigateToSelectedFragment(0, new HomeContainerFragment());
    }

    public void navigateToSearch(SearchResultFragment searchResultFragment) {
        navigateToSelectedFragment(2, searchResultFragment);
    }

    public void navigateToStore() {
        navigateToSelectedFragment(3, MyStoresFragment.newInstance(getStoreEvent(), this.themeManager.getBaseTheme().getThemeName(), "stores", StoreContext.home));
    }

    public void setBottomNavigationItems(ArrayList<Integer> arrayList) {
        this.bottomNavigationItems = arrayList;
    }
}