Skip to main content

Content Filtering and Sorting

Content filters sort requested data by distance from the filter location (typically a geo-coordinate), in a descending order (closest first). They can also limit data by specifying a geographic area for the returned data. The content filter is set globally for the SDK, and it is an optional configuration.

By default the SDK uses device location geo point for sorting if available, and data is not filtered in any way.

Effects of location content filters

Setting content filter affects following method calls:

  • LoopMediaGroup.client().collections() - data provider that filters returned collections if filter geometry specified
  • LoopMediaGroup.client().businesses(), LoopMediaGroup.client().collectionBusinesses() - data provider sorts and filters returned businesses with offers if sorting geo point and filter geometry specified
  • LoopMediaGroup.client().locationsForBounds() - data provider sorts and filters locations if sorting geo point and filter geometry specified
  • LoopMediaGroup.client().offer() - sorts locations where offer is available if sorting geopoint specified
  • LoopMediaGroup.client().business() - sorts locations of a business if sorting geopoint specified
  • LocationMapBrowserFragment - centers on ordering geo point if one is set, otherwise displays current user location

Setting a location content filter

import com.loopmediagroup.LoopMediaGroup
import com.loopmediagroup.common.contentfilter.ContentFilter
LoopMediaGroup.client().contentFilter = ContentFilter.Builder()
.setContextGeoArea(48.407326, -123.329773, 10000.0)
.build()

Creating a content filter

Content filters are created by creating an instance of com.loopmediagroup.common.contentfilter.ContentFilter.Builder and calling one or more of the methods on the builder. A Builder instance can also be created by calling builder() on an existing instance of ContentFilter

The ContentFilter.Builder has the following methods.

methoddescription
setOrderingPoint(point: LatLng?)Sets or removes the ordering point using a com.loopmediagroup.common.LatLng instance
setOrderingPoint(lat: Double, lng: Double)Sets the ordering point using latitude and longitude values
setContextGeoArea(area: List<LatLng>?)Sets or remove the context area using a list of LatLng points. This list is required to be a closed area, ie the last point in the list should usually be the same as the first point. The list of points is required to be an an anti clockwise direction.
setContextGeoArea(center: LatLng, radius: Double)Sets the context area to a square centered on the provided point with the distance from the center point to the sides of the square as the given radius in meters. If the orderingPoint is currently null then it is also set to the center.
setContextGeoArea(lat: Double, lng: Double, radius: Double)Same as setting the contextGeoArea with a center point and radius.

Clearing the content filter

LoopMediaGroup.client().contentFilter = null