Search in sources :

Example 1 with Locations

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);
        }
    }
}
Also used : LocationManager(android.location.LocationManager) ArgbEvaluator(android.animation.ArgbEvaluator) Locations(com.mrane.data.Locations) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) SubsamplingScaleImageView(com.mrane.zoomview.SubsamplingScaleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) CampusMapView(com.mrane.zoomview.CampusMapView) ExpandableListView(android.widget.ExpandableListView) TextPaint(android.text.TextPaint)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 LocationManager (android.location.LocationManager)1 TextPaint (android.text.TextPaint)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ExpandableListView (android.widget.ExpandableListView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)1 Locations (com.mrane.data.Locations)1 CampusMapView (com.mrane.zoomview.CampusMapView)1 SubsamplingScaleImageView (com.mrane.zoomview.SubsamplingScaleImageView)1