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

Commit

Permalink
[android] - introduce MapboxMapOptins facility creation method.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jul 8, 2019
1 parent 532e9dc commit f8492dc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
@UiThread
public MapView(@NonNull Context context) {
super(context);
initialize(context, MapboxMapOptions.createFromAttributes(context, null));
initialize(context, MapboxMapOptions.createFromAttributes(context));
}

@UiThread
Expand All @@ -109,7 +109,7 @@ public MapView(@NonNull Context context, @Nullable AttributeSet attrs, int defSt
@UiThread
public MapView(@NonNull Context context, @Nullable MapboxMapOptions options) {
super(context);
initialize(context, options == null ? MapboxMapOptions.createFromAttributes(context, null) : options);
initialize(context, options == null ? MapboxMapOptions.createFromAttributes(context) : options);
}

@CallSuper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;

import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
Expand Down Expand Up @@ -136,7 +137,18 @@ private MapboxMapOptions(Parcel in) {
}

/**
* Creates a MapboxMapsOptions from the attribute set.s
* Creates a default MapboxMapsOptions from a given context.
*
* @param context Context related to a map view.
* @return the MapboxMapOptions created from attributes
*/
@NonNull
public static MapboxMapOptions createFromAttributes(@NonNull Context context) {
return createFromAttributes(context, null);
}

/**
* Creates a MapboxMapsOptions from the attribute set.
*
* @param context Context related to a map view.
* @param attrs Attributeset containing configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static MapboxMapOptions resolveArgs(@NonNull Context context, @Nullable B
options = args.getParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS);
} else {
// load default options
options = MapboxMapOptions.createFromAttributes(context, null);
options = MapboxMapOptions.createFromAttributes(context);
}
return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
class MapPagerAdapter(private val context: Context, fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {

override fun getItem(position: Int): Fragment {
val options = MapboxMapOptions.createFromAttributes(context, null)
val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.doubleTapGesturesEnabled(false)
options.rotateGesturesEnabled(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ViewPagerActivity : AppCompatActivity() {
}

override fun getItem(position: Int): Fragment? {
val options = MapboxMapOptions.createFromAttributes(context, null)
val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.camera(
CameraPosition.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static MainMapFragment newInstance(Context context, int mapCounter) {
Bundle bundle = new Bundle();
bundle.putInt("mapcounter", mapCounter);
mapFragment.setArguments(bundle);
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public static class BottomSheetFragment extends Fragment implements OnMapReadyCa

public static BottomSheetFragment newInstance(Context context) {
BottomSheetFragment mapFragment = new BottomSheetFragment();
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapboxMapOptions.renderSurfaceOnTop(true);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_symbollayer);

// Create map configuration
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this, null);
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this);
mapboxMapOptions.camera(new CameraPosition.Builder().target(
new LatLng(52.35273, 4.91638))
.zoom(13)
Expand Down

0 comments on commit f8492dc

Please sign in to comment.