Use play-services 9.2.0

This commit is contained in:
ligi 2016-07-05 22:22:18 +02:00
parent 5df92308a5
commit aac121e8c2
2 changed files with 55 additions and 73 deletions

View file

@ -4,7 +4,7 @@ buildscript {
support_version = '23.4.0'
dagger_version = '2.5'
butterknife_version = '8.1.0'
play_version = '9.0.2'
play_version = '9.2.0'
}
repositories {

View file

@ -3,12 +3,12 @@ package org.ligi.passandroid;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
@ -21,9 +21,9 @@ import org.ligi.passandroid.model.pass.PassLocation;
import org.ligi.passandroid.ui.PassViewActivityBase;
public class LocationsMapFragment extends SupportMapFragment {
private PassViewActivityBase base_activity;
public boolean click_to_fullscreen = false;
private Handler handler;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -35,85 +35,67 @@ public class LocationsMapFragment extends SupportMapFragment {
throw new IllegalArgumentException("LocationsMapFragment must be used inside a PassViewActivityBase");
}
final MapInitRunnable mapInitRunnable = new MapInitRunnable();
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final GoogleMap map) {
handler = new Handler();
handler.postDelayed(mapInitRunnable, 42);
return root;
}
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onResume() {
super.onResume();
}
boolean initDone;
private class MapInitRunnable implements Runnable {
@Override
public void run() {
final GoogleMap map = getMap();
if (map == null) {
// map not yet initialized - retry http://stackoverflow.com/questions/19219255/supportmapfragment-getmap-returns-null
handler.postDelayed(this, 230);
return;
}
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
boolean initDone;
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (initDone) {
return; // all done - not again
}
initDone = true;
LatLngBounds.Builder boundBuilder = new LatLngBounds.Builder();
List<PassLocation> locations = base_activity.currentPass.getLocations();
for (PassLocation l : locations) {
// yea that looks stupid but need to split LatLng free/nonfree - google play services ^^
LatLng latLng = new LatLng(l.lat, l.lon);
map.addMarker(new MarkerOptions()
.position(latLng)
.title(l.getName(base_activity.currentPass))
//.icon(BitmapDescriptorFactory.fromBitmap(base_activity.passbook.getIconBitmap())));
);
boundBuilder = boundBuilder.include(latLng);
}
map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("geo:" + marker.getPosition().latitude + "," + marker.getPosition().longitude + "?q=" + marker.getTitle()));
getActivity().startActivity(i);
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (initDone) {
return; // all done - not again
}
});
map.moveCamera(CameraUpdateFactory.newLatLngBounds(boundBuilder.build(), 100));
initDone = true;
// limit zoom-level to 17 - otherwise we could be so zoomed in that it looks buggy
map.moveCamera(CameraUpdateFactory.zoomTo(Math.min(17f, map.getCameraPosition().zoom)));
LatLngBounds.Builder boundBuilder = new LatLngBounds.Builder();
// Remove listener to prevent position reset on camera move.
map.setOnCameraChangeListener(null);
if (click_to_fullscreen)
map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
final List<PassLocation> locations = base_activity.currentPass.getLocations();
for (PassLocation l : locations) {
// yea that looks stupid but need to split LatLng free/nonfree - google play services ^^
LatLng latLng = new LatLng(l.lat, l.lon);
map.addMarker(new MarkerOptions()
.position(latLng)
.title(l.getName(base_activity.currentPass))
//.icon(BitmapDescriptorFactory.fromBitmap(base_activity.passbook.getIconBitmap())));
);
boundBuilder = boundBuilder.include(latLng);
}
map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onMapClick(LatLng latLng) {
App.component().passStore().setCurrentPass(base_activity.currentPass);
AXT.at(getActivity()).startCommonIntent().activityFromClass(FullscreenMapActivity.class);
public void onInfoWindowClick(Marker marker) {
final Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("geo:" + marker.getPosition().latitude + "," + marker.getPosition().longitude + "?q=" + marker.getTitle()));
getActivity().startActivity(i);
}
});
}
});
}
map.moveCamera(CameraUpdateFactory.newLatLngBounds(boundBuilder.build(), 100));
// limit zoom-level to 17 - otherwise we could be so zoomed in that it looks buggy
map.moveCamera(CameraUpdateFactory.zoomTo(Math.min(17f, map.getCameraPosition().zoom)));
// Remove listener to prevent position reset on camera move.
map.setOnCameraChangeListener(null);
if (click_to_fullscreen)
map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
App.component().passStore().setCurrentPass(base_activity.currentPass);
AXT.at(getActivity()).startCommonIntent().activityFromClass(FullscreenMapActivity.class);
}
});
}
});
}
});
return root;
}
}