Search in sources :

Example 1 with MyFragmentManager

use of com.giua.app.MyFragmentManager in project Giua-App by Giua-app.

the class DrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null)
        savedInstanceState.clear();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer);
    loggerManager = new LoggerManager("DrawerActivity", this);
    loggerManager.d("onCreate chiamato");
    offlineMode = getIntent().getBooleanExtra("offline", false);
    demoMode = SettingsData.getSettingBoolean(this, SettingKey.DEMO_MODE);
    goTo = getIntent().getStringExtra("goTo");
    notificationsDBController = new NotificationsDBController(this);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (GlobalVariables.gsThread == null || GlobalVariables.gsThread.isInterrupted())
        GlobalVariables.gsThread = new GiuaScraperThread();
    if (GlobalVariables.gS == null) {
        loggerManager.w("gs è null ma non dovrebbe esserlo quindi avvio AutomaticLogin");
        startActivityManager();
        return;
    }
    if (!offlineMode) {
        GlobalVariables.gsThread.addTask(() -> {
            if (!GlobalVariables.gS.isSessionValid(GlobalVariables.gS.getCookie())) {
                runOnUiThread(this::startActivityManager);
            }
        });
    }
    myFragmentManager = new MyFragmentManager(this, toolbar, getSupportFragmentManager(), offlineMode, demoMode, unstableFeatures);
    myDrawerManager = new MyDrawerManager(this, this::onChangeAccountFromDrawer, this::settingsItemOnClick, this::logoutItemOnClick, realUsername, userType, toolbar, myFragmentManager, demoMode);
    if (goTo == null || goTo.equals(""))
        myFragmentManager.changeFragment(R.id.nav_home);
    else if (goTo.equals(AppNotificationsParams.NEWSLETTERS_NOTIFICATION_GOTO))
        myFragmentManager.changeFragment(R.id.nav_newsletters);
    else if (goTo.equals(AppNotificationsParams.ALERTS_NOTIFICATION_GOTO))
        myFragmentManager.changeFragment(R.id.nav_alerts);
    else if (goTo.equals(AppNotificationsParams.VOTES_NOTIFICATION_GOTO))
        myFragmentManager.changeFragment(R.id.nav_votes);
    else if (goTo.equals(AppNotificationsParams.AGENDA_NOTIFICATION_GOTO))
        myFragmentManager.changeFragment(R.id.nav_agenda);
    else
        myFragmentManager.changeFragment(R.id.nav_home);
    setupAppNotifications();
    getAndSetupUsernameUsertype();
    new Thread(() -> {
        // Anche se siamo in offline mode, proviamo a scaricarle comunque (magari il registro è in manutenzione)
        loggerManager.d("Scarico le informazioni sulle funzionalità instabili");
        try {
            unstableFeatures = GiuaScraper.getExtPage("https://giua-app.github.io/unstable_features2.txt").text();
            myFragmentManager.unstableFeatures = unstableFeatures;
        } catch (Exception ignored) {
        }
    }).start();
    checkForUpdateChangelog();
}
Also used : NotificationsDBController(com.giua.app.NotificationsDBController) GiuaScraperThread(com.giua.app.GiuaScraperThread) MyFragmentManager(com.giua.app.MyFragmentManager) LoggerManager(com.giua.app.LoggerManager) MyDrawerManager(com.giua.app.MyDrawerManager) GiuaScraperThread(com.giua.app.GiuaScraperThread)

Aggregations

GiuaScraperThread (com.giua.app.GiuaScraperThread)1 LoggerManager (com.giua.app.LoggerManager)1 MyDrawerManager (com.giua.app.MyDrawerManager)1 MyFragmentManager (com.giua.app.MyFragmentManager)1 NotificationsDBController (com.giua.app.NotificationsDBController)1