Represents a Android.Support.V4.App.Fragment class that supports ViewModel navigation.
Definition
public abstract class Fragment<TViewModel> : Fragment,
IServiceAccessor, ILocationListener, ISupportLocationResult, ISupportMasterDetail
where TViewModel : IViewModel, class
Type Parameters
TViewModel | Instance of IViewModel |
Summary
The following table summarizes the members exposed in this class.
Protected Constructors
Fragment<TViewModel> Constructor() | Initializes the Fragment<TViewModel> class. |
Fragment<TViewModel> Constructor(int) | Initializes the Fragment<TViewModel> class. |
Fragment<TViewModel> Constructor(TViewModel) | Initializes the Fragment<TViewModel> class. |
Fragment<TViewModel> Constructor(IntPtr, JniHandleOwnership) | Initializes a new instance of the Fragment<TViewModel> class. |
Public Properties
LocationManager | Gets the location manager. |
NavigationInitiator | Gets or sets the navigation initiator. |
ShouldNotDispose | Gets or sets a value indicating whether the fragment should not be disposed OnDestroy. |
ViewModel | Gets the related view model. |
Protected Properties
ContentLayoutId | Gets the value of the ID of the content layout to be inflated. |
IconId | Gets the value that determines the icon that will be displayed on the action bar when this fragment is displayed. |
IsDisposed | Gets the value indicating whether the current fragment has been disposed. |
IsRotated | Gets the value indicating whether the current fragment has been rotated. |
IsRotating | Gets the value indicating whether the current fragment is being rotated. |
LayoutInflater | Gets the layout inflater. |
MenuLayoutId | Gets the menu layout ID to be inflated to the action bar. |
NestedFragments | Gets the nested fragments dictionary to be inflated dynamically inside this fragment. Supply the container ID and the Type of the Fragment that you wish to inflated to that particular layout container ID. |
ShouldHandleNavigation | Gets the value indicating whether the current activity should handle the navigation. This mechanism is used when dealing with child fragments where the child fragment and it's owner hold the same view model. In this case, the navigation should only be handled by the child fragment. |
ShowActionBarUpButton | Gets or sets that determines whether action bar is clickable as back navigation. |
Title | Gets the value that determines the label that will be displayed on the action bar when this fragment is displayed. |
ViewModel | Gets the related view model. |
Public Methods
AddBinding(View, BindableProperty, BindingDescription) | Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
AddBinding(View, BindableProperty, string) | Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
AddBinding(View, BindableProperty, string, BindingMode) | Add a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
AddBinding(string, BindableProperty, BindingDescription) | Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
AddBinding(string, BindableProperty, string) | Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
AddBinding(string, BindableProperty, string, BindingMode) | Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>. |
DisposeFragment() | Dispose fragment. |
FindName(string) | Finds the view with the specified string name. |
FindName<T>(string) | Finds the view with the specified string name. |
ForceNavigation() | Force navigation. |
GetService<TService>() | Gets the registered service based on the specified type parameter. |
GetService<TService>(bool) | Gets the service and optionally return a new instance of the service. |
OnAttach(Activity) | Called when a fragment is first attached to its activity. |
OnAttached(INavigable) | Called when the IFragment is attached. |
OnCreate(Bundle) | Called when the activity is starting. |
OnCreateOptionsMenu(IMenu, MenuInflater) | Initialize the contents of the Activity's standard options menu. |
OnCreateView(LayoutInflater, ViewGroup, Bundle) | Called to have the fragment instantiate its user interface view. |
OnDestroy() | Perform any final cleanup before an activity is destroyed. |
OnDestroyView() | Called when the view has been detached from the fragment. |
OnLocationChanged(Location) | Called when the location has changed. |
OnOptionsItemSelected(IMenuItem) | Called whenever an item in the options menu is selected. |
OnPause() | Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed. |
OnProviderDisabled(string) | Called when the provider is disabled by the user. |
OnProviderEnabled(string) | Called when the provider is enabled by the user. |
OnResume() | Called when activity start interacting with the user. |
OnStart() | Called when the activity had been stopped, but is now again being displayed to the user. |
OnStatusChanged(string, Availability, Bundle) | Called when the provider status changes. |
OnStop() | Called when you are no longer visible to the user. |
OnViewCreated(View, Bundle) | Called immediately after Fragment<TViewModel> has returned, but before any saved state has been restored in to the view. |
RegisterViewIdentifier(string, object) | Registers view identifier at runtime. |
ReinitializeBinding(string, BindableProperty) | Reinitializes the binding after orientation changes. |
RequestLocationUpdates(string, long, float, Action<LocationRequest, List<object>>) | Monitors device location. Triggers on location change. |
SetViewModel(IViewModel) | Sets the view model for the IFragment. |
Protected Methods
CreateViewModel() | Creates a view model based on the given IViewModel. |
CreateViewState() | Create the view state to store non-configuration instance which should be retained before the view is being destroyed. |
Dispose(bool) | Performs tasks associated with freeing, releasing, or resetting unmanaged resources. |
InitializeBindings() | Initializes the bindings after it has been registered. |
InitializeNestedFragments() | Initializes the nested fragments. |
InitializeView() | Initializes the view-related logic before it is rendered. |
InitializeViewModel() | Initializes the view model instance. |
OnRestoreNonConfigurationInstance(ViewState) | Restore non configuration instance that was previously returned by Fragment<TViewModel>. |
OnRetainNonConfigurationInstance() | Retain non configuration instance to be used when the instance is re-created after being destroyed. |
OnRotate() | Called when the activity had been rotated and is now being displayed to the user. |
OnViewCreated() | Called when the view is created. |
OnViewDisposed() | Called when the view is disposed. |
OnViewInitialized() | Called when view is initialized. |
OnViewModelDisposed() | Dispose the view model. |
OnViewModelPropertyChanged(PropertyChangedEventArgs) | Called when the properties of the associated view model has changed. |
OnViewModelResourcesChanged() | Called when the resources in view model has changed. |
OnViewNavigated() | Called when the view is navigated. |
Protected Constructors
protected Fragment()
Initializes the Fragment<TViewModel> class.
protected Fragment(int contentLayoutId)
Initializes the Fragment<TViewModel> class.
Parameters
contentLayoutId | ID of the content layout to be inflated |
protected Fragment(TViewModel viewModel)
Initializes the Fragment<TViewModel> class.
Parameters
viewModel | Instance of IViewModel |
protected Fragment(IntPtr intPtr, JniHandleOwnership handleOwnership)
Initializes a new instance of the Fragment<TViewModel> class.
Parameters
intPtr | The int PTR. |
handleOwnership | The handle ownership. |
Public Properties
public LocationManager LocationManager { get; }
Gets the location manager.
public INavigable NavigationInitiator { get; set; }
Gets or sets the navigation initiator.
public bool ShouldNotDispose { get; set; }
Gets or sets a value indicating whether the fragment should not be disposed OnDestroy.
public TViewModel ViewModel { get; }
Gets the related view model.
Protected Properties
protected int ContentLayoutId { get; }
Gets the value of the ID of the content layout to be inflated.
protected int IconId { get; }
Gets the value that determines the icon that will be displayed on the action bar when this fragment is displayed.
protected bool IsDisposed { get; }
Gets the value indicating whether the current fragment has been disposed.
protected bool IsRotated { get; }
Gets the value indicating whether the current fragment has been rotated.
protected bool IsRotating { get; }
Gets the value indicating whether the current fragment is being rotated.
protected LayoutInflater LayoutInflater { get; }
Gets the layout inflater.
protected int MenuLayoutId { get; }
Gets the menu layout ID to be inflated to the action bar.
protected Dictionary<Type, int> NestedFragments { get; }
Gets the nested fragments dictionary to be inflated dynamically inside this fragment. Supply the container ID and the Type of the Fragment that you wish to inflated to that particular layout container ID.
protected bool ShouldHandleNavigation { get; }
Gets the value indicating whether the current activity should handle the navigation. This mechanism is used when dealing with child fragments where the child fragment and it's owner hold the same view model. In this case, the navigation should only be handled by the child fragment.
protected bool ShowActionBarUpButton { get; }
Gets or sets that determines whether action bar is clickable as back navigation.
protected string Title { get; }
Gets the value that determines the label that will be displayed on the action bar when this fragment is displayed.
protected TViewModel ViewModel { set; }
Gets the related view model.
Public Methods
public void AddBinding(View targetView, BindableProperty property, BindingDescription binding)
Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetView | The target Android.Views.View |
property | The BindableProperty |
binding | The BindingDescription |
public void AddBinding(View targetView, BindableProperty property, string path)
Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetView | The target Android.Views.View |
property | The BindableProperty |
path | The property name path |
public void AddBinding(View targetView, BindableProperty property, string path, BindingMode mode)
Add a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetView | The target Android.Views.View |
property | The BindableProperty |
path | The property name path |
mode | The BindingMode to be used |
public void AddBinding(string targetViewName, BindableProperty property, BindingDescription binding)
Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetViewName | The target Android.Views.View |
property | The BindableProperty |
binding | The BindingDescription to be used |
public void AddBinding(string targetViewName, BindableProperty property, string path)
Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetViewName | The string name of the target Android.Views.View |
property | The BindableProperty |
path | The property name path |
public void AddBinding(string targetViewName, BindableProperty property, string path, BindingMode mode)
Adds a new BindingContext to a list of BindingContext used by Activity<TViewModel>.
Parameters
targetViewName | The string name of the target Android.Views.View |
property | The BindableProperty |
path | The property name path |
mode | The BindingMode to be used |
public void DisposeFragment()
Dispose fragment.
public object FindName(string name)
Finds the view with the specified string name.
Parameters
name | The name. |
Return Types
object associated with the identifier. |
public T FindName<T>(string name)
Finds the view with the specified string name.
Type Parameters
T | System.Type of the view |
Parameters
name | The name. |
public void ForceNavigation()
Force navigation.
public TService GetService<TService>()
Gets the registered service based on the specified type parameter.
Type Parameters
TService | The service type to retrieve. |
Return Types
The service. |
public TService GetService<TService>(bool newInstance)
Gets the service and optionally return a new instance of the service.
Type Parameters
TService | The service type to retrieve. |
Parameters
newInstance | If set to true new instance. |
Return Types
The service. |
public void OnAttach(Activity activity)
Called when a fragment is first attached to its activity.
Parameters
activity | The activity. |
public void OnAttached(INavigable sender)
Called when the IFragment is attached.
Parameters
sender | The sender. |
public void OnCreate(Bundle savedInstanceState)
Called when the activity is starting.
Parameters
savedInstanceState | The bundle contains instance state |
public void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
Initialize the contents of the Activity's standard options menu.
Parameters
menu | The options menu in which you place your items. |
inflater | The menu inflater. |
public View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view.
Parameters
inflater | The LayoutInflater object that can be used to inflate any views in the fragment. |
container | If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view. |
savedInstanceState | If non-null, this fragment is being re-constructed from a previous saved state as given here. |
public void OnDestroy()
Perform any final cleanup before an activity is destroyed.
public void OnDestroyView()
Called when the view has been detached from the fragment.
public void OnLocationChanged(Location location)
Called when the location has changed.
Remarks
Called when the location has changed. There are no restrictions on the use of the supplied Location object. <format type="text/html"> <a href="http://developer.android.com/reference/android/location/LocationListener.html#onLocationChanged(android.location.Location)" target="_blank"> [Android Documentation] </a> </format> |
Parameters
location | The new location, as a Location object. |
public bool OnOptionsItemSelected(IMenuItem item)
Called whenever an item in the options menu is selected.
Parameters
item | The menu item that is selected. |
public void OnPause()
Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed.
public void OnProviderDisabled(string provider)
Called when the provider is disabled by the user.
Remarks
Called when the provider is disabled by the user. If requestLocationUpdates is called on an already disabled provider, this method is called immediately. <format type="text/html"> <a href="http://developer.android.com/reference/android/location/LocationListener.html#onProviderDisabled(java.lang.String)" target="_blank"> [Android Documentation] </a> </format> |
Parameters
provider | the name of the location provider associated with this update. |
public void OnProviderEnabled(string provider)
Called when the provider is enabled by the user.
Remarks
Called when the provider is enabled by the user. <format type="text/html"> <a href="http://developer.android.com/reference/android/location/LocationListener.html#onProviderEnabled(java.lang.String)" target="_blank"> [Android Documentation] </a> </format> |
Parameters
provider | the name of the location provider associated with this update. |
public void OnResume()
Called when activity start interacting with the user.
public void OnStart()
Called when the activity had been stopped, but is now again being displayed to the user.
public void OnStatusChanged(string provider, Availability status, Bundle extras)
Called when the provider status changes.
Remarks
Called when the provider status changes. This method is called when a provider is unable to fetch a location or if the provider has recently become available after a period of unavailability. <format type="text/html"> <a href="http://developer.android.com/reference/android/location/LocationListener.html#onStatusChanged(java.lang.String, int, android.os.Bundle)" target="_blank"> [Android Documentation] </a> </format> |
Parameters
provider | the name of the location provider associated with this update. |
status | if the provider is out of service, and this is not expected to change in the near future; if the provider is temporarily unavailable but is expected to be available shortly; and if the provider is currently available. |
extras | an optional Bundle which will contain provider specific status variables. A number of common key/value pairs for the extras Bundle are listed below. Providers that use any of the keys on this list must provide the corresponding value as described below. satellites - the number of satellites used to derive the fix |
public void OnStop()
Called when you are no longer visible to the user.
public void OnViewCreated(View view, Bundle savedInstanceState)
Called immediately after Fragment<TViewModel> has returned, but before any saved state has been restored in to the view.
Parameters
view | The View returned by Fragment<TViewModel>. |
savedInstanceState | If non-null, this fragment is being re-constructed from a previous saved state as given here. |
public void RegisterViewIdentifier(string id, object view)
Registers view identifier at runtime.
Parameters
id | The string ID to be registered |
view | The Android.Views.View object to be registered |
public void ReinitializeBinding(string targetViewName, BindableProperty property)
Reinitializes the binding after orientation changes.
Parameters
targetViewName | The target Android.Views.View name |
property | The BindableProperty |
public void RequestLocationUpdates(string provider, long minTime, float minDistance, Action<LocationRequest, List<object>> locationCallback)
Monitors device location. Triggers on location change.
Parameters
provider | The Android.Locations.LocationProvider |
minTime | Minimum time in milliseconds before Android.Locations.ILocationListener.OnLocationChanged(Android.Locations.Location) is triggered |
minDistance | Minimum distance in meters before Android.Locations.ILocationListener.OnLocationChanged(Android.Locations.Location) is triggered |
locationCallback | The System.Action callback |
public void SetViewModel(IViewModel viewModel)
Sets the view model for the IFragment.
Parameters
viewModel | The view model. |
Protected Methods
protected TViewModel CreateViewModel()
Creates a view model based on the given IViewModel.
Return Types
Instance of IViewModel |
protected ViewState CreateViewState()
Create the view state to store non-configuration instance which should be retained before the view is being destroyed.
Return Types
The view state which contains non-configuration instance. |
protected void Dispose(bool disposing)
Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
Parameters
disposing | If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed. |
protected void InitializeBindings()
Initializes the bindings after it has been registered.
protected void InitializeNestedFragments()
Initializes the nested fragments.
protected void InitializeView()
Initializes the view-related logic before it is rendered.
protected void InitializeViewModel()
Initializes the view model instance.
protected void OnRestoreNonConfigurationInstance(ViewState viewState)
Restore non configuration instance that was previously returned by Fragment<TViewModel>.
Parameters
viewState | The view state. |
protected ViewState OnRetainNonConfigurationInstance()
Retain non configuration instance to be used when the instance is re-created after being destroyed.
Return Types
The view state which contains non-configuration instance. |
protected void OnRotate()
Called when the activity had been rotated and is now being displayed to the user.
protected void OnViewCreated()
Called when the view is created.
protected void OnViewDisposed()
Called when the view is disposed.
protected void OnViewInitialized()
Called when view is initialized.
protected void OnViewModelDisposed()
Dispose the view model.
protected void OnViewModelPropertyChanged(PropertyChangedEventArgs e)
Called when the properties of the associated view model has changed.
Parameters
e | The System.ComponentModel.PropertyChangedEventArgs instance containing the event data. |
protected void OnViewModelResourcesChanged()
Called when the resources in view model has changed.
protected void OnViewNavigated()
Called when the view is navigated.