Coder Social home page Coder Social logo

pelias / pelias-android-sdk Goto Github PK

View Code? Open in Web Editor NEW
20.0 23.0 5.0 416 KB

Android sdk for pelias

License: Other

Java 98.14% Shell 1.86%
search android android-library android-development location location-based pelias java geolocation geocoding

pelias-android-sdk's Introduction

Pelias Android SDK

Android SDK for Pelias

Circle CI

Usage

Pelias Android SDK is a client-side Java wrapper for Pelias plus Android specific integrations.

Initialization

The Pelias class provides a simple interface to the Pelias geocoder which can be included in your application.

Pelias pelias = new Pelias();

Suggest

The suggest endpoint provides fast type-ahead autocomplete results.

pelias.suggest("term to search", lat, lon, Callback<Result>);

Search

The search endpoint provides locally and globally relevant full-text search results for addresses and POIs.

pelias.search("term to search", lat, lon, Callback<Result>);

Custom Endpoint

If you have deployed your own instance of Pelias you can set it on the class before initializing.

Pelias pelias = new Pelias("https://your-pelias-domain.com");

Testing

The current strategy for testing involves mocking the service instance using a Retrofit interface which describes the paths to the API.

package com.mapzen.android;

import org.mockito.Mockito;

public class TestPelias extends Pelias {
  public TestPelias(PeliasService service) {
    super(service);
  }
  
  private class TestPeliasService implements PeliasService {
    @Override public Call<Result> getSuggest(@Query("text") String query,
        @Query("focus.point.lat") double lat, @Query("focus.point.lon") double lon) {
      return new TestCall();
    }
    ..
  }
  
  private class TestCall implements Call<Result> {
    @Override public Response<Result> execute() throws IOException {
      return Response.success(new Result());
    }

    @Override public void enqueue(Callback<Result> callback) {
      callback.onResponse(null, Response.success(new Result()));
    }
  }
}

Install

Download Jar

Download the latest AAR.

Maven

Include dependency using Maven.

<dependency>
  <groupId>com.mapzen.android</groupId>
  <artifactId>pelias-android-sdk</artifactId>
  <version>1.3.1</version>
</dependency>

Gradle

Include dependency using Gradle.

compile 'com.mapzen.android:pelias-android-sdk:1.3.1'

pelias-android-sdk's People

Contributors

baldur avatar ecgreb avatar kingofirony avatar mapnerd avatar msmollin avatar sarahsnow1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pelias-android-sdk's Issues

Name or address?

Add logic to determine if "name" field for an individual feature contains a POI name or a street address.

Set cursor position

Description

PeliasSearchView should allow cursor position to be set without performing a lookup on the EditText.

Steps to Reproduce

Currently cursor position can be set with the following code:

val editText = peliasSearchView.findViewById(R.id.search_src_text) as EditText?
editText?.setSelection(editText.text.length)

Client apps should not have to execute findViewById(R.id.search_src_text) to set the selection. Instead we should expose an API to set the position:

peliasSearchView.setCursorPosition(peliasSearchView.query.length)

Allow custom search behavior

Clients should be able to determine whether or not they want to:

  • execute a search
  • hide autocomplete list view

The current default does both when the search key is pressed

Remove copyTask? (Upgrade Robolectric)

Test if the custom Gradle task to copy com/mapzen/pelias/R.java to android/support/v7/appcompat/R.java is still required in the latest version Roboletric (3.1.2).

If this task is still needed then our configuration of the Gradle Release plugin needs to be updated to automatically trigger the copyTask at the appropriate time in the release build process.

NPE

Description

Exception thrown when response has no body. Check to see why there isn't a body/on which queries this occurs.

01-05 14:30:15.021 31687-31687/com.mapzen.places.api.sample E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: com.mapzen.places.api.sample, PID: 31687
                                                                              java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.mapzen.pelias.gson.Result.getFeatures()' on a null object reference
                                                                                  at com.mapzen.pelias.widget.PeliasSearchView$6.onResponse(PeliasSearchView.java:241)
                                                                                  at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:158)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

[search] Pelias API field deprecation

As a follow up to this issue: mapzen/open#358

we don't use this property so I believe it should work just fine
I think you'll find it's being used to derive the doc ids, in places such as:
https://github.com/mapzen/pelias-android-sdk/blob/68e036553f68af8b33227abdd195bcb8ba2e9e3e/src/main/java/com/mapzen/android/Pelias.java#L55

Ping me when you have a development build out for it so we can verify that
Due to the financial cost and complexity of running the prod cluster we don't currently have a staging env and probably won't ever have one, when you are happy with what is currently live I will kill the type property.

[edit] scratch that, we could potentially deploy a custom pelias/api repo to a box in the live env to test against if you find it helpful, it would require a bit of @heffergm 's time, so let us know if you need that.

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.