gt:             mapView = new MapView(context);
context: /*
   * This is the source code of Telegram for Android v. 3.x.x.
   * It is licensed under GNU GPL v. 2 or later.
   * You should have received a copy of the license in this archive (see LICENSE).
   *
   * Copyright Nikolai Kudashov, 2013-2016.
   */
  
  package org.telegram.ui;
  
  import android.Manifest;
  import android.animation.AnimatorSet;
  import android.animation.ObjectAnimator;
  import android.animation.StateListAnimator;
  import android.annotation.SuppressLint;
  import android.annotation.TargetApi;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.pm.PackageManager;
  import android.graphics.Outline;
  import android.location.Location;
  import android.location.LocationManager;
  import android.net.Uri;
  import android.os.Build;
  import android.text.TextUtils;
  import android.util.TypedValue;
  import android.view.Gravity;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.ViewOutlineProvider;
  import android.widget.AbsListView;
  import android.widget.AdapterView;
  import android.widget.EditText;
  import android.widget.FrameLayout;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.ListView;
  import android.widget.TextView;
  
  import com.google.android.gms.maps.CameraUpdate;
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapView;
  import com.google.android.gms.maps.MapsInitializer;
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
  import com.google.android.gms.maps.model.CircleOptions;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  import org.telegram.messenger.AndroidUtilities;
  import org.telegram.messenger.ApplicationLoader;
  import org.telegram.messenger.FileLog;
  import org.telegram.messenger.LocaleController;
  import org.telegram.messenger.MessageObject;
  import org.telegram.messenger.MessagesController;
  import org.telegram.messenger.NotificationCenter;
  import org.telegram.messenger.R;
  import org.telegram.messenger.UserObject;
  import org.telegram.tgnet.TLRPC;
  import org.telegram.ui.ActionBar.ActionBar;
  import org.telegram.ui.ActionBar.ActionBarMenu;
  import org.telegram.ui.ActionBar.ActionBarMenuItem;
  import org.telegram.ui.ActionBar.BaseFragment;
  import org.telegram.ui.Adapters.BaseLocationAdapter;
  import org.telegram.ui.Adapters.LocationActivityAdapter;
  import org.telegram.ui.Adapters.LocationActivitySearchAdapter;
  import org.telegram.ui.Components.AvatarDrawable;
  import org.telegram.ui.Components.BackupImageView;
  import org.telegram.ui.Components.LayoutHelper;
  import org.telegram.ui.Components.MapPlaceholderDrawable;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Locale;
  
  public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
  
      private final static int share = 1;
      private final static int map_list_menu_map = 2;
      private final static int map_list_menu_satellite = 3;
      private final static int map_list_menu_hybrid = 4;
      private GoogleMap googleMap;
      private TextView distanceTextView;
      private BackupImageView avatarImageView;
      private TextView nameTextView;
      private MapView mapView;
      private FrameLayout mapViewClip;
      private LocationActivityAdapter adapter;
      private ListView listView;
      private ListView searchListView;
      private LocationActivitySearchAdapter searchAdapter;
      private LinearLayout emptyTextLayout;
      private ImageView markerImageView;
      private ImageView markerXImageView;
      private ImageView locationButton;
      private AnimatorSet animatorSet;
      private boolean checkPermission = true;
      private boolean searching;
      private boolean searchWas;
      private boolean wasResults;
      private Location myLocation;
      private Location userLocation;
      private int markerTop;
      private MessageObject messageObject;
      private boolean userLocationMoved = false;
      private boolean firstWas = false;
      private CircleOptions circleOptions;
      private LocationActivityDelegate delegate;
      private int overScrollHeight = AndroidUtilities.displaySize.x - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(66);
  
      @Override
      public boolean onFragmentCreate() {
          super.onFragmentCreate();
          swipeBackEnabled = false;
          NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
          NotificationCenter.getInstance().addObserver(this, NotificationCenter.locationPermissionGranted);
          if (messageObject != null) {
              NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
          }
          return true;
      }
  
      @Override
      public void onFragmentDestroy() {
          super.onFragmentDestroy();
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.locationPermissionGranted);
          NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
          try {
              if (mapView != null) {
                  mapView.onDestroy();
              }
          } catch (Exception e) {
              FileLog.e("tmessages", e);
          }
          if (adapter != null) {
              adapter.destroy();
          }
          if (searchAdapter != null) {
              searchAdapter.destroy();
          }
      }
  
      @Override
      public View createView(Context context) {
          actionBar.setBackButtonImage(R.drawable.ic_ab_back);
          actionBar.setAllowOverlayTitle(true);
          if (AndroidUtilities.isTablet()) {
              actionBar.setOccupyStatusBar(false);
          }
          actionBar.setAddToContainer(messageObject != null);
  
          actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
              @Override
              public void onItemClick(int id) {
                  if (id == -1) {
                      finishFragment();
                  } else if (id == map_list_menu_map) {
                      if (googleMap != null) {
                          googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                      }
                  } else if (id == map_list_menu_satellite) {
                      if (googleMap != null) {
                          googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
                      }
                  } else if (id == map_list_menu_hybrid) {
                      if (googleMap != null) {
                          googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
                      }
                  } else if (id == share) {
                      try {
                          double lat = messageObject.messageOwner.media.geo.lat;
                          double lon = messageObject.messageOwner.media.geo._long;
                          getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon)));
                      } catch (Exception e) {
                          FileLog.e("tmessages", e);
                      }
                  }
              }
          });
  
          ActionBarMenu menu = actionBar.createMenu();
          if (messageObject != null) {
              if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) {
                  actionBar.setTitle(messageObject.messageOwner.media.title);
                  if (messageObject.messageOwner.media.address != null && messageObject.messageOwner.media.address.length() > 0) {
                      actionBar.setSubtitle(messageObject.messageOwner.media.address);
                  }
              } else {
                  actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
              }
              menu.addItem(share, R.drawable.share);
          } else {
              actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
  
              ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
                  @Override
                  public void onSearchExpand() {
                      searching = true;
                      listView.setVisibility(View.GONE);
                      mapViewClip.setVisibility(View.GONE);
                      searchListView.setVisibility(View.VISIBLE);
                      searchListView.setEmptyView(emptyTextLayout);
                  }
  
                  @Override
                  public void onSearchCollapse() {
                      searching = false;
                      searchWas = false;
                      searchListView.setEmptyView(null);
                      listView.setVisibility(View.VISIBLE);
                      mapViewClip.setVisibility(View.VISIBLE);
                      searchListView.setVisibility(View.GONE);
                      emptyTextLayout.setVisibility(View.GONE);
                      searchAdapter.searchDelayed(null, null);
                  }
  
                  @Override
                  public void onTextChanged(EditText editText) {
                      if (searchAdapter == null) {
                          return;
                      }
                      String text = editText.getText().toString();
                      if (text.length() != 0) {
                          searchWas = true;
                      }
                      searchAdapter.searchDelayed(text, userLocation);
                  }
              });
              item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
          }
  
          ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
          item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0);
          item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0);
          item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0);
          fragmentView = new FrameLayout(context) {
              private boolean first = true;
  
              @Override
              protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
                  super.onLayout(changed, left, top, right, bottom);
  
                  if (changed) {
                      fixLayoutInternal(first);
                      first = false;
                  }
              }
          };
          FrameLayout frameLayout = (FrameLayout) fragmentView;
  
          locationButton = new ImageView(context);
          locationButton.setBackgroundResource(R.drawable.floating_user_states);
          locationButton.setImageResource(R.drawable.myloc_on);
          locationButton.setScaleType(ImageView.ScaleType.CENTER);
          if (Build.VERSION.SDK_INT >= 21) {
              StateListAnimator animator = new StateListAnimator();
              animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(locationButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
              animator.addState(new int[]{}, ObjectAnimator.ofFloat(locationButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
              locationButton.setStateListAnimator(animator);
              locationButton.setOutlineProvider(new ViewOutlineProvider() {
                  @SuppressLint("NewApi")
                  @Override
                  public void getOutline(View view, Outline outline) {
                      outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
                  }
              });
          }
  
          if (messageObject != null) {
  