Skip to content

Commit

Permalink
Merge pull request #5 from Trendyol/AddTouchEventListener
Browse files Browse the repository at this point in the history
Add TouchEventListener
  • Loading branch information
erolaksoy authored Mar 2, 2023
2 parents c32b65b + 7d59ab0 commit 707eceb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mapskit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ afterEvaluate {
from components.release
groupId = 'com.trendyol.mapskit'
artifactId = 'mapskit'
version = '1.2'
version = '1.3'
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions mapskit/src/main/java/com/trendyol/mapskit/maplibrary/MapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.widget.FrameLayout
import com.trendyol.mapskit.maplibrary.listeners.MapsLifeCycle
import com.trendyol.mapskit.maplibrary.listeners.IOnCameraIdleListener
import com.trendyol.mapskit.maplibrary.listeners.IOnCameraMoveStartedListener
import com.trendyol.mapskit.maplibrary.listeners.IOnMapClickListener
import com.trendyol.mapskit.maplibrary.listeners.IOnMapLoadedCallback
import com.trendyol.mapskit.maplibrary.listeners.IOnMapReadyCallback
import com.trendyol.mapskit.maplibrary.listeners.IOnMarkerClickListener
import com.trendyol.mapskit.maplibrary.listeners.MapsLifeCycle
import com.trendyol.mapskit.maplibrary.model.CameraPosition
import com.trendyol.mapskit.maplibrary.model.Marker
import com.trendyol.mapskit.maplibrary.model.MarkerOptions
Expand All @@ -21,7 +21,11 @@ class MapView : FrameLayout, Map, MapsLifeCycle {

constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)

private val availableService = AvailableServiceProvider.getAvailableService(context)

Expand All @@ -31,6 +35,8 @@ class MapView : FrameLayout, Map, MapsLifeCycle {
HuaweiMapsOperations(context)
}

private var touchEventListener: ((MotionEvent?) -> Unit)? = null

init {
val view: View? = mapOperation.getMapView()
addView(view)
Expand All @@ -41,6 +47,7 @@ class MapView : FrameLayout, Map, MapsLifeCycle {
MotionEvent.ACTION_UP -> parent.requestDisallowInterceptTouchEvent(false)
MotionEvent.ACTION_DOWN -> parent.requestDisallowInterceptTouchEvent(true)
}
touchEventListener?.invoke(ev)
return super.dispatchTouchEvent(ev)
}

Expand Down Expand Up @@ -121,6 +128,14 @@ class MapView : FrameLayout, Map, MapsLifeCycle {
return mapOperation.addMarker(markerOptions, tag)
}

fun setTouchEventListener(touchEventListener: (MotionEvent?) -> Unit) {
this.touchEventListener = touchEventListener
}

fun clearTouchEventListener() {
touchEventListener = null
}

override fun clear() {
mapOperation.clear()
}
Expand Down

0 comments on commit 707eceb

Please sign in to comment.