/*
 * Copyright (C) 2016 team-cachebox.de
 *
 * Licensed under the : GNU General Public License (GPL);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.gnu.org/licenses/gpl.html
 *
 * 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.
 */
package de.longri.cachebox3.gui.views;

import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import de.longri.cachebox3.CacheboxMain;
import de.longri.cachebox3.gui.stages.StageManager;
import org.oscim.gdx.LayerHandler;
import org.oscim.gdx.MotionHandler;

/**
 * The MapView has transparent background. The Map render runs at CacheboxMain.
 * This View has only the controls for the Map!
 * Created by Longri on 24.07.16.
 */
public class MapView extends AbstractView {

    InputMultiplexer mapInputHandler;

    public MapView() {
        super("MapView");
        this.setTouchable(Touchable.disabled);
    }

    @Override
    protected void create() {

    }

    @Override
    public void onShow() {
        CacheboxMain.drawMap = true;
        // map input handler
        GestureDetector gestureDetectore = new GestureDetector(new LayerHandler(CacheboxMain.mMap));
        MotionHandler motionHandler = new MotionHandler(CacheboxMain.mMap);
        MapInputHandler inputHandler = new MapInputHandler(CacheboxMain.mMap);
        mapInputHandler = new InputMultiplexer();
        mapInputHandler.addProcessor(motionHandler);
        mapInputHandler.addProcessor(gestureDetectore);
        mapInputHandler.addProcessor(inputHandler);
        StageManager.addMapMultiplexer(mapInputHandler);
    }

    @Override
    public void onHide() {
        CacheboxMain.drawMap = false;
        StageManager.removeMapMultiplexer(mapInputHandler);
    }


    @Override
    public void dispose() {

    }
}

@@ -851,24 +851,280 @@
 ageManager;%0A
+import de.longri.cachebox3.locator.Location;%0Aimport de.longri.cachebox3.locator.Locator;%0Aimport de.longri.cachebox3.locator.events.PositionChangedEvent;%0Aimport de.longri.cachebox3.locator.events.PositionChangedEventList;%0Aimport org.oscim.core.MapPosition;%0A
 import org.o
@@ -1183,16 +1183,70 @@
 ndler;%0A%0A
+import static de.longri.cachebox3.CacheboxMain.mMap;%0A%0A
 /**%0A * T
@@ -1449,16 +1449,48 @@
 actView 
+implements PositionChangedEvent 
 %7B%0A%0A    I
@@ -1861,37 +1861,24 @@
 ayerHandler(
-CacheboxMain.
 mMap));%0A    
@@ -1925,37 +1925,24 @@
 tionHandler(
-CacheboxMain.
 mMap);%0A     
@@ -1995,29 +1995,16 @@
 Handler(
-CacheboxMain.
 mMap);%0A 
@@ -2266,24 +2266,68 @@
 utHandler);%0A
+        PositionChangedEventList.Add(this);%0A
     %7D%0A%0A    @
@@ -2456,24 +2456,71 @@
 utHandler);%0A
+        PositionChangedEventList.Remove(this);%0A
     %7D%0A%0A%0A    
@@ -2563,11 +2563,614 @@
 %7B%0A%0A    %7D
+%0A%0A    @Override%0A    public void PositionChanged() %7B%0A        MapPosition curentMapPosition = mMap.getMapPosition();%0A        Location curentLocation = Locator.getLocation();%0A        curentMapPosition.setPosition(curentLocation.latitude, curentLocation.longitude);%0A        mMap.setMapPosition(curentMapPosition);%0A    %7D%0A%0A    @Override%0A    public void OrientationChanged() %7B%0A%0A    %7D%0A%0A    @Override%0A    public void SpeedChanged() %7B%0A%0A    %7D%0A%0A    @Override%0A    public String getReceiverName() %7B%0A        return %22MapView%22;%0A    %7D%0A%0A    @Override%0A    public Priority getPriority() %7B%0A        return Priority.High;%0A    %7D
 %0A%7D%0A

set MapPosition with incoming new GPS position