Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add preferredFramesPerSecond support #3627

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
private val mFeatures = mutableListOf<FeatureEntry>()
private var mQueuedFeatures: MutableList<AbstractMapFeature>? = ArrayList()
private val mCameraChangeTracker = CameraChangeTracker()
private var mPreferredFrameRate: Int? = null
private lateinit var mMap: MapboxMap

private lateinit var mMapView: MapView
Expand Down Expand Up @@ -651,6 +652,12 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
changes.add(Property.LOCALIZE_LABELS)
}

fun setReactPreferredFramesPerSecond(preferredFramesPerSecond: Int) {
if (this::mMapView.isInitialized) {
mMapView.setMaximumFps(preferredFramesPerSecond)
}
}

fun setReactStyleURL(styleURL: String) {
mStyleURL = styleURL
changes.add(Property.STYLE_URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso
mapView.setReactStyleURL(styleURL.asString())
}

@ReactProp(name = "preferredFramesPerSecond") @Suppress("UNUSED_PARAMETER")
fun setPreferredFramesPerSecond(mapView: RNMBXMapView, preferredFramesPerSecond: Int) {
//mapView.setReactPreferredFramesPerSecond(preferredFramesPerSecond);
@ReactProp(name = "preferredFramesPerSecond")
override fun setPreferredFramesPerSecond(mapView: RNMBXMapView, preferredFramesPerSecond: Dynamic) {
mapView.setReactPreferredFramesPerSecond(preferredFramesPerSecond.asInt())
}

@ReactProp(name = "zoomEnabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "mapViewImpl":
mViewManager.setMapViewImpl(view, new DynamicFromObject(value));
break;
case "preferredFramesPerSecond":
mViewManager.setPreferredFramesPerSecond(view, new DynamicFromObject(value));
break;
default:
super.setProperty(view, propName, value);
}
Expand Down
Loading
Loading