Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Test app fixes 7.1.0 QA #13773

Merged
merged 4 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,30 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
private static final double ANIMATION_DELAY_FACTOR = 1.5;
private static final LatLng START_LAT_LNG = new LatLng(37.787947, -122.407432);

private final LongSparseArray<AnimatorBuilder> animators = new LongSparseArray<AnimatorBuilder>() {
{
put(R.id.menu_action_accelerate_decelerate_interpolator, () -> {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
createLatLngAnimator(START_LAT_LNG, new LatLng(37.826715, -122.422795)),
obtainExampleInterpolator(new FastOutSlowInInterpolator(), 2500)
);
return animatorSet;
});

put(R.id.menu_action_bounce_interpolator, () -> {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
createLatLngAnimator(START_LAT_LNG, new LatLng(37.787947, -122.407432)),
obtainExampleInterpolator(new BounceInterpolator(), 3750)
);
return animatorSet;
});

put(R.id.menu_action_anticipate_overshoot_interpolator, () ->
obtainExampleInterpolator(new AnticipateOvershootInterpolator(), 2500)
);

put(R.id.menu_action_path_interpolator, () -> obtainExampleInterpolator(
PathInterpolatorCompat.create(.22f, .68f, 0, 1.71f), 2500));
}
};
private final LongSparseArray<Animator> animators = new LongSparseArray<>();

{
AnimatorSet accelerateDecelerateAnimatorSet = new AnimatorSet();
accelerateDecelerateAnimatorSet.playTogether(
createLatLngAnimator(START_LAT_LNG, new LatLng(37.826715, -122.422795)),
obtainExampleInterpolator(new FastOutSlowInInterpolator(), 2500)
);
animators.put(R.id.menu_action_accelerate_decelerate_interpolator, accelerateDecelerateAnimatorSet);

AnimatorSet bounceAnimatorSet = new AnimatorSet();
bounceAnimatorSet.playTogether(
createLatLngAnimator(START_LAT_LNG, new LatLng(37.787947, -122.407432)),
obtainExampleInterpolator(new BounceInterpolator(), 3750)
);
animators.put(R.id.menu_action_bounce_interpolator, bounceAnimatorSet);

animators.put(R.id.menu_action_anticipate_overshoot_interpolator,
obtainExampleInterpolator(new AnticipateOvershootInterpolator(), 2500)
);

animators.put(R.id.menu_action_path_interpolator, obtainExampleInterpolator(
PathInterpolatorCompat.create(.22f, .68f, 0, 1.71f), 2500));
}

private MapView mapView;
private MapboxMap mapboxMap;
Expand Down Expand Up @@ -161,7 +156,7 @@ private Animator createTiltAnimator(double currentTilt, double targetTilt) {
//

private Animator obtainExampleInterpolator(int menuItemId) {
return animators.get(menuItemId).build();
return animators.get(menuItemId);
}

@Override
Expand Down Expand Up @@ -198,6 +193,7 @@ private void resetCameraPosition() {
private void playAnimation(int itemId) {
Animator animator = obtainExampleInterpolator(itemId);
if (animator != null) {
animator.cancel();
animator.start();
}
}
Expand Down Expand Up @@ -238,6 +234,9 @@ protected void onPause() {
protected void onStop() {
super.onStop();
mapView.onStop();
for (int i = 0; i < animators.size(); i++) {
animators.get(animators.keyAt(i)).cancel();
}
}

@Override
Expand Down Expand Up @@ -274,8 +273,4 @@ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
return latLng;
}
}

interface AnimatorBuilder {
Animator build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
Expand All @@ -18,19 +19,51 @@
*/
public class ViewPagerActivity extends AppCompatActivity {

private ViewPager viewPager;
private MapFragmentAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);

ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager = (ViewPager) findViewById(R.id.viewpager);
if (viewPager != null) {
MapFragmentAdapter adapter = new MapFragmentAdapter(getSupportFragmentManager());
adapter = new MapFragmentAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
}
}

static class MapFragmentAdapter extends FragmentPagerAdapter {
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);

int currentPosition = viewPager.getCurrentItem();
SupportMapFragment mapFragment;

if (Math.abs(0 - currentPosition) <= 1) {
mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 0);
mapFragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
});
}

if (Math.abs(1 - currentPosition) <= 1) {
mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 1);
mapFragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.DARK);
});
}

if (Math.abs(2 - currentPosition) <= 1) {
mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 2);
mapFragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.SATELLITE);
});
}
}

static class MapFragmentAdapter extends FragmentStatePagerAdapter {

private static int NUM_ITEMS = 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
*/
public class GeoJsonClusteringActivity extends AppCompatActivity {

private static final double CAMERA_ZOOM_DELTA = 0.01;
private MapView mapView;
private MapboxMap mapboxMap;

Expand Down Expand Up @@ -121,7 +122,7 @@ private void onClusterClick(Feature cluster, Point clickPoint) {
if (clickOptionCounter == 0) {
double nextZoomLevel = clusterSource.getClusterExpansionZoom(cluster);
double zoomDelta = nextZoomLevel - mapboxMap.getCameraPosition().zoom;
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomDelta, clickPoint));
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(zoomDelta + CAMERA_ZOOM_DELTA, clickPoint));
Toast.makeText(this, "Zooming to " + nextZoomLevel, Toast.LENGTH_SHORT).show();
} else if (clickOptionCounter == 1) {
FeatureCollection collection = clusterSource.getClusterChildren(cluster);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public static String convertRegionName(@NonNull byte[] metadata) {
try {
String json = new String(metadata, JSON_CHARSET);
JsonObject jsonObject = new Gson().fromJson(json, JsonObject.class);
return jsonObject.get(JSON_FIELD_REGION_NAME).getAsString();
String name = jsonObject.get(JSON_FIELD_REGION_NAME).getAsString();
return name != null ? name : "";
} catch (Exception exception) {
return null;
return "";
}
}

Expand Down