Facebook Friends Mapper Android Today

private void showFriendDetailsDialog(FriendLocation friend) { new AlertDialog.Builder(this) .setTitle(friend.name) .setMessage("Location: " + friend.location + "\n" + "Coordinates: " + friend.latitude + ", " + friend.longitude) .setPositiveButton("Close", null) .setNeutralButton("Show on Map", (dialog, which) -> { LatLng position = new LatLng(friend.latitude, friend.longitude); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position, 12)); }) .show(); }

<Button android:id="@+id/loginButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="FB Login" /> facebook friends mapper android

private void fetchFriendsAndLocations() { progressBar.setVisibility(View.VISIBLE); statusText.setText("Loading friends..."); GraphRequest request = GraphRequest.newMeRequest( AccessToken.getCurrentAccessToken(), (object, response) -> { if (object != null) { try { JSONObject friends = object.getJSONObject("friends"); JSONArray data = friends.getJSONArray("data"); for (int i = 0; i < data.length(); i++) { JSONObject friend = data.getJSONObject(i); String name = friend.getString("name"); String id = friend.getString("id"); // Fetch friend's location info fetchFriendLocation(id, name); } statusText.setText("Found " + data.length() + " friends"); progressBar.setVisibility(View.GONE); } catch (Exception e) { e.printStackTrace(); statusText.setText("Error parsing friends data"); } } } ); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,friends.limit(100){id,name,location}"); request.setParameters(parameters); request.executeAsync(); } " + friend.longitude) .setPositiveButton("Close"

private void fetchFriendLocation(String friendId, String friendName) { GraphRequest request = GraphRequest.newGraphPathRequest( AccessToken.getCurrentAccessToken(), friendId, response -> { try { JSONObject friendData = response.getJSONObject(); if (friendData.has("location")) { JSONObject location = friendData.getJSONObject("location"); String locationName = location.getString("name"); // Geocode location name to coordinates geocodeLocation(locationName, friendName); } } catch (Exception e) { // No location available for this friend } } ); Bundle params = new Bundle(); params.putString("fields", "location"); request.setParameters(params); request.executeAsync(); } null) .setNeutralButton("Show on Map"

private Map<String, FriendLocation> friendMarkers = new HashMap<>(); private List<FriendLocation> allFriends = new ArrayList<>();

<Button android:id="@+id/filterButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Filter" />

public class FacebookFriendsMapperActivity extends AppCompatActivity implements OnMapReadyCallback {