Search in sources :

Example 1 with InitEvents

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

the class GeoIntentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_address_offline);
    getSupportActionBar().setTitle(R.string.search_osm_offline);
    getMyApplication().checkApplicationIsBeingInitialized(this, new AppInitializeListener() {

        @Override
        public void onProgress(AppInitializer init, InitEvents event) {
        }

        @Override
        public void onFinish(AppInitializer init) {
        }
    });
    location = getMyApplication().getSettings().getLastKnownMapLocation();
    final Intent intent = getIntent();
    if (intent != null) {
        final ProgressDialog progress = ProgressDialog.show(GeoIntentActivity.this, getString(R.string.searching), getString(R.string.searching_address));
        final GeoIntentTask task = new GeoIntentTask(progress, intent);
        progress.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                task.cancel(true);
            }
        });
        progress.setCancelable(true);
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        setIntent(null);
    }
}
Also used : AppInitializer(net.osmand.plus.AppInitializer) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) AppInitializeListener(net.osmand.plus.AppInitializer.AppInitializeListener) ProgressDialog(android.app.ProgressDialog) InitEvents(net.osmand.plus.AppInitializer.InitEvents) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 2 with InitEvents

use of net.osmand.plus.AppInitializer.InitEvents 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)2 AppInitializeListener (net.osmand.plus.AppInitializer.AppInitializeListener)2 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