Search in sources :

Example 1 with LoadingNavigationControllerException

use of org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException in project pictureapp by EyeSeeTea.

the class DashboardActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    PreferencesState.getInstance().onCreateActivityPreferences(getResources(), getTheme());
    if (getIntent().getBooleanExtra(getString(R.string.show_announcement_key), true) && !Session.getCredentials().isDemoCredentials()) {
        new AsyncAnnouncement().execute();
    }
    handler = new Handler(Looper.getMainLooper());
    mDashboardActivityStrategy = new DashboardActivityStrategy(this);
    mDashboardActivityStrategy.onCreate();
    dashboardActivity = this;
    setContentView(R.layout.tab_dashboard);
    Survey.removeInProgress();
    if (savedInstanceState == null) {
        initImprove();
        initMonitor();
        if (GradleVariantConfig.isStockFragmentActive()) {
            initStock();
        }
        initAssess();
    }
    initTabHost(savedInstanceState);
    /* set tabs in order */
    LayoutUtils.setTabHosts(this);
    LayoutUtils.setTabDivider(this);
    // set the tabs background as transparent
    setTabsBackgroundColor(R.color.tab_unpressed_background);
    // set first tab as selected:
    tabHost.getTabWidget().getChildAt(0).setBackgroundColor(getResources().getColor(R.color.tab_pressed_background));
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {
            /**
             * If current tab is android
             */
            // set the tabs background as transparent
            setTabsBackgroundColor(R.color.tab_unpressed_background);
            // If change of tab from surveyFragment or FeedbackFragment they could be closed.
            if (isSurveyFragmentActive()) {
                onSurveyBackPressed();
            }
            if (isReviewFragmentActive()) {
                exitReviewOnChangeTab(null);
            }
            if (tabId.equalsIgnoreCase(getResources().getString(R.string.tab_tag_assess))) {
                if (!isReadOnly) {
                    mDashboardActivityStrategy.reloadFirstFragment();
                }
                mDashboardActivityStrategy.reloadFirstFragmentHeader();
            } else if (tabId.equalsIgnoreCase(getResources().getString(R.string.tab_tag_improve))) {
                mDashboardActivityStrategy.reloadSecondFragment();
            } else if (tabId.equalsIgnoreCase(getResources().getString(R.string.tab_tag_stock))) {
                mDashboardActivityStrategy.reloadStockFragment(dashboardActivity);
            } else if (tabId.equalsIgnoreCase(getResources().getString(R.string.tab_tag_monitor))) {
                mDashboardActivityStrategy.reloadFourthFragment();
            }
            tabHost.getCurrentTabView().setBackgroundColor(getResources().getColor(R.color.tab_pressed_background));
        }
    });
    // init tabHost
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        tabHost.getTabWidget().getChildAt(i).setFocusable(false);
    }
    getSurveysFromService();
    if (BuildConfig.multiuser) {
        try {
            initNavigationController();
        } catch (LoadingNavigationControllerException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : LoadingNavigationControllerException(org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException) TabHost(android.widget.TabHost) Handler(android.os.Handler) DashboardActivityStrategy(org.eyeseetea.malariacare.strategies.DashboardActivityStrategy)

Example 2 with LoadingNavigationControllerException

use of org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException in project pictureapp by EyeSeeTea.

the class SplashScreenActivity method init.

private void init() {
    LocationMemory.getInstance().init(getApplicationContext());
    D2.init(this);
    SdkQueries.createDBIndexes();
    // Added to execute a query in DB, because DBFLow doesn't do any migration until a query
    // is executed
    PopulateDB.initDBQuery();
    try {
        PostMigration.launchPostMigration();
    } catch (PostMigrationException e) {
        new AlertDialog.Builder(this).setTitle(getApplicationContext().getString(R.string.error_message)).setCancelable(false).setMessage(getApplicationContext().getString(R.string.db_migration_error)).setNeutralButton(android.R.string.ok, null).create().show();
    }
    if (!BuildConfig.multiuser) {
        Log.i(TAG, "Pull on SplashScreen ...");
        PullController pullController = new PullController(getApplication().getApplicationContext());
        IAsyncExecutor asyncExecutor = new AsyncExecutor();
        IMainExecutor mainExecutor = new UIThreadExecutor();
        PullUseCase pullUseCase = new PullUseCase(pullController, asyncExecutor, mainExecutor);
        PullFilters pullFilters = new PullFilters();
        pullFilters.setDemo(true);
        pullUseCase.execute(pullFilters, new PullUseCase.Callback() {

            @Override
            public void onComplete() {
                Log.d(this.getClass().getSimpleName(), "pull complete");
                try {
                    NavigationBuilder.getInstance().buildController(Tab.getFirstTab());
                } catch (LoadingNavigationControllerException ex) {
                    onError(ex.getMessage());
                }
            }

            @Override
            public void onStep(PullStep step) {
                Log.d(this.getClass().getSimpleName(), step.toString());
            }

            @Override
            public void onError(String message) {
                Log.e(this.getClass().getSimpleName(), message);
            }

            @Override
            public void onNetworkError() {
                Log.e(this.getClass().getSimpleName(), "Network Error");
            }

            @Override
            public void onPullConversionError() {
                Log.e(this.getClass().getSimpleName(), "Pull Conversion Error");
            }

            @Override
            public void onCancel() {
                Log.e(this.getClass().getSimpleName(), "Pull oncancel");
            }
        });
    }
}
Also used : AlertDialog(android.app.AlertDialog) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor) PullStep(org.eyeseetea.malariacare.domain.usecase.pull.PullStep) PullController(org.eyeseetea.malariacare.data.sync.importer.PullController) IMainExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor) LoadingNavigationControllerException(org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException) PullUseCase(org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase) PostMigrationException(org.eyeseetea.malariacare.domain.exception.PostMigrationException) UIThreadExecutor(org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor) PullFilters(org.eyeseetea.malariacare.domain.usecase.pull.PullFilters) AsyncExecutor(org.eyeseetea.malariacare.presentation.executors.AsyncExecutor) IAsyncExecutor(org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)

Example 3 with LoadingNavigationControllerException

use of org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException in project pictureapp by EyeSeeTea.

the class NavigationBuilder method buildNavigationController.

private void buildNavigationController(Question rootQuestion) {
    Log.d(TAG, "Begin loading navigation controller");
    try {
        Session.setIsLoadingNavigationController(true);
        // init steps counter
        step = 0;
        QuestionNode rootNode = buildNode(rootQuestion);
        Session.setNavigationController(new NavigationController(rootNode));
        Session.setIsLoadingNavigationController(false);
        if (mLoadBuildControllerListener != null) {
            notifyLoadFinished();
        }
    } catch (NullPointerException ex) {
        Session.setIsLoadingNavigationController(false);
        new LoadingNavigationControllerException(ex);
    }
    Log.d(TAG, "End loading navigation controller");
}
Also used : LoadingNavigationControllerException(org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException)

Aggregations

LoadingNavigationControllerException (org.eyeseetea.malariacare.domain.exception.LoadingNavigationControllerException)3 AlertDialog (android.app.AlertDialog)1 Handler (android.os.Handler)1 TabHost (android.widget.TabHost)1 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)1 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)1 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)1 PostMigrationException (org.eyeseetea.malariacare.domain.exception.PostMigrationException)1 PullFilters (org.eyeseetea.malariacare.domain.usecase.pull.PullFilters)1 PullStep (org.eyeseetea.malariacare.domain.usecase.pull.PullStep)1 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)1 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)1 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)1 DashboardActivityStrategy (org.eyeseetea.malariacare.strategies.DashboardActivityStrategy)1