Buggy code:
public class DashFavoritesFragment extends DashBaseFragment { public static final String TAG = "DASH_FAVORITES_FRAGMENT" ; private Location location = null ; private LatLon loc = null ; private Float heading = null ; private List < ImageView > arrows = new ArrayList < ImageView > ( ) ; List < FavouritePoint > points = new ArrayList < FavouritePoint > ( ) ; @ Override public View onCreateView ( LayoutInflater inflater , @ Nullable ViewGroup container , @ Nullable Bundle savedInstanceState ) { } @ Override public void onResume ( ) { } private void setupFavorites ( ) { View mainView = getView ( ) ; final FavouritesDbHelper helper = getMyApplication ( ) . getFavorites ( ) ; points = new ArrayList < FavouritePoint > ( helper . getFavouritePoints ( ) ) ; arrows . clear ( ) ; if ( ( points . size ( ) ) == 0 ) { mainView . findViewById ( main_fav ) . setVisibility ( GONE ) ; return ; } else { mainView . findViewById ( main_fav ) . setVisibility ( VISIBLE ) ; } Collections . sort ( points , new Comparator < FavouritePoint > ( ) { @ Override public int compare ( FavouritePoint point , FavouritePoint point2 ) { LatLon lastKnownMapLocation = getMyApplication ( ) . getSettings ( ) . getLastKnownMapLocation ( ) ; int dist = ( ( int ) ( MapUtils . getDistance ( point . getLatitude ( ) , point . getLongitude ( ) , lastKnownMapLocation . getLatitude ( ) , lastKnownMapLocation . getLongitude ( ) ) ) ) ; int dist2 = ( ( int ) ( MapUtils . getDistance ( point2 . getLatitude ( ) , point2 . getLongitude ( ) , lastKnownMapLocation . getLatitude ( ) , lastKnownMapLocation . getLongitude ( ) ) ) ) ; return dist - dist2 ; } } ) ; LinearLayout favorites = ( ( LinearLayout ) ( mainView . findViewById ( favorites ) ) ) ; favorites . removeAllViews ( ) ; if ( ( points . size ( ) ) > 3 ) { while ( ( points . size ( ) ) != 3 ) { points . remove ( 3 ) ; } } for ( final FavouritePoint point : points ) { LayoutInflater inflater = getActivity ( ) . getLayoutInflater ( ) ; View view = inflater . inflate ( dash_favorites_item , null , false ) ; TextView name = ( ( TextView ) ( view . findViewById ( name ) ) ) ; TextView label = ( ( TextView ) ( view . findViewById ( distance ) ) ) ; ImageView icon = ( ( ImageView ) ( view . findViewById ( icon ) ) ) ; ImageView direction = ( ( ImageView ) ( view . findViewById ( direction ) ) ) ; <START_BUG> if ( ( location ) != null ) { <END_BUG> direction . setVisibility ( VISIBLE ) ; updateArrow ( point , direction ) ; } arrows . add ( direction ) ; name . setText ( point . getName ( ) ) ; icon . setImageDrawable ( FavoriteImageDrawable . getOrCreate ( getActivity ( ) , point . getColor ( ) ) ) ; LatLon lastKnownMapLocation = getMyApplication ( ) . getSettings ( ) . getLastKnownMapLocation ( ) ; int dist = ( ( int ) ( MapUtils . getDistance ( point . getLatitude ( ) , point . getLongitude ( ) , lastKnownMapLocation . getLatitude ( ) , lastKnownMapLocation . getLongitude ( ) ) ) ) ; String distance = ( OsmAndFormatter . getFormattedDistance ( dist , getMyApplication ( ) ) ) + "<seq2seq4repair_space>" ; view . findViewById ( navigate_to ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View view ) { DirectionsDialogs . directionsToDialogAndLaunchMap ( getActivity ( ) , point . getLatitude ( ) , point . getLongitude ( ) , point . getName ( ) ) ; } } ) ; label . setText ( distance , SPANNABLE ) ; label . setTypeface ( DEFAULT , ( point . isVisible ( ) ? Typeface . NORMAL : Typeface . ITALIC ) ) ; view . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View view ) { getMyApplication ( ) . getSettings ( ) . setMapLocationToShow ( point . getLatitude ( ) , point . getLongitude ( ) , 15 , null , point . getName ( ) , point ) ; MapActivity . launchMapActivityMoveToTop ( getActivity ( ) ) ; } } ) ; favorites . addView ( view ) ; } } private void updateArrows ( ) { } private void updateArrow ( FavouritePoint point , ImageView direction ) { } public void updateCompassValue ( float value ) { } public void updateLocation ( Location location ) { } private OsmAndLocationProvider getLocationProvider ( ) { } }

Fix:
if ( ( loc ) != null ) {