-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
The tests were failing due to the FileSource remained being active after an instrumentation test. When a map is visible to the user in a recyclerview and the activity is destroyed we need to call onPause and onStop. The issue however is that they can already have been stopped or paused by scrolling the MapView out of bounds. e50ee45 addresses this issue by maintaining state if the FileSource has been activated/deactivated. |
@@ -101,6 +101,7 @@ | |||
private MapZoomButtonController mapZoomButtonController; | |||
@Nullable | |||
private Bundle savedInstanceState; | |||
private boolean isActivated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isStarted
might be better suited here.
* </p> | ||
*/ | ||
@SuppressLint("ClickableViewAccessibility") | ||
class RecyclerViewActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This activity leaks context when rotated. Also, when map element is out of view and the activity is recreated (rotated), the map is not loading anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into this with this PR and solution for this is #13133
override fun onDestroy() { | ||
super.onDestroy() | ||
// to perform cleanup, we need to call MapView#onDestroy | ||
(recyclerView.adapter as ItemAdapter).onDestroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like some of the problems mentioned above might stem from calling MapView#onDestroy
only when activity is destroyed. We should call that whenever the MapView
holder is destroyed? Maybe #onViewRecycled
? Not sure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue above was the view measurement from #13133 . View recycling still keeps the View in memory, it's detached but keeps it alive. OnDestroy doesn't match that step at that time completely. Destroying at view recycle time would also result in recreating it completely while scrolling up and down the list. This results in hick-up during scrolling and seeing the black surface for a second. I initially went with that approach but was not satisfied with the experience.
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { | ||
return v instanceof SurfaceView || v instanceof PagerTabStrip || (super.canScroll(v, checkV, dx, x, y)); | ||
} | ||
// @Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to remove below lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, left over from testing, these lines should remain
...tApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
Show resolved
Hide resolved
80e7cf5
to
c68062d
Compare
3a72dd6
to
e2cd0da
Compare
@LukasPaczos that issue stemmed from using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for verifying!
e2cd0da
to
8986946
Compare
8986946
to
aaa574a
Compare
This PR adds an POC integration with RecyclerView.
Note that we advice against adding a MapView as part of RecyclerView. It's better for these use-cases to use a bitmap of a map instead (eg. generated with the MapSnapshotter).