Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From where does the "handler" come from? #2

Closed
KerryKilian opened this issue Jan 14, 2021 · 6 comments
Closed

From where does the "handler" come from? #2

KerryKilian opened this issue Jan 14, 2021 · 6 comments

Comments

@KerryKilian
Copy link

Android studio does not know the "handler". How can I initilize it?

@westnordost
Copy link
Owner

The handler is the interface you implement yourself.

@westnordost westnordost added question Further information is requested and removed question Further information is requested labels Jan 14, 2021
@KerryKilian
Copy link
Author

Is it the class or the map or something else? Maybe you can give an example?

@westnordost
Copy link
Owner

For example

int nodes = 0;
int ways = 0;
int relations = 0;

overpassMapDataDao.queryElements("[bbox:13.8,35.5,14.9,36.3]; nwr[shop]; out meta;", new MapDataHandler() {
  public void handle(BoundingBox bounds) {
    // a bounding box was parsed from the overpass response, do something with it or not
  }

  public void handle(Node node) {
    // a node was parsed from the overpass response, do something with it or not
    nodes++;
  }

  public void handle(Way way) {
    // a way was parsed from the overpass response, do something with it or not
    ways++;
  }

  public void handle(Relation relation) {
    // a relation was parsed from the overpass response, do something with it or not
    relations++;
  }
});
System.out.println("On Malta, there are " (nodes+ways+relations) + " shops, of these: " + nodes + " nodes, " + ways + " ways and " + relations + " relations");

@KerryKilian
Copy link
Author

I get this error (and much more lines similar to that): Duplicate class org.jetbrains.annotations.Async$Execute found in modules jetified-annotations-16.0.1 (org.jetbrains:annotations:16.0.1) and jetified-annotations-java5-18.0 (org.jetbrains:annotations-java5:18.0.0)
Thanks by the way for your help:)

@westnordost
Copy link
Owner

Hm I don't remember what was the solution to it. The annotations used in this library collide with the annotations used in Android. In the gradle config, you can exclude certain dependencies to remove the duplicates. I am too busy so I can't help you now, try searching for the problem with google. When you found the solution, please let me know, then I can update the readme.

@KerryKilian
Copy link
Author

KerryKilian commented Jan 29, 2021

In build.gradle under android { } I added configurations { cleanedAnnotations compile.exclude group: 'org.jetbrains' , module:'annotations' all*.exclude group: 'xmlpull', module: 'xmlpull' }
The error disappears and my app is starting but crashes right after start. Now I have to figure out if these above lines caused the crash or something else in my code
EDIT: Your example code from above causes the crash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants