ArViewer  Android Version
Arvos - Augmented reality viewer open source
 All Classes Namespaces Files Functions Variables
ArvosTextView.java
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013, Peter Graf
3 
4  This file is part of Arvos - AR Viewer Open Source for Android.
5  Arvos is free software.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20  For more information on the AR Viewer Open Source or Peter Graf,
21  please see: http://www.mission-base.com/.
22  */
23 
24 package com.mission_base.arviewer_android.viewer;
25 
26 import com.mission_base.arviewer_android.Arvos;
27 
28 import android.content.Context;
29 import android.graphics.Color;
30 import android.location.Location;
31 import android.location.LocationManager;
32 import android.widget.TextView;
33 
40 public class ArvosTextView extends TextView
41 {
42  private LocationManager mLocationManager;
43 
44  public ArvosTextView(Context context)
45  {
46  super(context);
47  String svcName = Context.LOCATION_SERVICE;
48  mLocationManager = (LocationManager) Arvos.getInstance().getActivity().getSystemService(svcName);
49  setTextColor(Color.RED);
50  }
51 
55  public void updateWithNewLocation()
56  {
57  String provider = LocationManager.GPS_PROVIDER;
58  Location location = mLocationManager.getLastKnownLocation(provider);
59 
60  String latLongString = "No location found";
61  if (location != null)
62  {
63  latLongString = //
64  "Lat:" + location.getLatitude() //
65  + "\nLon:" + location.getLongitude() //
66  ;
67  }
68  latLongString += "\nFPS:" + Arvos.getInstance().mFPS //
69  + "\nAzi:" + Arvos.getInstance().mAzimuth //
70  + "\nPit:" + Arvos.getInstance().mPitch //
71  + "\nRol:" + Arvos.getInstance().mRoll //
72  + "\nOri:" + Arvos.getInstance().getRotationDegrees() //
73  + "\nDeg:" + Arvos.getInstance().mCorrectedAzimuth //
74  ;
75 
76  setText("Your Current mPosition is:\n" + latLongString);
77  }
78 }