Search in sources :

Example 6 with AppInitializeListener

use of net.osmand.plus.AppInitializer.AppInitializeListener in project Osmand by osmandapp.

the class MapActivity method checkAppInitialization.

private void checkAppInitialization() {
    if (app.isApplicationInitializing()) {
        findViewById(R.id.init_progress).setVisibility(View.VISIBLE);
        initListener = new AppInitializeListener() {

            boolean openGlSetup = false;

            @Override
            public void onProgress(AppInitializer init, InitEvents event) {
                String tn = init.getCurrentInitTaskName();
                if (tn != null) {
                    ((TextView) findViewById(R.id.ProgressMessage)).setText(tn);
                }
                if (event == InitEvents.NATIVE_INITIALIZED) {
                    setupOpenGLView(false);
                    openGlSetup = true;
                }
                if (event == InitEvents.MAPS_INITIALIZED) {
                    // TODO investigate if this false cause any issues!
                    mapView.refreshMap(false);
                    if (dashboardOnMap != null) {
                        dashboardOnMap.updateLocation(true, true, false);
                    }
                    app.getTargetPointsHelper().lookupAddessAll();
                    app.getMapMarkersHelper().lookupAddressAll();
                }
            }

            @Override
            public void onFinish(AppInitializer init) {
                if (!openGlSetup) {
                    setupOpenGLView(false);
                }
                mapView.refreshMap(false);
                if (dashboardOnMap != null) {
                    dashboardOnMap.updateLocation(true, true, false);
                }
                findViewById(R.id.init_progress).setVisibility(View.GONE);
                findViewById(R.id.drawer_layout).invalidate();
            }
        };
        getMyApplication().checkApplicationIsBeingInitialized(this, initListener);
    } else {
        setupOpenGLView(true);
    }
}
Also used : AppInitializer(net.osmand.plus.AppInitializer) AppInitializeListener(net.osmand.plus.AppInitializer.AppInitializeListener) InitEvents(net.osmand.plus.AppInitializer.InitEvents)

Aggregations

AppInitializer (net.osmand.plus.AppInitializer)6 AppInitializeListener (net.osmand.plus.AppInitializer.AppInitializeListener)6 InitEvents (net.osmand.plus.AppInitializer.InitEvents)2 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 OnCancelListener (android.content.DialogInterface.OnCancelListener)1 Intent (android.content.Intent)1