Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
886db27a
Commit
886db27a
authored
Jul 15, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add locate button to InstiMap
parent
b960d2d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
27 deletions
+58
-27
app/src/main/java/app/insti/MainActivity.java
app/src/main/java/app/insti/MainActivity.java
+1
-2
app/src/main/java/app/insti/fragment/MapFragment.java
app/src/main/java/app/insti/fragment/MapFragment.java
+40
-23
app/src/main/res/layout/fragment_map.xml
app/src/main/res/layout/fragment_map.xml
+17
-2
No files found.
app/src/main/java/app/insti/MainActivity.java
View file @
886db27a
...
...
@@ -313,8 +313,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return
;
case
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION:
if
(
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
MapFragment
mapFragment
=
new
MapFragment
();
updateFragment
(
mapFragment
);
MapFragment
.
getMainActivity
().
setupGPS
();
}
else
{
Toast
toast
=
Toast
.
makeText
(
MainActivity
.
this
,
"Need Permission"
,
Toast
.
LENGTH_SHORT
);
toast
.
show
();
...
...
app/src/main/java/app/insti/fragment/MapFragment.java
View file @
886db27a
...
...
@@ -4,6 +4,7 @@ import android.Manifest;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.content.res.ColorStateList
;
import
android.content.res.Configuration
;
import
android.graphics.Color
;
import
android.graphics.PointF
;
...
...
@@ -20,6 +21,7 @@ import android.media.SoundPool;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentManager
;
...
...
@@ -188,18 +190,36 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
public
void
onResponse
(
Call
<
List
<
Venue
>>
call
,
Response
<
List
<
Venue
>>
response
)
{
if
(
response
.
isSuccessful
())
{
Locations
mLocations
=
new
Locations
(
response
.
body
());
data
=
mLocations
.
data
;
markerlist
=
new
ArrayList
<
com
.
mrane
.
data
.
Marker
>(
data
.
values
());
setUpDrawer
();
setupMap
();
setupGPS
();
setupWithData
(
response
.
body
());
}
}
@Override
public
void
onFailure
(
Call
<
List
<
Venue
>>
call
,
Throwable
t
)
{
}
public
void
onFailure
(
Call
<
List
<
Venue
>>
call
,
Throwable
t
)
{
setupWithData
(
new
ArrayList
<
Venue
>());
}
});
}
void
setupWithData
(
List
<
Venue
>
venues
)
{
Locations
mLocations
=
new
Locations
(
venues
);
data
=
mLocations
.
data
;
markerlist
=
new
ArrayList
<
com
.
mrane
.
data
.
Marker
>(
data
.
values
());
setUpDrawer
();
setupMap
();
// Setup locate button
FloatingActionButton
fab
=
getView
().
findViewById
(
R
.
id
.
locate_fab
);
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
locate
();
}
});
}
private
void
locate
()
{
setupGPS
();
}
...
...
@@ -1038,17 +1058,17 @@ public class MapFragment extends Fragment implements TextWatcher,
ActivityCompat
.
requestPermissions
(
getActivity
(),
new
String
[]{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
MY_PERMISSIONS_REQUEST_LOCATION
);
}
LocationManager
locationManager
=
(
LocationManager
)
getActivity
().
getSystemService
(
Context
.
LOCATION_SERVICE
);
LocationListener
locationListener
=
new
MyLocationListener
();
try
{
locationManager
.
requestLocationUpdates
(
LocationManager
.
GPS_PROVIDER
,
50
,
1
,
locationListen
er
);
campusMapView
.
addMarker
(
user
);
}
catch
(
SecurityException
ignored
)
{
Toast
.
makeText
(
getContext
(),
"No permission!"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
LocationManager
locationManager
=
(
LocationManager
)
getActivity
().
getSystemService
(
Context
.
LOCATION_SERVICE
);
LocationListener
locationListener
=
new
MyLocationListener
(
);
try
{
locationManager
.
requestLocationUpdates
(
LocationManager
.
GPS_PROVIDER
,
50
,
1
,
locationListener
);
campusMapView
.
addMarker
(
us
er
);
}
catch
(
SecurityException
ignored
)
{
Toast
.
makeText
(
getContext
(),
"No permission!"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
...
...
@@ -1057,6 +1077,8 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
public
void
onLocationChanged
(
Location
loc
)
{
if
(
getView
()
==
null
||
getActivity
()
==
null
)
return
;
Toast
.
makeText
(
getActivity
().
getBaseContext
(),
"Location changed: Lat: "
+
loc
.
getLatitude
()
+
" Lng: "
...
...
@@ -1075,11 +1097,6 @@ public class MapFragment extends Fragment implements TextWatcher,
A
=
new
double
[]
{
0.010619520345247447
,
-
14.46472789089445
,
61.00432524817795
,
12.593699865482979
,
-
1.3923808471860513
,
0.05646175191919056
,
0.3826096686410426
,
0.07802615132849677
,
-
10.35622400664665
};
int
py
=
(
int
)(
Zyn
+
A
[
0
]
+
A
[
1
]*
x
+
A
[
2
]*
y
+
A
[
3
]*
x
*
x
+
A
[
4
]*
x
*
x
*
y
+
A
[
5
]*
x
*
x
*
y
*
y
+
A
[
6
]*
y
*
y
+
A
[
7
]*
x
*
y
*
y
+
A
[
8
]*
x
*
y
);
/*Toast.makeText(
getActivity().getBaseContext(),
"Location changed: Lat: " + px + " Lng: "
+ py, Toast.LENGTH_SHORT).show();*/
if
(
px
>
0
&&
py
>
0
&&
px
<
5430
&&
py
<
5375
){
user
.
setPoint
(
new
PointF
(
px
,
py
));
SubsamplingScaleImageView
.
AnimationBuilder
anim
=
campusMapView
.
animateCenter
(
user
.
getPoint
());
...
...
app/src/main/res/layout/fragment_map.xml
View file @
886db27a
...
...
@@ -140,10 +140,10 @@
</LinearLayout>
<RelativeLayout
android:id=
"@+id/loadingPanel"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
android:gravity=
"center"
android:id=
"@+id/loadingPanel"
>
<ProgressBar
android:layout_width=
"wrap_content"
...
...
@@ -151,4 +151,19 @@
android:indeterminate=
"true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/locate_fab"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_alignParentRight=
"true"
android:layout_margin=
"16dp"
android:src=
"@drawable/ic_my_location_black_24dp"
android:tint=
"@android:color/black"
/>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment