use of com.omkarmoghe.pokemap.controllers.map.LocationManager in project Pokemap by omkarmoghe.
the class MapWrapperFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
locationManager = LocationManager.getInstance(getContext());
nianticManager = NianticManager.getInstance();
locationManager.register(new LocationManager.Listener() {
@Override
public void onLocationChanged(Location location) {
if (mLocation == null) {
mLocation = location;
initMap(true, true);
} else {
mLocation = location;
}
}
@Override
public void onLocationFetchFailed(@Nullable ConnectionResult connectionResult) {
showLocationFetchFailed();
}
});
// Inflate the layout for this fragment if the view is not null
if (mView == null)
mView = inflater.inflate(R.layout.fragment_map_wrapper, container, false);
else {
}
// build the map
if (mSupportMapFragment == null) {
mSupportMapFragment = SupportMapFragment.newInstance();
getChildFragmentManager().beginTransaction().replace(R.id.map, mSupportMapFragment).commit();
mSupportMapFragment.setRetainInstance(true);
}
if (mGoogleMap == null) {
mSupportMapFragment.getMapAsync(this);
}
FloatingActionButton locationFab = (FloatingActionButton) mView.findViewById(R.id.location_fab);
locationFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mLocation != null && mGoogleMap != null) {
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()), 15));
} else {
showLocationFetchFailed();
}
}
});
mView.findViewById(R.id.closeSuggestions).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideMapSuggestion();
}
});
if (!mPref.getShowMapSuggestion()) {
hideMapSuggestion();
}
return mView;
}
Aggregations