yayaa / LocationManager

Simplify getting user's location for Android
806 stars 187 forks source link

bugfix: add a NPE protection. #69

Closed fightyz closed 6 years ago

fightyz commented 6 years ago

The onLocationChanged(Location location) callback is actually called in a thread's looper, which created the LocationManager. So, event if the DefaultLocationProvider.onDestroy() is done, the message which has the callback, may not be destroyed (because the removeUpdates(LocationListener listener) method will call a system service, which is another process), and still in the looper's message queue. At this moment, executing onLocationChanged(Location location) will cause a Null Point Exception, as getSourceProvider() returns null.

codecov-io commented 6 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@062034b). Click here to learn what that means. The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #69   +/-   ##
=========================================
  Coverage          ?   66.88%           
=========================================
  Files             ?       31           
  Lines             ?     1075           
  Branches          ?       92           
=========================================
  Hits              ?      719           
  Misses            ?      297           
  Partials          ?       59
Impacted Files Coverage Δ
...viders/locationprovider/DefaultLocationSource.java 0% <0%> (ø)
...ders/locationprovider/DefaultLocationProvider.java 87.76% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 062034b...6231f44. Read the comment docs.