daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top