<commit_before>// Copyright (C) 2016 History in Paderborn App - Universitt Paderborn
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//       http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using Android.App;
using Android.OS;
using Android.Support.V4.Content;
using Android.Views;
using de.upb.hip.mobile.pcl.BusinessLayer.Models;
using Osmdroid.TileProvider.TileSource;
using Osmdroid.Util;
using Osmdroid.Views;
using Osmdroid.Views.Overlay;

namespace de.upb.hip.mobile.droid.fragments {
    public class MapFragment : Fragment {

        /// <summary>
        /// ExhibitSet containing the exhibit that should be displayed in the RecyclerView.
        /// </summary>
        public ExhibitSet ExhibitSet { get; set; }

        /// <summary>
        /// GeoLocation for the current position of the user.
        /// </summary>
        public GeoLocation GeoLocation { get; set; }


        public override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
        }

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate (Resource.Layout.fragment_map, container, false);

            var mapView = view.FindViewById<MapView> (Resource.Id.mapview);
            // mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
            mapView.SetBuiltInZoomControls (true);

            mapView.SetTileSource (new XYTileSource ("OSM", 0, 18, 1024, ".png",
                                                     new[] {"http://tile.openstreetmap.org/"}));

            var mapController = mapView.Controller;
            mapController.SetZoom (13);

            // var centreOfMap = new GeoPoint(51496994, -134733);
            var centreOfMap = new GeoPoint (GeoLocation.Latitude, GeoLocation.Longitude);


            mapController.SetCenter (centreOfMap);

            SetAllMarkers (mapView);

            return view;
        }

        private void SetAllMarkers (MapView mapView)
        {
            //SetUp Markers TODO rewrite with markers from bonuspack
            var mapMarkerArray = new List<OverlayItem> ();
            var myLocationOverlay = new MyLocationOverlay (this.Activity, mapView);
            var mapMarkerIcon = ContextCompat.GetDrawable (this.Activity, Resource.Drawable.marker_blue);
            var myScaleBarOverlay = new ScaleBarOverlay (this.Activity);

            foreach (var e in ExhibitSet.ActiveSet)
            {
                //One Marker Object
                var marker = new OverlayItem (e.Marker.Title, e.Marker.Text, new GeoPoint (e.Location.Latitude, e.Location.Longitude));
                marker.SetMarker (mapMarkerIcon);
                mapMarkerArray.Add (marker);
            }

            //Initialize this after markers are added to 
            var mapMarkerItemizedOverlay = new ItemizedIconOverlay (this.Activity, mapMarkerArray, null);
            mapView.OverlayManager.Add (mapMarkerItemizedOverlay);
            mapView.OverlayManager.Add (myScaleBarOverlay);
            mapView.OverlayManager.Add (myLocationOverlay);
            mapView.PostInvalidate ();
        }

    }
}<commit_msg>Adds onPause/onResume for compass/location updates.<commit_after>// Copyright (C) 2016 History in Paderborn App - Universitt Paderborn
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//       http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using Android.App;
using Android.OS;
using Android.Support.V4.Content;
using Android.Views;
using de.upb.hip.mobile.pcl.BusinessLayer.Models;
using Osmdroid.TileProvider.TileSource;
using Osmdroid.Util;
using Osmdroid.Views;
using Osmdroid.Views.Overlay;

namespace de.upb.hip.mobile.droid.fragments {
    public class MapFragment : Fragment {

        /// <summary>
        /// ExhibitSet containing the exhibit that should be displayed in the RecyclerView.
        /// </summary>
        public ExhibitSet ExhibitSet { get; set; }

        /// <summary>
        /// GeoLocation for the current position of the user.
        /// </summary>
        public GeoLocation GeoLocation { get; set; }

        /// <summary>
        /// LocationOverlay used for the map.
        /// </summary>
        private MyLocationOverlay LocationOverlay { get; set; }


        public override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
        }

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate (Resource.Layout.fragment_map, container, false);

            var mapView = view.FindViewById<MapView> (Resource.Id.mapview);
            // mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
            mapView.SetBuiltInZoomControls (true);

            mapView.SetTileSource (new XYTileSource ("OSM", 0, 18, 1024, ".png",
                                                     new[] {"http://tile.openstreetmap.org/"}));

            var mapController = mapView.Controller;
            mapController.SetZoom (13);

            // var centreOfMap = new GeoPoint(51496994, -134733);
            var centreOfMap = new GeoPoint (GeoLocation.Latitude, GeoLocation.Longitude);
            mapController.SetCenter (centreOfMap);

            SetAllMarkers (mapView);

            return view;
        }

        private void SetAllMarkers (MapView mapView)
        {
            //SetUp Markers TODO rewrite with markers from bonuspack
            var mapMarkerArray = new List<OverlayItem> ();
            LocationOverlay = new MyLocationOverlay (this.Activity, mapView);
            var mapMarkerIcon = ContextCompat.GetDrawable (this.Activity, Resource.Drawable.marker_blue);
            var myScaleBarOverlay = new ScaleBarOverlay (this.Activity);

            foreach (var e in ExhibitSet.ActiveSet)
            {
                //One Marker Object
                var marker = new OverlayItem (e.Marker.Title, e.Marker.Text, new GeoPoint (e.Location.Latitude, e.Location.Longitude));
                marker.SetMarker (mapMarkerIcon);
                mapMarkerArray.Add (marker);
            }

            //Initialize this after markers are added to 
            var mapMarkerItemizedOverlay = new ItemizedIconOverlay (this.Activity, mapMarkerArray, null);
            mapView.OverlayManager.Add (mapMarkerItemizedOverlay);
            mapView.OverlayManager.Add (myScaleBarOverlay);
            mapView.OverlayManager.Add (LocationOverlay);
            mapView.PostInvalidate ();
        }

        public override void OnResume ()
        {
            base.OnResume ();
            LocationOverlay.EnableMyLocation ();
            LocationOverlay.EnableCompass ();
        }

        public override void OnPause ()
        {
            base.OnPause ();
            LocationOverlay.DisableMyLocation ();
            LocationOverlay.DisableCompass ();
        }

    }
}
{'fraction_non_alphanumeric': 0.08865514650638617, 'fraction_numerical': 0.008014024542950162, 'mean_word_length': 2.316860465116279, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669762', 'n_tokens_mistral': 2112, 'n_tokens_neox': 2018, 'n_words': 601}