art2limit / Compass-View

Android library. Arrow view shows from current location to desired
60 stars 15 forks source link

Awesome

Screen-gifs

Important

For correct library working arrow should be see straight up like this ⬆

Import

Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

And on module build.gradle

dependencies {
        compile 'com.github.art2limit:Compass-View:1.0.3'
    }

In your activity or fragment init CompassSensorManager and create CompassView like this:

    private CompassSensorManager compassSensorManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        compassSensorManager = new CompassSensorManager(this);

        CompassView compassView = new CompassView(this);
        compassView.init(compassSensorManager, location1, location2, R.drawable.icon_arrow);
    }

    @Override
    protected void onResume() {
        ...
        compassSensorManager.onResume();
    }

    @Override
    protected void onPause() {
        ...
        compassSensorManager.onPause();
    }

Don't forget call onResume and onPause, if you don't battery will be cry.