Code Monkey home page Code Monkey logo

flipper-mapbox's Introduction

Flipper + Mapbox

Mapbox integration and sample plugin for Facebook Flipper.

This project shows how to configure Flipper with the Mapbox Maps SDK for Android, and contains a sample plugin that sends map events to Flipper.

NetworkFlipperPlugin

image

Instantiate the plugin:

val networkFlipperPlugin = NetworkFlipperPlugin()

Create a new OkHttp object and add NetworkFlipperPlugin as an interceptor:

val okHttpClient = OkHttpClient.Builder()
    .addNetworkInterceptor(FlipperOkhttpInterceptor(networkFlipperPlugin))
    .build()

Finally, pass this OkHttp client to Mapbox and enable the plugin:

HttpRequestUtil.setOkHttpClient(okHttpClient)
client.addPlugin(networkFlipperPlugin)

SharedPreferencesFlipperPlugin

image

You can follow Mapbox-specific preferences key/values by setting up SharedPreferencesFlipperPlugin with the Mapbox preferences filename (MapboxConstants is provided by the Maps SDK):

client.addPlugin(
    SharedPreferencesFlipperPlugin(this, MapboxConstants.MAPBOX_SHARED_PREFERENCES)
)

DatabasesFlipperPlugin

image

The Maps SDK stores the style resources in a local SQLite database. You can browse the content of this database by using the MapboxEventsFlipperPlugin.getDatabaseFiles() utility method:

client.addPlugin(
    DatabasesFlipperPlugin(
        SqliteDatabaseDriver(this,
            SqliteDatabaseProvider { MapboxEventsFlipperPlugin.getDatabaseFiles(this) })
    )
)

Mapbox Events Plugin

image

This repo contains a new and experimental plugin that sends map events to Flipper. It currently supports:

  • Connectivity status
  • Access token
  • Map events: onWillStartLoadingMap and onDidFinishLoadingMap.

Installing it is a two-step process. First, register plugin (this example uses Koin for dependency injection in the Application class):

val flipperPlugin: MapboxEventsFlipperPlugin = get()
client.addPlugin(flipperPlugin)

Then, in the Fragment or Activity where you instantiate the map, install the listeners:

private val flipperPlugin: MapboxEventsFlipperPlugin by inject()

...

mapView?.addOnWillStartLoadingMapListener(flipperPlugin)
mapView?.addOnDidFinishLoadingMapListener(flipperPlugin)

flipper-mapbox's People

Contributors

zugaldia avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.