Remove deprecated 'kotlin-android-extensions' Gradle plugin (#654)
This commit is contained in:
@@ -41,6 +41,11 @@ android {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
|
||||
namespace 'com.mapbox.mapboxsdk.testapp'
|
||||
testNamespace '${applicationId}'
|
||||
lint {
|
||||
@@ -90,5 +95,4 @@ apply from: "${rootDir}/gradle/gradle-lint.gradle"
|
||||
|
||||
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-android'
|
||||
@@ -17,9 +17,9 @@ import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityLatlngboundsBinding
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil.loadStringFromAssets
|
||||
import com.mapbox.mapboxsdk.utils.BitmapUtils
|
||||
import kotlinx.android.synthetic.main.activity_latlngbounds.*
|
||||
import java.net.URISyntaxException
|
||||
|
||||
/** Test activity showcasing using the LatLngBounds camera API. */
|
||||
@@ -28,6 +28,7 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var bottomSheetBehavior: BottomSheetBehavior<*>
|
||||
private lateinit var bounds: LatLngBounds
|
||||
private lateinit var binding: ActivityLatlngboundsBinding
|
||||
|
||||
private val peekHeight by lazy {
|
||||
375.toPx(this) // 375dp
|
||||
@@ -39,13 +40,15 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_latlngbounds)
|
||||
binding = ActivityLatlngboundsBinding.inflate(layoutInflater)
|
||||
val view = binding.root
|
||||
setContentView(view)
|
||||
initMapView(savedInstanceState)
|
||||
}
|
||||
|
||||
private fun initMapView(savedInstanceState: Bundle?) {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { map ->
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync { map ->
|
||||
mapboxMap = map
|
||||
|
||||
val featureCollection: FeatureCollection =
|
||||
@@ -87,14 +90,14 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
)
|
||||
) {
|
||||
initBottomSheet()
|
||||
fab.setOnClickListener {
|
||||
binding.fab.setOnClickListener {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initBottomSheet() {
|
||||
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet)
|
||||
bottomSheetBehavior = BottomSheetBehavior.from(binding.bottomSheet)
|
||||
bottomSheetBehavior.setBottomSheetCallback(
|
||||
object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
@@ -138,37 +141,37 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
binding.mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityBackstackFragmentBinding
|
||||
import com.mapbox.mapboxsdk.testapp.utils.NavUtils
|
||||
import kotlinx.android.synthetic.main.activity_backstack_fragment.*
|
||||
|
||||
/**
|
||||
* Test activity showcasing using the MapFragment API as part of a backstacked fragment.
|
||||
@@ -18,11 +18,13 @@ class FragmentBackStackActivity : AppCompatActivity() {
|
||||
private const val FRAGMENT_TAG = "map_fragment"
|
||||
}
|
||||
|
||||
private lateinit var binding: ActivityBackstackFragmentBinding
|
||||
private lateinit var mapFragment: SupportMapFragment
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_backstack_fragment)
|
||||
binding = ActivityBackstackFragmentBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mapFragment = SupportMapFragment.newInstance()
|
||||
@@ -39,7 +41,7 @@ class FragmentBackStackActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
button.setOnClickListener { handleClick() }
|
||||
binding.button.setOnClickListener { handleClick() }
|
||||
}
|
||||
|
||||
private fun initMap(mapboxMap: MapboxMap) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_recyclerview.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityRecyclerviewBinding
|
||||
|
||||
/**
|
||||
* TestActivity showcasing how to integrate a MapView in a RecyclerView.
|
||||
@@ -26,11 +26,14 @@ import kotlinx.android.synthetic.main.activity_recyclerview.*
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
class NestedViewPagerActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityRecyclerviewBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_recyclerview)
|
||||
recyclerView.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||
recyclerView.adapter = ItemAdapter(this, LayoutInflater.from(this), supportFragmentManager)
|
||||
binding = ActivityRecyclerviewBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.recyclerView.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||
binding.recyclerView.adapter = ItemAdapter(this, LayoutInflater.from(this), supportFragmentManager)
|
||||
}
|
||||
|
||||
class ItemAdapter(private val context: Context, private val inflater: LayoutInflater, private val fragmentManager: androidx.fragment.app.FragmentManager) : androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>() {
|
||||
|
||||
@@ -8,29 +8,32 @@ import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_viewpager.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityViewpagerBinding
|
||||
|
||||
/**
|
||||
* Test activity showcasing using the Android SDK ViewPager API to show MapFragments.
|
||||
*/
|
||||
class ViewPagerActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityViewpagerBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_viewpager)
|
||||
viewPager.adapter = MapFragmentAdapter(this, supportFragmentManager)
|
||||
binding = ActivityViewpagerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.viewPager.adapter = MapFragmentAdapter(this, supportFragmentManager)
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
val currentPosition = viewPager.currentItem
|
||||
val offscreenLimit = viewPager.offscreenPageLimit
|
||||
val currentPosition = binding.viewPager.currentItem
|
||||
val offscreenLimit = binding.viewPager.offscreenPageLimit
|
||||
for (i in currentPosition - offscreenLimit..currentPosition + offscreenLimit) {
|
||||
if (i < 0 || i > viewPager.adapter?.count ?: 0) {
|
||||
if (i < 0 || i > binding.viewPager.adapter?.count ?: 0) {
|
||||
continue
|
||||
}
|
||||
val mapFragment = viewPager.adapter?.instantiateItem(viewPager, i) as SupportMapFragment
|
||||
val mapFragment =
|
||||
binding.viewPager.adapter?.instantiateItem(binding.viewPager, i) as SupportMapFragment
|
||||
mapFragment.getMapAsync(i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_snapshot.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivitySnapshotBinding
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
@@ -16,16 +15,18 @@ import timber.log.Timber
|
||||
*/
|
||||
class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
private lateinit var binding: ActivitySnapshotBinding
|
||||
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
|
||||
private val idleListener = object : MapView.OnDidFinishRenderingFrameListener {
|
||||
override fun onDidFinishRenderingFrame(fully: Boolean) {
|
||||
if (fully) {
|
||||
mapView.removeOnDidFinishRenderingFrameListener(this)
|
||||
binding.mapView.removeOnDidFinishRenderingFrameListener(this)
|
||||
Logger.v(TAG, LOG_MESSAGE)
|
||||
mapboxMap.snapshot { snapshot ->
|
||||
imageView.setImageBitmap(snapshot)
|
||||
mapView.addOnDidFinishRenderingFrameListener(this)
|
||||
binding.imageView.setImageBitmap(snapshot)
|
||||
binding.mapView.addOnDidFinishRenderingFrameListener(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,24 +34,25 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_snapshot)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
binding = ActivitySnapshotBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync(this)
|
||||
}
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))) { mapView.addOnDidFinishRenderingFrameListener(idleListener) }
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))) { binding.mapView.addOnDidFinishRenderingFrameListener(idleListener) }
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -58,28 +60,28 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
mapboxMap.snapshot {
|
||||
Timber.e("Regression test for https://github.com/mapbox/mapbox-gl-native/pull/11358")
|
||||
}
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
binding.mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.removeOnDidFinishRenderingFrameListener(idleListener)
|
||||
mapView.onDestroy()
|
||||
binding.mapView.removeOnDidFinishRenderingFrameListener(idleListener)
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,16 +19,20 @@ import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_location_layer_fragment.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityLocationLayerFragmentBinding
|
||||
|
||||
class LocationFragmentActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityLocationLayerFragmentBinding
|
||||
|
||||
private lateinit var permissionsManager: PermissionsManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_location_layer_fragment)
|
||||
binding = ActivityLocationLayerFragmentBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
fab.setOnClickListener {
|
||||
binding.fab.setOnClickListener {
|
||||
val fragment = supportFragmentManager.findFragmentByTag(EmptyFragment.TAG)
|
||||
if (fragment == null) {
|
||||
supportFragmentManager
|
||||
|
||||
@@ -9,7 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_recyclerview.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityRecyclerviewBinding
|
||||
|
||||
/**
|
||||
* TestActivity showcasing how to integrate multiple GLSurfaceView MapViews in a RecyclerView.
|
||||
@@ -21,23 +21,26 @@ import kotlinx.android.synthetic.main.activity_recyclerview.*
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
|
||||
|
||||
lateinit var binding: ActivityRecyclerviewBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_recyclerview)
|
||||
recyclerView.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||
recyclerView.adapter = ItemAdapter(this, LayoutInflater.from(this))
|
||||
binding = ActivityRecyclerviewBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.recyclerView.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||
binding.recyclerView.adapter = ItemAdapter(this, LayoutInflater.from(this))
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
// to release memory, we need to call MapView#onLowMemory
|
||||
(recyclerView.adapter as ItemAdapter).onLowMemory()
|
||||
(binding.recyclerView.adapter as ItemAdapter).onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
// to perform cleanup, we need to call MapView#onDestroy
|
||||
(recyclerView.adapter as ItemAdapter).onDestroy()
|
||||
(binding.recyclerView.adapter as ItemAdapter).onDestroy()
|
||||
}
|
||||
|
||||
open fun getMapItemLayoutId(): Int {
|
||||
|
||||
@@ -8,58 +8,60 @@ import android.os.PersistableBundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_overlay.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityOverlayBinding
|
||||
|
||||
/**
|
||||
* Test overlaying a Map with a View that uses a radial gradient shader.
|
||||
*/
|
||||
class OverlayMapActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityOverlayBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_overlay)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
parentView.addView(OverlayView(this))
|
||||
mapView.getMapAsync {
|
||||
binding = ActivityOverlayBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.parentView.addView(OverlayView(this))
|
||||
binding.mapView.getMapAsync {
|
||||
it.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
|
||||
super.onSaveInstanceState(outState, outPersistentState)
|
||||
outState.let {
|
||||
mapView.onSaveInstanceState(it)
|
||||
binding.mapView.onSaveInstanceState(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.mapbox.mapboxsdk.offline.OfflineManager
|
||||
import com.mapbox.mapboxsdk.offline.OfflineRegion
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_change_resources_cache_path.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityChangeResourcesCachePathBinding
|
||||
import java.io.File
|
||||
|
||||
class ChangeResourcesCachePathActivity :
|
||||
@@ -29,6 +29,8 @@ class ChangeResourcesCachePathActivity :
|
||||
private const val TAG = "Mbgl-ChangeResourcesCachePathActivity"
|
||||
}
|
||||
|
||||
private lateinit var binding: ActivityChangeResourcesCachePathBinding
|
||||
|
||||
private lateinit var adapter: PathAdapter
|
||||
|
||||
private lateinit var offlineManager: OfflineManager
|
||||
@@ -37,12 +39,13 @@ class ChangeResourcesCachePathActivity :
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_change_resources_cache_path)
|
||||
binding = ActivityChangeResourcesCachePathBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
adapter = PathAdapter(this, obtainExternalFilesPaths())
|
||||
listView.adapter = adapter
|
||||
listView.emptyView = empty
|
||||
listView.onItemClickListener = this
|
||||
binding.listView.adapter = adapter
|
||||
binding.listView.emptyView = binding.empty
|
||||
binding.listView.onItemClickListener = this
|
||||
|
||||
offlineManager = OfflineManager.getInstance(this)
|
||||
}
|
||||
@@ -59,18 +62,18 @@ class ChangeResourcesCachePathActivity :
|
||||
}
|
||||
|
||||
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
listView.onItemClickListener = null
|
||||
binding.listView.onItemClickListener = null
|
||||
val path: String = adapter.getItem(position) as String
|
||||
FileSource.setResourcesCachePath(path, callback)
|
||||
}
|
||||
|
||||
override fun onError(message: String) {
|
||||
listView.onItemClickListener = this
|
||||
binding.listView.onItemClickListener = this
|
||||
Toast.makeText(this, "Error: $message", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun onSuccess(path: String) {
|
||||
listView.onItemClickListener = this
|
||||
binding.listView.onItemClickListener = this
|
||||
Toast.makeText(this, "New path: $path", Toast.LENGTH_LONG).show()
|
||||
|
||||
offlineManager.listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.offline
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.View
|
||||
@@ -14,7 +15,7 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.offline.*
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_region_download.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityRegionDownloadBinding
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -30,6 +31,7 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
|
||||
private val handler: Handler = Handler()
|
||||
private lateinit var offlineManager: OfflineManager
|
||||
private lateinit var binding: ActivityRegionDownloadBinding
|
||||
private var offlineRegion: OfflineRegion? = null
|
||||
private var downloading = false
|
||||
private var previousCompletedResourceCount: Long = 0
|
||||
@@ -37,15 +39,16 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_region_download)
|
||||
binding = ActivityRegionDownloadBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
offlineManager = OfflineManager.getInstance(this)
|
||||
offlineManager.setOfflineMapboxTileCountLimit(Long.MAX_VALUE)
|
||||
initUi()
|
||||
|
||||
deleteOldOfflineRegions {
|
||||
container.visibility = View.VISIBLE
|
||||
fab.visibility = View.VISIBLE
|
||||
binding.container.visibility = View.VISIBLE
|
||||
binding.fab.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +59,13 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
|
||||
private fun createOfflineRegion() {
|
||||
val latitudeNorth = editTextLatNorth.text.toString().toDouble()
|
||||
val longitudeEast = editTextLonEast.text.toString().toDouble()
|
||||
val latitudeSouth = editTextLatSouth.text.toString().toDouble()
|
||||
val longitudeWest = editTextLonWest.text.toString().toDouble()
|
||||
val styleUrl = spinnerStyleUrl.selectedItem as String
|
||||
val maxZoom = seekbarMaxZoom.progress.toFloat()
|
||||
val minZoom = seekbarMinZoom.progress.toFloat()
|
||||
val latitudeNorth = binding.editTextLatNorth.text.toString().toDouble()
|
||||
val longitudeEast = binding.editTextLonEast.text.toString().toDouble()
|
||||
val latitudeSouth = binding.editTextLatSouth.text.toString().toDouble()
|
||||
val longitudeWest = binding.editTextLonWest.text.toString().toDouble()
|
||||
val styleUrl = binding.spinnerStyleUrl.selectedItem as String
|
||||
val maxZoom = binding.seekbarMaxZoom.progress.toFloat()
|
||||
val minZoom = binding.seekbarMinZoom.progress.toFloat()
|
||||
|
||||
if (!validCoordinates(latitudeNorth, longitudeEast, latitudeSouth, longitudeWest)) {
|
||||
Toast.makeText(this, "coordinates need to be in valid range", Toast.LENGTH_LONG).show()
|
||||
@@ -90,7 +93,7 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
logMessage("Region with id ${region.id} created")
|
||||
offlineRegion = region
|
||||
startDownload(region)
|
||||
fab.visibility = View.VISIBLE
|
||||
binding.fab.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onError(error: String) {
|
||||
@@ -102,7 +105,7 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
|
||||
private fun startDownload(region: OfflineRegion) {
|
||||
downloading = true
|
||||
fab.setImageResource(R.drawable.ic_pause_black_24dp)
|
||||
binding.fab.setImageResource(R.drawable.ic_pause_black_24dp)
|
||||
logMessage("Downloading...")
|
||||
|
||||
region.setObserver(this)
|
||||
@@ -125,12 +128,12 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
|
||||
private fun pauseDownload(region: OfflineRegion) {
|
||||
downloading = false
|
||||
fab.setImageResource(R.drawable.ic_play_arrow_black_24dp)
|
||||
binding.fab.setImageResource(R.drawable.ic_play_arrow_black_24dp)
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
region.setDownloadState(OfflineRegion.STATE_INACTIVE)
|
||||
"Paused".let {
|
||||
logMessage(it)
|
||||
download_status.text = it
|
||||
binding.downloadStatus.text = it
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +141,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
if (status.isComplete) {
|
||||
"Completed".let {
|
||||
logMessage("SUCCESS! $it")
|
||||
download_status.text = it
|
||||
binding.downloadStatus.text = it
|
||||
}
|
||||
fab.setImageResource(R.drawable.ic_play_arrow_black_24dp)
|
||||
binding.fab.setImageResource(R.drawable.ic_play_arrow_black_24dp)
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
offlineRegion?.setObserver(null)
|
||||
offlineRegion?.setDownloadState(OfflineRegion.STATE_INACTIVE)
|
||||
@@ -148,7 +151,7 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
val statusText = "Downloaded ${status.completedResourceCount}/${status.requiredResourceCount}"
|
||||
statusText.let {
|
||||
logMessage(it)
|
||||
download_status.text = it
|
||||
binding.downloadStatus.text = it
|
||||
}
|
||||
|
||||
if (status.completedResourceCount > status.requiredResourceCount &&
|
||||
@@ -231,19 +234,20 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
initFab()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun initEditTexts() {
|
||||
editTextLatNorth.setText("62.0")
|
||||
editTextLonEast.setText("24.0")
|
||||
editTextLatSouth.setText("60.0")
|
||||
editTextLonWest.setText("22.5")
|
||||
binding.editTextLatNorth.setText("62.0")
|
||||
binding.editTextLonEast.setText("24.0")
|
||||
binding.editTextLatSouth.setText("60.0")
|
||||
binding.editTextLonWest.setText("22.5")
|
||||
}
|
||||
|
||||
private fun initSeekbars() {
|
||||
val maxZoom = MapboxConstants.MAXIMUM_ZOOM.toInt()
|
||||
seekbarMinZoom.max = maxZoom
|
||||
seekbarMinZoom.progress = 1
|
||||
seekbarMaxZoom.max = maxZoom
|
||||
seekbarMaxZoom.progress = 15
|
||||
binding.seekbarMinZoom.max = maxZoom
|
||||
binding.seekbarMinZoom.progress = 1
|
||||
binding.seekbarMaxZoom.max = maxZoom
|
||||
binding.seekbarMaxZoom.progress = 15
|
||||
}
|
||||
|
||||
private fun initSpinner() {
|
||||
@@ -254,19 +258,19 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
styles.add(Style.getPredefinedStyle("Outdoor"))
|
||||
val spinnerArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, styles)
|
||||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
spinnerStyleUrl.adapter = spinnerArrayAdapter
|
||||
binding.spinnerStyleUrl.adapter = spinnerArrayAdapter
|
||||
}
|
||||
|
||||
private fun initZoomLevelTextviews() {
|
||||
textViewMaxText.text = String.format("Max zoom: %s", seekbarMaxZoom.progress)
|
||||
textViewMinText.text = String.format("Min zoom: %s", seekbarMinZoom.progress)
|
||||
binding.textViewMaxText.text = String.format("Max zoom: %s", binding.seekbarMaxZoom.progress)
|
||||
binding.textViewMinText.text = String.format("Min zoom: %s", binding.seekbarMinZoom.progress)
|
||||
}
|
||||
|
||||
private fun initFab() {
|
||||
fab.setOnClickListener {
|
||||
container.visibility = View.GONE
|
||||
binding.fab.setOnClickListener {
|
||||
binding.container.visibility = View.GONE
|
||||
if (offlineRegion == null) {
|
||||
fab.visibility = View.GONE
|
||||
binding.fab.visibility = View.GONE
|
||||
createOfflineRegion()
|
||||
} else {
|
||||
offlineRegion?.let {
|
||||
@@ -281,9 +285,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
|
||||
private fun initSeekbarListeners() {
|
||||
seekbarMaxZoom.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
binding.seekbarMaxZoom.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
textViewMaxText.text = String.format("Max zoom: %s", progress)
|
||||
binding.textViewMaxText.text = String.format("Max zoom: %s", progress)
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
@@ -293,9 +297,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
})
|
||||
|
||||
seekbarMinZoom.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
binding.seekbarMinZoom.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
textViewMinText.text = String.format("Min zoom: %s", progress)
|
||||
binding.textViewMinText.text = String.format("Min zoom: %s", progress)
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
@@ -9,11 +9,13 @@ import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.offline.OfflineManager
|
||||
import com.mapbox.mapboxsdk.offline.OfflineRegion
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityMergeOfflineRegionsBinding
|
||||
import com.mapbox.mapboxsdk.testapp.utils.FileUtils
|
||||
import kotlinx.android.synthetic.main.activity_merge_offline_regions.*
|
||||
|
||||
class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMergeOfflineRegionsBinding
|
||||
|
||||
companion object {
|
||||
private const val LOG_TAG = "Mbgl-MergeOfflineRegionsActivity"
|
||||
private const val TEST_DB_FILE_NAME = "offline_test.db"
|
||||
@@ -41,7 +43,7 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
|
||||
private val onRegionMergedListener = object : OfflineManager.MergeOfflineRegionsCallback {
|
||||
override fun onMerge(offlineRegions: Array<OfflineRegion>) {
|
||||
mapView.getMapAsync {
|
||||
binding.mapView.getMapAsync {
|
||||
it.setStyle(Style.Builder().fromUri(TEST_STYLE))
|
||||
}
|
||||
Toast.makeText(
|
||||
@@ -84,16 +86,17 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_merge_offline_regions)
|
||||
binding = ActivityMergeOfflineRegionsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
// forcing offline state
|
||||
Mapbox.setConnected(false)
|
||||
|
||||
mapView.onCreate(savedInstanceState)
|
||||
load_region_btn.setOnClickListener {
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.loadRegionBtn.setOnClickListener {
|
||||
copyAsset()
|
||||
}
|
||||
mapView.getMapAsync {
|
||||
binding.mapView.getMapAsync {
|
||||
it.isDebugActive = true
|
||||
it.setStyle(Style.Builder().fromUri(TEST_STYLE))
|
||||
}
|
||||
@@ -113,33 +116,33 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mergeCallback.onActivityDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
|
||||
// restoring connectivity state
|
||||
Mapbox.setConnected(null)
|
||||
@@ -147,6 +150,6 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
binding.mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,22 @@ import android.os.Looper
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.mapbox.mapboxsdk.offline.OfflineManager
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_cache_management.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityCacheManagementBinding
|
||||
|
||||
/**
|
||||
* Test activity showcasing the cache management APIs
|
||||
*/
|
||||
class CacheManagementActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityCacheManagementBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_cache_management)
|
||||
binding = ActivityCacheManagementBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val fileSource = OfflineManager.getInstance(this)
|
||||
resetDatabaseButton.setOnClickListener {
|
||||
binding.resetDatabaseButton.setOnClickListener {
|
||||
fileSource.resetDatabase(object : OfflineManager.FileSourceCallback {
|
||||
override fun onSuccess() {
|
||||
showSnackbar("Reset database success")
|
||||
@@ -30,7 +32,7 @@ class CacheManagementActivity : AppCompatActivity() {
|
||||
})
|
||||
}
|
||||
|
||||
invalidateAmbientCacheButton.setOnClickListener {
|
||||
binding.invalidateAmbientCacheButton.setOnClickListener {
|
||||
fileSource.invalidateAmbientCache(object : OfflineManager.FileSourceCallback {
|
||||
override fun onSuccess() {
|
||||
showSnackbar("Invalidate ambient cache success")
|
||||
@@ -42,7 +44,7 @@ class CacheManagementActivity : AppCompatActivity() {
|
||||
})
|
||||
}
|
||||
|
||||
clearAmbientCacheButton.setOnClickListener {
|
||||
binding.clearAmbientCacheButton.setOnClickListener {
|
||||
fileSource.clearAmbientCache(object : OfflineManager.FileSourceCallback {
|
||||
override fun onSuccess() {
|
||||
showSnackbar("Clear ambient cache success")
|
||||
@@ -54,7 +56,7 @@ class CacheManagementActivity : AppCompatActivity() {
|
||||
})
|
||||
}
|
||||
|
||||
setMaximumAmbientCacheSizeButton.setOnClickListener {
|
||||
binding.setMaximumAmbientCacheSizeButton.setOnClickListener {
|
||||
fileSource.setMaximumAmbientCacheSize(
|
||||
5000000,
|
||||
object : OfflineManager.FileSourceCallback {
|
||||
@@ -75,6 +77,6 @@ class CacheManagementActivity : AppCompatActivity() {
|
||||
assert(Looper.myLooper() == Looper.getMainLooper())
|
||||
|
||||
// show snackbar
|
||||
Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show()
|
||||
Snackbar.make(binding.container, message, Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.mapbox.mapboxsdk.style.layers.LineLayer
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_collection_update_on_style_change.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityCollectionUpdateOnStyleChangeBinding
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -26,14 +26,16 @@ import java.util.*
|
||||
*/
|
||||
class CollectionUpdateOnStyleChange : AppCompatActivity(), OnMapReadyCallback, Style.OnStyleLoaded {
|
||||
|
||||
private lateinit var binding: ActivityCollectionUpdateOnStyleChangeBinding
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var currentStyleIndex: Int = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_collection_update_on_style_change)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
binding = ActivityCollectionUpdateOnStyleChangeBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync(this)
|
||||
setupStyleChangeView()
|
||||
Toast.makeText(
|
||||
this,
|
||||
@@ -77,37 +79,37 @@ class CollectionUpdateOnStyleChange : AppCompatActivity(), OnMapReadyCallback, S
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
binding.mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -16,16 +16,16 @@ import com.mapbox.mapboxsdk.style.layers.Property.NONE
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityWithinExpressionBinding
|
||||
import com.mapbox.turf.TurfConstants
|
||||
import com.mapbox.turf.TurfTransformation
|
||||
import kotlinx.android.synthetic.main.activity_physical_circle.*
|
||||
|
||||
/**
|
||||
* An Activity that showcases the within expression to filter features outside a geometry
|
||||
*/
|
||||
class DistanceExpressionActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityWithinExpressionBinding
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
|
||||
private val lat = 37.78794572301525
|
||||
@@ -33,10 +33,11 @@ class DistanceExpressionActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_within_expression)
|
||||
binding = ActivityWithinExpressionBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { map ->
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync { map ->
|
||||
mapboxMap = map
|
||||
|
||||
// Setup camera position above Georgetown
|
||||
@@ -84,46 +85,46 @@ class DistanceExpressionActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// Hide other types of labels to highlight POI labels
|
||||
(style.getLayer("road_label") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("airport-label-major") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("poi_transit") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("road_label") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
(style.getLayer("airport-label-major") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
(style.getLayer("poi_transit") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
|
||||
super.onSaveInstanceState(outState, outPersistentState)
|
||||
outState?.let {
|
||||
mapView.onSaveInstanceState(it)
|
||||
binding.mapView.onSaveInstanceState(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_draggable_marker.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityDraggableMarkerBinding
|
||||
|
||||
/**
|
||||
* An Activity that showcases how to make symbols draggable.
|
||||
@@ -46,8 +45,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
supportActionBar?.height ?: 0
|
||||
}
|
||||
|
||||
// View property is required for activity sanity tests
|
||||
// we perform reflection on this requires using findViewById
|
||||
private lateinit var binding: ActivityDraggableMarkerBinding
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private val featureCollection = FeatureCollection.fromFeatures(mutableListOf())
|
||||
@@ -63,9 +61,10 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_draggable_marker)
|
||||
binding = ActivityDraggableMarkerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
mapView = findViewById(R.id.mapView)
|
||||
mapView = binding.mapView
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap ->
|
||||
this.mapboxMap = mapboxMap
|
||||
@@ -122,7 +121,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
// Adding symbol drag listeners
|
||||
draggableSymbolsManager?.addOnSymbolDragListener(object : DraggableSymbolsManager.OnSymbolDragListener {
|
||||
override fun onSymbolDragStarted(id: String) {
|
||||
draggedMarkerPositionTv.visibility = View.VISIBLE
|
||||
binding.draggedMarkerPositionTv.visibility = View.VISIBLE
|
||||
Snackbar.make(
|
||||
mapView,
|
||||
"Marker drag started (%s)".format(id),
|
||||
@@ -135,11 +134,11 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
val point = featureCollection.features()?.find {
|
||||
it.id() == id
|
||||
}?.geometry() as Point
|
||||
draggedMarkerPositionTv.text = "Dragged marker's position: %.4f, %.4f".format(point.latitude(), point.longitude())
|
||||
binding.draggedMarkerPositionTv.text = "Dragged marker's position: %.4f, %.4f".format(point.latitude(), point.longitude())
|
||||
}
|
||||
|
||||
override fun onSymbolDragFinished(id: String) {
|
||||
draggedMarkerPositionTv.visibility = View.GONE
|
||||
binding.draggedMarkerPositionTv.visibility = View.GONE
|
||||
Snackbar.make(
|
||||
mapView,
|
||||
"Marker drag finished (%s)".format(id),
|
||||
|
||||
@@ -12,13 +12,14 @@ import com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_map_simple.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityMapSimpleBinding
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* Activity showcasing how to load symbols on a map without a Style URI or Style JSON.
|
||||
*/
|
||||
class NoStyleActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityMapSimpleBinding
|
||||
|
||||
private val imageIcon: Drawable by lazy {
|
||||
ResourcesCompat.getDrawable(resources, R.drawable.ic_add_white, theme)!!
|
||||
@@ -26,8 +27,10 @@ class NoStyleActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_map_simple)
|
||||
mapView.getMapAsync { map ->
|
||||
binding = ActivityMapSimpleBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.mapView.getMapAsync { map ->
|
||||
map.moveCamera(CameraUpdateFactory.newLatLngZoom(cameraTarget, cameraZoom))
|
||||
map.setStyle(
|
||||
Style.Builder()
|
||||
@@ -40,38 +43,38 @@ class NoStyleActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
|
||||
super.onSaveInstanceState(outState, outPersistentState)
|
||||
outState?.let {
|
||||
mapView.onSaveInstanceState(it)
|
||||
binding.mapView.onSaveInstanceState(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,13 @@ import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_physical_circle.mapView
|
||||
import kotlinx.android.synthetic.main.activity_snapshot.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityMapsnapshotterWithinExpressionBinding
|
||||
|
||||
/**
|
||||
* An Activity that showcases the use of MapSnapshotter with 'within' expression
|
||||
*/
|
||||
class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMapsnapshotterWithinExpressionBinding
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var snapshotter: MapSnapshotter
|
||||
private var snapshotInProgress = false
|
||||
@@ -40,7 +38,7 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
snapshotInProgress = true
|
||||
snapshotter.setCameraPosition(mapboxMap.cameraPosition)
|
||||
snapshotter.start {
|
||||
imageView.setImageBitmap(it.bitmap)
|
||||
binding.imageView.setImageBitmap(it.bitmap)
|
||||
snapshotInProgress = false
|
||||
}
|
||||
}
|
||||
@@ -67,10 +65,11 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_mapsnapshotter_within_expression)
|
||||
binding = ActivityMapsnapshotterWithinExpressionBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { map ->
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync { map ->
|
||||
mapboxMap = map
|
||||
|
||||
// Setup camera position above Georgetown
|
||||
@@ -80,7 +79,7 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
.build()
|
||||
|
||||
// Wait for the map to become idle before manipulating the style and camera of the map
|
||||
mapView.addOnDidBecomeIdleListener(object : MapView.OnDidBecomeIdleListener {
|
||||
binding.mapView.addOnDidBecomeIdleListener(object : MapView.OnDidBecomeIdleListener {
|
||||
override fun onDidBecomeIdle() {
|
||||
mapboxMap.easeCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
@@ -93,7 +92,7 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
),
|
||||
1000
|
||||
)
|
||||
mapView.removeOnDidBecomeIdleListener(this)
|
||||
binding.mapView.removeOnDidBecomeIdleListener(this)
|
||||
}
|
||||
})
|
||||
// Load mapbox streets and add lines and circles
|
||||
@@ -128,10 +127,13 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Streets"))
|
||||
) {
|
||||
mapView.addOnCameraDidChangeListener(cameraListener)
|
||||
binding.mapView.addOnCameraDidChangeListener(cameraListener)
|
||||
}
|
||||
|
||||
val options = MapSnapshotter.Options(imageView.measuredWidth / 2, imageView.measuredHeight / 2)
|
||||
val options = MapSnapshotter.Options(
|
||||
binding.imageView.measuredWidth / 2,
|
||||
binding.imageView.measuredHeight / 2
|
||||
)
|
||||
.withCameraPosition(mapboxMap.cameraPosition)
|
||||
.withPixelRatio(2.0f)
|
||||
.withStyleBuilder(
|
||||
@@ -176,37 +178,37 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
|
||||
super.onSaveInstanceState(outState, outPersistentState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
binding.mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
private fun bufferLineStringGeometry(): Polygon {
|
||||
|
||||
@@ -13,9 +13,8 @@ import com.mapbox.mapboxsdk.style.expressions.Expression.*
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityPhysicalCircleBinding
|
||||
import com.mapbox.turf.TurfTransformation
|
||||
import kotlinx.android.synthetic.main.activity_physical_circle.*
|
||||
|
||||
/**
|
||||
* An Activity that showcases how to create a Circle with radius expressed in physical units using a FillLayer.
|
||||
@@ -30,15 +29,17 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
const val ZOOM = 10.0
|
||||
}
|
||||
|
||||
private lateinit var binding: ActivityPhysicalCircleBinding
|
||||
private lateinit var source: GeoJsonSource
|
||||
private var steps: Int = 10
|
||||
private var radius: Double = 9000.0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_physical_circle)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap ->
|
||||
binding = ActivityPhysicalCircleBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync { mapboxMap ->
|
||||
|
||||
mapboxMap.cameraPosition = CameraPosition.Builder()
|
||||
.target(LatLng(LATITUDE, LONGITUDE))
|
||||
@@ -55,8 +56,8 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
)
|
||||
)
|
||||
|
||||
stepsBar.setOnSeekBarChangeListener(this)
|
||||
radiusBar.setOnSeekBarChangeListener(this)
|
||||
binding.stepsBar.setOnSeekBarChangeListener(this)
|
||||
binding.radiusBar.setOnSeekBarChangeListener(this)
|
||||
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder()
|
||||
@@ -81,7 +82,7 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
|
||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||
seekBar?.let {
|
||||
if (it.id == stepsBar.id) {
|
||||
if (it.id == binding.stepsBar.id) {
|
||||
steps = progress
|
||||
} else {
|
||||
radius = progress.toDouble()
|
||||
@@ -108,38 +109,38 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView.onStart()
|
||||
binding.mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView.onResume()
|
||||
binding.mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView.onPause()
|
||||
binding.mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView.onStop()
|
||||
binding.mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
binding.mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView.onDestroy()
|
||||
binding.mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
|
||||
super.onSaveInstanceState(outState, outPersistentState)
|
||||
outState?.let {
|
||||
mapView.onSaveInstanceState(it)
|
||||
binding.mapView.onSaveInstanceState(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_physical_circle.*
|
||||
import com.mapbox.mapboxsdk.testapp.databinding.ActivityWithinExpressionBinding
|
||||
|
||||
/**
|
||||
* An Activity that showcases the within expression to filter features outside a geometry
|
||||
@@ -30,6 +29,9 @@ import kotlinx.android.synthetic.main.activity_physical_circle.*
|
||||
class WithinExpressionActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var binding: ActivityWithinExpressionBinding
|
||||
private lateinit var mapView: MapView
|
||||
|
||||
private val handler: Handler = Handler()
|
||||
private val runnable: Runnable = Runnable {
|
||||
optimizeStyle()
|
||||
@@ -37,7 +39,9 @@ class WithinExpressionActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_within_expression)
|
||||
binding = ActivityWithinExpressionBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
mapView = binding.mapView
|
||||
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { map ->
|
||||
@@ -157,9 +161,9 @@ class WithinExpressionActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// Hide other types of labels to highlight POI labels
|
||||
(style.getLayer("road_label") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("airport-label-major") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("poi_transit") as SymbolLayer).setProperties(visibility(NONE))
|
||||
(style.getLayer("road_label") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
(style.getLayer("airport-label-major") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
(style.getLayer("poi_transit") as SymbolLayer?)?.setProperties(visibility(NONE))
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
||||
Reference in New Issue
Block a user