@@ -1229,16 +1229,14 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
12291229 *
12301230 * @return a `LatLng` object denoting the location of the top right corner of the map.
12311231 */
1232- override fun getScreenTopRight (): LatLng ? {
1233- if (binding?.map?.projection == null || binding!! .map.width == 0 ) {
1234- Timber .e(" Map projection or dimensions are invalid. Cannot calculate screenTopRight." )
1235- return null
1236- }
1237- val screenTopRight = binding!! .map.projection
1238- .fromPixels(binding!! .map.width, 0 )
1239- return LatLng (
1240- screenTopRight.latitude, screenTopRight.longitude, 0f
1241- )
1232+ override fun getScreenTopRight (): LatLng ? {
1233+ val map = binding?.map ? : return null
1234+ val projection = map.projection ? : return null
1235+
1236+ val screenTopRight = projection.fromPixels(map.width, 0 )
1237+ return if (screenTopRight != null ) {
1238+ LatLng (screenTopRight.latitude, screenTopRight.longitude, 0f )
1239+ } else null
12421240 }
12431241
12441242 /* *
@@ -1247,15 +1245,13 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
12471245 * @return a `LatLng` object denoting the location of the bottom left corner of the map.
12481246 */
12491247 override fun getScreenBottomLeft (): LatLng ? {
1250- if (binding?.map?.projection == null || binding!! .map.height == 0 ) {
1251- Timber .e(" Map projection or dimensions are invalid. Cannot calculate screenBottomLeft." )
1252- return null
1253- }
1254- val screenBottomLeft = binding!! .map.projection
1255- .fromPixels(0 , binding!! .map.height)
1256- return LatLng (
1257- screenBottomLeft.latitude, screenBottomLeft.longitude, 0f
1258- )
1248+ val map = binding?.map ? : return null
1249+ val projection = map.projection ? : return null
1250+
1251+ val screenBottomLeft = projection.fromPixels(0 , map.height)
1252+ return if (screenBottomLeft != null ) {
1253+ LatLng (screenBottomLeft.latitude, screenBottomLeft.longitude, 0f )
1254+ } else null
12591255 }
12601256
12611257 override fun populatePlaces (currentLatLng : LatLng ) {
0 commit comments