[android] deprecate MapboxMapOptions empty constructor

This commit is contained in:
Łukasz Paczos
2019-05-23 15:48:04 +02:00
committed by Łukasz Paczos
parent d60df973a6
commit d8e9acd0f5
11 changed files with 27 additions and 23 deletions

View File

@@ -84,7 +84,9 @@ public class MapboxMapOptions implements Parcelable {
/**
* Creates a new MapboxMapOptions object.
* @deprecated Use {@link #createFromAttributes(Context, AttributeSet)} instead.
*/
@Deprecated
public MapboxMapOptions() {
}

View File

@@ -55,7 +55,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
super.onCreate(savedInstanceState);
// configure inital map state
MapboxMapOptions options = new MapboxMapOptions()
MapboxMapOptions options = MapboxMapOptions.createFromAttributes(this, null)
.attributionTintColor(RED_COLOR)
.compassFadesWhenFacingNorth(false)
.camera(new CameraPosition.Builder()

View File

@@ -47,7 +47,7 @@ public class MapFragmentActivity extends AppCompatActivity implements MapFragmen
}
private MapboxMapOptions createFragmentOptions() {
MapboxMapOptions options = new MapboxMapOptions();
MapboxMapOptions options = MapboxMapOptions.createFromAttributes(this, null);
options.scrollGesturesEnabled(false);
options.zoomGesturesEnabled(false);

View File

@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.testapp.activity.fragment
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
@@ -36,10 +37,10 @@ class NestedViewPagerActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_recyclerview)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = ItemAdapter(LayoutInflater.from(this), supportFragmentManager)
recyclerView.adapter = ItemAdapter(this, LayoutInflater.from(this), supportFragmentManager)
}
class ItemAdapter(private val inflater: LayoutInflater, private val fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class ItemAdapter(private val context: Context, private val inflater: LayoutInflater, private val fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val items = listOf(
"one", "two", "three", ViewPagerItem(), "four", "five", "six", "seven", "eight", "nine", "ten",
@@ -57,7 +58,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return if (viewType == TYPE_VIEWPAGER) {
val viewPager = inflater.inflate(R.layout.item_viewpager, parent, false) as ViewPager
mapHolder = ViewPagerHolder(viewPager, fragmentManager)
mapHolder = ViewPagerHolder(context, viewPager, fragmentManager)
return mapHolder as ViewPagerHolder
} else {
TextHolder(inflater.inflate(android.R.layout.simple_list_item_1, parent, false) as TextView)
@@ -90,9 +91,9 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
class ViewPagerItem
class ViewPagerHolder(private val viewPager: ViewPager, fragmentManager: FragmentManager) : RecyclerView.ViewHolder(viewPager) {
class ViewPagerHolder(context: Context, private val viewPager: ViewPager, fragmentManager: FragmentManager) : RecyclerView.ViewHolder(viewPager) {
init {
viewPager.adapter = MapPagerAdapter(fragmentManager)
viewPager.adapter = MapPagerAdapter(context, fragmentManager)
viewPager.setOnTouchListener { view, motionEvent ->
// Disallow the touch request for recyclerView scroll
view.parent.requestDisallowInterceptTouchEvent(true)
@@ -102,10 +103,10 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
}
class MapPagerAdapter(fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {
class MapPagerAdapter(private val context: Context, fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {
override fun getItem(position: Int): Fragment {
val options = MapboxMapOptions()
val options = MapboxMapOptions.createFromAttributes(context, null)
options.textureMode(true)
options.doubleTapGesturesEnabled(false)
options.rotateGesturesEnabled(false)

View File

@@ -48,7 +48,7 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements Map
}
private MapboxMapOptions createFragmentOptions() {
MapboxMapOptions options = new MapboxMapOptions();
MapboxMapOptions options = MapboxMapOptions.createFromAttributes(this, null);
options.scrollGesturesEnabled(false);
options.zoomGesturesEnabled(false);

View File

@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.fragment
import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
@@ -21,7 +22,7 @@ class ViewPagerActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_viewpager)
viewPager.adapter = MapFragmentAdapter(supportFragmentManager)
viewPager.adapter = MapFragmentAdapter(this, supportFragmentManager)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
@@ -37,14 +38,14 @@ class ViewPagerActivity : AppCompatActivity() {
}
}
internal class MapFragmentAdapter(fragmentManager: FragmentManager) : FragmentStatePagerAdapter(fragmentManager) {
internal class MapFragmentAdapter(private val context: Context, fragmentManager: FragmentManager) : FragmentStatePagerAdapter(fragmentManager) {
override fun getCount(): Int {
return NUM_ITEMS
}
override fun getItem(position: Int): Fragment? {
val options = MapboxMapOptions()
val options = MapboxMapOptions.createFromAttributes(context, null)
options.textureMode(true)
options.camera(
CameraPosition.Builder()

View File

@@ -79,7 +79,7 @@ public class BottomSheetActivity extends AppCompatActivity {
int fragmentCount = fragmentManager.getBackStackEntryCount();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
MainMapFragment mainMapFragment = MainMapFragment.newInstance(fragmentCount);
MainMapFragment mainMapFragment = MainMapFragment.newInstance(this, fragmentCount);
if (fragmentCount == 0) {
fragmentTransaction.add(R.id.fragment_container, mainMapFragment, TAG_MAIN_FRAGMENT);
} else {
@@ -104,7 +104,7 @@ public class BottomSheetActivity extends AppCompatActivity {
private void addBottomSheetMapFragment() {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.fragment_container_bottom, BottomSheetFragment.newInstance(), TAG_BOTTOM_FRAGMENT);
fragmentTransaction.add(R.id.fragment_container_bottom, BottomSheetFragment.newInstance(this), TAG_BOTTOM_FRAGMENT);
fragmentTransaction.commit();
}
@@ -128,12 +128,12 @@ public class BottomSheetActivity extends AppCompatActivity {
private MapView map;
public static MainMapFragment newInstance(int mapCounter) {
public static MainMapFragment newInstance(Context context, int mapCounter) {
MainMapFragment mapFragment = new MainMapFragment();
Bundle bundle = new Bundle();
bundle.putInt("mapcounter", mapCounter);
mapFragment.setArguments(bundle);
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
@@ -209,9 +209,9 @@ public class BottomSheetActivity extends AppCompatActivity {
private MapView map;
public static BottomSheetFragment newInstance() {
public static BottomSheetFragment newInstance(Context context) {
BottomSheetFragment mapFragment = new BottomSheetFragment();
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
mapboxMapOptions.renderSurfaceOnTop(true);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;

View File

@@ -101,7 +101,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
protected MapboxMapOptions setupMapboxMapOptions() {
return new MapboxMapOptions();
return MapboxMapOptions.createFromAttributes(this, null);
}
@Override

View File

@@ -39,7 +39,7 @@ public class DoubleMapActivity extends AppCompatActivity {
setContentView(R.layout.activity_map_fragment);
if (savedInstanceState == null) {
MapboxMapOptions options = new MapboxMapOptions();
MapboxMapOptions options = MapboxMapOptions.createFromAttributes(this, null);
options.camera(new CameraPosition.Builder()
.target(MACHU_PICCHU)
.zoom(ZOOM_IN)

View File

@@ -114,7 +114,7 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
setContentView(R.layout.activity_symbollayer);
// Create map configuration
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this, null);
mapboxMapOptions.camera(new CameraPosition.Builder().target(
new LatLng(52.35273, 4.91638))
.zoom(13)

View File

@@ -39,7 +39,7 @@ public class TextureViewTransparentBackgroundActivity extends AppCompatActivity
}
private void setupMapView(Bundle savedInstanceState) {
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this, null);
mapboxMapOptions.translucentTextureSurface(true);
mapboxMapOptions.textureMode(true);
mapboxMapOptions.camera(new CameraPosition.Builder()