added base-map module

This commit is contained in:
Oleg Kuznetsov 2019-08-15 18:32:42 +03:00
parent 78755f9ce7
commit ff02810e3a
4 changed files with 67 additions and 0 deletions

1
base-map/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

15
base-map/build.gradle Normal file
View File

@ -0,0 +1,15 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion versions.compileSdk
defaultConfig {
minSdkVersion 17
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

View File

@ -0,0 +1 @@
<manifest package="ru.touchin.basemap"/>

View File

@ -0,0 +1,50 @@
package ru.touchin.basemap
import android.os.Bundle
import android.view.View
abstract class AbstractMapManager<TMapView: View, TMap: Any, TLocation: Any>(protected val mapView: TMapView) {
protected lateinit var map: TMap
protected var mapListener: AbstractMapListener<TMapView, TMap, TLocation>? = null
open fun initialize(mapListener: AbstractMapListener<TMapView, TMap, TLocation>? = null) {
this.mapListener = mapListener
}
protected open fun initMap(map: TMap) {
this.map = map
this.mapListener?.onMapInitialized(map)
}
open fun onCreate(savedInstanceState: Bundle) = Unit
open fun onDestroy() = Unit
open fun onStart() = Unit
open fun onStop() = Unit
open fun onResume() = Unit
open fun onPause() = Unit
open fun onLowMemory() = Unit
open fun onSaveInstanceState (outState: Bundle) = Unit
abstract fun getCameraTarget(): TLocation
abstract fun getCameraZoom(): Float
abstract fun moveCamera(target: TLocation, zoom: Float = getCameraZoom())
abstract fun smoothMoveCamera(target: TLocation, zoom: Float = getCameraZoom())
abstract fun smoothMoveCamera(targets: List<TLocation>, padding: Int = 0)
abstract fun smoothMoveCamera(targets: List<TLocation>, width: Int, height: Int, padding: Int)
abstract fun setMapAllGesturesEnabled(enabled: Boolean)
abstract fun setMyLocationEnabled(enabled: Boolean)
abstract fun isLocationInVisibleRegion(location: TLocation): Boolean
interface AbstractMapListener<TMapView, TMap, TLocation> {
fun onMapInitialized(map: TMap)
fun onMapLoaded() = Unit
fun onMapTap(location: TLocation) = Unit
fun onMapLongTap(location: TLocation) = Unit
fun onCameraMoved(finished: Boolean) = Unit
}
}