Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. accept.setOnClickListener(new View.OnClickListener() {
  2.     @Override
  3.     public void onClick(View view) {
  4.         customDialog.dismiss();
  5.  
  6.         Location userClickedLocation = mRealm.createObject(Location.class);
  7.         String address = getAddressFromLngLat(point.getLatitude(), point.getLongitude());
  8.         Latitude lat = point.getLatitude();
  9.         Longitude long = point.getLongitude();
  10.  
  11.         saveToDb(address, lat, long);
  12.  
  13.         MarkerOptions markerOptions = new MarkerOptions();
  14.         markerOptions.setPosition(point);
  15.         mapboxMap.addMarker(markerOptions);
  16.     }
  17. });
  18.  
  19. private void saveToDb(String address, lat: Latitude, long: Longitude) {
  20.     new HandlerThread("RealmThread") {
  21.         @Override
  22.         protected void onLooperPrepared() {
  23.             mRealm.beginTransaction();
  24.  
  25.             Location userClickedLocation = mRealm.createObject(Location.class);
  26.             userClickedLocation.setAddress(address);
  27.             userClickedLocation.setLat(lat);
  28.             userClickedLocation.setLng(long);
  29.             mRealm.commitTransaction();
  30.         }
  31.     }.start();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement