use of com.mrane.data.Locations in project IITB-App by wncc.
the class MapFragment method setupWithData.
private void setupWithData(List<Venue> venues) {
if (getActivity() == null || getView() == null || getContext() == null)
return;
// Setup fade animation for background
int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
int colorTo = getResources().getColor(R.color.colorGray);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
// milliseconds
colorAnimation.setDuration(250);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
if (getActivity() == null || getView() == null)
return;
getView().findViewById(R.id.main_container).setBackgroundColor((int) animator.getAnimatedValue());
}
});
colorAnimation.start();
// Show the location fab
if (getView() == null)
return;
((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
// Start the setup
Locations mLocations = new Locations(venues);
data = mLocations.data;
markerlist = new ArrayList<>(data.values());
if (getArguments() != null) {
setupMap(getArguments().getString(Constants.MAP_INITIAL_MARKER));
}
// Setup locate button
FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locate(true);
}
});
// Setup GPS if already has permission and GPS is on
String permission = Manifest.permission.ACCESS_FINE_LOCATION;
int res = getContext().checkCallingOrSelfPermission(permission);
if (res == PackageManager.PERMISSION_GRANTED) {
final LocationManager manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locate(false);
setFollowingUser(false);
}
}
}
Aggregations