Search in sources :

Example 1 with ImportHelper

use of net.osmand.plus.helpers.ImportHelper in project Osmand by osmandapp.

the class MapActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
    long tm = System.currentTimeMillis();
    app = getMyApplication();
    settings = app.getSettings();
    app.applyTheme(this);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    boolean portraitMode = AndroidUiHelper.isOrientationPortrait(this);
    boolean largeDevice = AndroidUiHelper.isXLargeDevice(this);
    landscapeLayout = !portraitMode && !largeDevice;
    mapContextMenu.setMapActivity(this);
    super.onCreate(savedInstanceState);
    // Full screen is not used here
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
    if (Build.VERSION.SDK_INT >= 21) {
        enterToFullScreen();
        // Navigation Drawer:
        AndroidUtils.addStatusBarPadding21v(this, findViewById(R.id.menuItems));
    }
    int statusBarHeight = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int w = dm.widthPixels;
    int h = dm.heightPixels - statusBarHeight;
    mapView = new OsmandMapTileView(this, w, h);
    if (app.getAppInitializer().checkAppVersionChanged() && WhatsNewDialogFragment.SHOW) {
        SecondSplashScreenFragment.SHOW = false;
        WhatsNewDialogFragment.SHOW = false;
        new WhatsNewDialogFragment().show(getSupportFragmentManager(), null);
    }
    mapActions = new MapActivityActions(this);
    mapLayers = new MapActivityLayers(this);
    if (mapViewTrackingUtilities == null) {
        mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
    }
    dashboardOnMap.createDashboardView();
    checkAppInitialization();
    parseLaunchIntentLocation();
    mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {

        @Override
        public boolean onTrackBallEvent(MotionEvent e) {
            showAndHideMapPosition();
            return MapActivity.this.onTrackballEvent(e);
        }
    });
    mapView.setAccessibilityActions(new MapAccessibilityActions(this));
    mapViewTrackingUtilities.setMapView(mapView);
    // to not let it gc
    downloaderCallback = new IMapDownloaderCallback() {

        @Override
        public void tileDownloaded(DownloadRequest request) {
            if (request != null && !request.error && request.fileToSave != null) {
                ResourceManager mgr = app.getResourceManager();
                mgr.tileDownloaded(request);
            }
            if (request == null || !request.error) {
                mapView.tileDownloaded(request);
            }
        }
    };
    app.getResourceManager().getMapTileDownloader().addDownloaderCallback(downloaderCallback);
    createProgressBarForRouting();
    mapLayers.createLayers(mapView);
    updateStatusBarColor();
    // it tries to continue the last route
    if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated() && !app.getRoutingHelper().isRouteBeingCalculated()) {
        FailSafeFuntions.restoreRoutingMode(this);
    } else if (!app.getRoutingHelper().isRoutePlanningMode() && !settings.FOLLOW_THE_ROUTE.get() && app.getTargetPointsHelper().getAllPoints().size() > 0) {
        app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
        app.getTargetPointsHelper().removeAllWayPoints(false, false);
    }
    if (!settings.isLastKnownMapLocation()) {
        // show first time when application ran
        net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation();
        mapViewTrackingUtilities.setMapLinkedToLocation(true);
        if (location != null) {
            mapView.setLatLon(location.getLatitude(), location.getLongitude());
            mapView.setIntZoom(14);
        }
    }
    addDialogProvider(mapActions);
    OsmandPlugin.onMapActivityCreate(this);
    importHelper = new ImportHelper(this, getMyApplication(), getMapView());
    wakeLockHelper = new WakeLockHelper(getMyApplication());
    if (System.currentTimeMillis() - tm > 50) {
        System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
    }
    mapView.refreshMap(true);
    mapActions.updateDrawerMenu();
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    screenOffReceiver = new ScreenOffReceiver();
    registerReceiver(screenOffReceiver, filter);
    app.getAidlApi().onCreateMapActivity(this);
    mIsDestroyed = false;
}
Also used : IntentFilter(android.content.IntentFilter) IMapDownloaderCallback(net.osmand.map.MapTileDownloader.IMapDownloaderCallback) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) ArrayList(java.util.ArrayList) DownloadRequest(net.osmand.map.MapTileDownloader.DownloadRequest) WhatsNewDialogFragment(net.osmand.plus.dialogs.WhatsNewDialogFragment) ResourceManager(net.osmand.plus.resources.ResourceManager) DisplayMetrics(android.util.DisplayMetrics) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) MapAccessibilityActions(net.osmand.access.MapAccessibilityActions) MotionEvent(android.view.MotionEvent) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) WakeLockHelper(net.osmand.plus.helpers.WakeLockHelper) ImportHelper(net.osmand.plus.helpers.ImportHelper) Location(net.osmand.Location)

Example 2 with ImportHelper

use of net.osmand.plus.helpers.ImportHelper in project Osmand by osmandapp.

the class FavoritesActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    OsmandApplication app = (OsmandApplication) getApplication();
    app.applyTheme(this);
    super.onCreate(icicle);
    app.logEvent(this, "myplaces_open");
    importHelper = new ImportHelper(this, getMyApplication(), null);
    // noinspection ConstantConditions
    getSupportActionBar().setTitle(R.string.shared_string_my_places);
    getSupportActionBar().setElevation(0);
    setContentView(R.layout.tab_content);
    List<TabItem> mTabs = getTabItems();
    setTabs(mTabs);
    // setupHomeButton();
    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
    if (icicle == null) {
        Intent intent = getIntent();
        if (intent != null) {
            if (intent.hasExtra(OPEN_FAVOURITES_TAB) && intent.getBooleanExtra(OPEN_FAVOURITES_TAB, false)) {
                if (intent.hasExtra(GROUP_NAME_TO_SHOW)) {
                    groupNameToShow = intent.getStringExtra(GROUP_NAME_TO_SHOW);
                }
                mViewPager.setCurrentItem(0, false);
            } else if (intent.hasExtra(OPEN_MY_PLACES_TAB) && intent.getBooleanExtra(OPEN_MY_PLACES_TAB, false)) {
                mViewPager.setCurrentItem(1, false);
            }
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) ImportHelper(net.osmand.plus.helpers.ImportHelper)

Aggregations

ImportHelper (net.osmand.plus.helpers.ImportHelper)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 ViewPager (android.support.v4.view.ViewPager)1 DisplayMetrics (android.util.DisplayMetrics)1 MotionEvent (android.view.MotionEvent)1 ArrayList (java.util.ArrayList)1 Location (net.osmand.Location)1 MapAccessibilityActions (net.osmand.access.MapAccessibilityActions)1 QuadPoint (net.osmand.data.QuadPoint)1 DownloadRequest (net.osmand.map.MapTileDownloader.DownloadRequest)1 IMapDownloaderCallback (net.osmand.map.MapTileDownloader.IMapDownloaderCallback)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 MapViewTrackingUtilities (net.osmand.plus.base.MapViewTrackingUtilities)1 WhatsNewDialogFragment (net.osmand.plus.dialogs.WhatsNewDialogFragment)1 WakeLockHelper (net.osmand.plus.helpers.WakeLockHelper)1 ResourceManager (net.osmand.plus.resources.ResourceManager)1 NewGpxPoint (net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1