com.here.android.restricted.streetlevel
Class StreetLevelFragment

java.lang.Object
  extended by android.app.Fragment
      extended by com.here.android.restricted.streetlevel.StreetLevelFragment
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, View.OnCreateContextMenuListener

public class StreetLevelFragment
extends Fragment

Represents a street level fragment. This is the fragment class designed to handle all UI-related use cases, including rendering and screen touch events.

Note: each StreetLevelFragment must be bound to a StreetLevelModel instance, and StreetLevel objects should be persisted during application runtime. StreetLevel objects live and expire according to the associated activity's lifecycle. This fragment has Fragment.setRetainInstance(true) set. Therefore the StreetLevelModel will retain any properties applied to it during an application's lifetime.

A StreetLevelFragment is defined in an Android layout XML file. For example:

 <fragment
     class="com.here.android.restricted.streetlevel.StreetLevelFragment"
     android:id="@+id/streetlevelfragment"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:layout_weight="1" />
 
 

Note: StreetLevelFragment automatically handles pause and resume of MapEngine during activity state changes, thus it is not necessary for the activity that owns StreetLevelFragment(s) to manually call MapEngine.onPause() / com.here.android.mapping.MapEngine.onResume() during the activity's onPause() and onResume(). However, considerations should be made regarding how much processing should be done in the onResume() method. Performing significant amounts of processing may delay the view rendering in cases such as device orientation change. It is recommended to use a specifically designated handler for organizing the amount of processing to be done in such cases.

Note: For map fragment support on API level 10, please use StreetLevelCompatibilityFragment.

See Also:
StreetLevelCompatibilityFragment, android.app.Fragment

Nested Class Summary
 
Nested classes/interfaces inherited from class android.app.Fragment
Fragment.InstantiationException, Fragment.SavedState
 
Field Summary
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
StreetLevelFragment()
          Constructor
 
Method Summary
 void addStreetLevelEventListener(StreetLevelEventListener listener)
          Adds a StreetLevelEventListener to listen for StreetLevelFragment events.
 StreetLevelGesture getStreetLevelGesture()
          Gets the StreetLevelGesture interface for the StreetLevelModel, used to enable or disable gestures.
 StreetLevelModel getStreetLevelModel()
          Retrieve the StreetLevelModel.
 void init(Context context, FragmentInitListener listener)
          User of StreetLevelFragment must call this function after the fragment is created.
 void init(FragmentInitListener listener)
          User of StreetLevelFragment must call this function after the fragment is first attached to its activity.
 View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
          Called when a fragment is first attached to its activity.
 void onDestroy()
          Called when the fragment is destroyed.
 void onDestroyView()
          Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment.
 void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
          Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.
 void onInflate(AttributeSet attrs, Bundle savedInstanceState)
           
 void onPause()
          Called when the Fragment is no longer resumed.
 void onResume()
          Called when the fragment is visible to the user and actively running.
 void removeStreetLevelEventListener(StreetLevelEventListener listener)
          Removes an existing StreetLevelEventListener.
 void setBlankStreetLevelImageVisible(boolean visible)
          Request the view to draw "black" so a model can be reused without showing the previous street level image.This is useful in case an application tries to display the street level image for a location where street level coverage is not available.This API ensures that a "black" image is displayed if there is no street level coverage for the new location.
 void setOnTouchListener(View.OnTouchListener listener)
          Sets an View.OnTouchListener to be invoked whenever a touch event is sent to the StreetLevelFragment.
 
Methods inherited from class android.app.Fragment
dump, equals, getActivity, getArguments, getFragmentManager, getId, getLoaderManager, getResources, getRetainInstance, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityCreated, onActivityResult, onAttach, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDetach, onHiddenChanged, onLowMemory, onOptionsItemSelected, onOptionsMenuClosed, onPrepareOptionsMenu, onSaveInstanceState, onStart, onStop, onTrimMemory, onViewCreated, registerForContextMenu, setArguments, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setRetainInstance, setTargetFragment, startActivity, startActivityForResult, toString, unregisterForContextMenu
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreetLevelFragment

public StreetLevelFragment()
Constructor

Method Detail

init

public void init(FragmentInitListener listener)
User of StreetLevelFragment must call this function after the fragment is first attached to its activity. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. This method is a method that should be used for fragments embedded in a layout XML. Do not use this method when StreetLevelFragment is created programatically.

Parameters:
listener - A FragmentInitListener object that will be called when StreetLevelFragment and RestrictedMapFactory initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.
See Also:
FragmentInitListener, init(android.content.Context, FragmentInitListener)

init

public void init(Context context,
                 FragmentInitListener listener)
User of StreetLevelFragment must call this function after the fragment is created. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. Do not use this method when StreetLevelFragment is created programatically.

Parameters:
context - Context of the application.
listener - A FragmentInitListener object that will be called when StreetLevelFragment and RestrictedMapFactory initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.
See Also:
FragmentInitListener, init(FragmentInitListener)

onInflate

public void onInflate(Activity activity,
                      AttributeSet attrs,
                      Bundle savedInstanceState)
Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity. This may be called immediately after the fragment is created from a tag in a layout file.

Overrides:
onInflate in class Fragment
See Also:
Fragment.onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle)

onInflate

public void onInflate(AttributeSet attrs,
                      Bundle savedInstanceState)
Overrides:
onInflate in class Fragment

onCreateView

public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState)
Called when a fragment is first attached to its activity. A Street Level View is automatically setup to cover the full size of the StreetLevelFragment dimension.

Overrides:
onCreateView in class Fragment
See Also:
Fragment.onAttach(android.app.Activity)

onPause

public void onPause()
Called when the Fragment is no longer resumed. All Map Engine activities will be paused automatically.

Overrides:
onPause in class Fragment
See Also:
Fragment.onPause()

onResume

public void onResume()
Called when the fragment is visible to the user and actively running. All Map Engine activities will be resumed automatically.

Overrides:
onResume in class Fragment
See Also:
Fragment.onResume()

onDestroyView

public void onDestroyView()
Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment. The StreetLevelModel created by the fragment will be detached from the fragment and destroyed automatically as part of the cleanup process. The View.OnTouchListener will also be disconnected from the fragment.

Overrides:
onDestroyView in class Fragment

onDestroy

public void onDestroy()
Called when the fragment is destroyed.

Overrides:
onDestroy in class Fragment

getStreetLevelModel

public StreetLevelModel getStreetLevelModel()
Retrieve the StreetLevelModel.


setOnTouchListener

public void setOnTouchListener(View.OnTouchListener listener)
Sets an View.OnTouchListener to be invoked whenever a touch event is sent to the StreetLevelFragment.

Parameters:
listener - An View.OnTouchListener to set for the StreetLevelFragment
See Also:
android.view.View.OnTouchListener

addStreetLevelEventListener

public void addStreetLevelEventListener(StreetLevelEventListener listener)
Adds a StreetLevelEventListener to listen for StreetLevelFragment events.

Note: it is recommended to remove street level event listeners when no longer used.

Parameters:
listener - A StreetLevelEventListener to add to the StreetLevelFragment
See Also:
removeStreetLevelEventListener(StreetLevelEventListener)

removeStreetLevelEventListener

public void removeStreetLevelEventListener(StreetLevelEventListener listener)
Removes an existing StreetLevelEventListener.

Note: It is recommended to remove street level event listeners when no longer used.

Parameters:
listener - A StreetLevelEventListener to remove from the StreetLevelFragment

getStreetLevelGesture

public StreetLevelGesture getStreetLevelGesture()
Gets the StreetLevelGesture interface for the StreetLevelModel, used to enable or disable gestures.

Returns:
The StreetLevelGesture

setBlankStreetLevelImageVisible

public void setBlankStreetLevelImageVisible(boolean visible)
Request the view to draw "black" so a model can be reused without showing the previous street level image.This is useful in case an application tries to display the street level image for a location where street level coverage is not available.This API ensures that a "black" image is displayed if there is no street level coverage for the new location.

Parameters:
visible - Boolean value to indicate if the blank image represented by the "black" model is visible.

Copyright (C) 2011-2013 HERE Global B.V. All rights reserved.