Class AppEntity
The platform-facing view of one of your app's nouns -- an order, a playlist, a saved route.
This is what an entity looks like after it has left your code. Your own
class stays your own class; the build reads its EntityId / EntityTitle /
EntitySubtitle / EntityImage members and generates the adapter that
produces one of these. You construct AppEntity directly only when indexing
content that has no annotated class behind it.
The field set is small because it is the intersection of what every platform entity display model actually has: something to identify it by, something to show, something to show underneath, a picture, and words to match a search against.
The id is a promise
Ids outlive the process. Spotlight keeps indexed items and the system keeps donated shortcuts, both of them holding your id, so an id has to mean the same thing after an app update as it did before. An id derived from a list position or a content hash will silently start resolving to the wrong object and nothing will report an error.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddKeywords(String... words) Extra words a search should match this entity on, beyond its title and subtitle.getId()The stable identifier of this instance.getImage()The thumbnail, or null.The keywords added so far.The secondary line, or null.getTitle()The primary line shown by a picker or a search result.getType()The entity type id.setImage(EncodedImage image) Sets the thumbnail.setSubtitle(String subtitle) Sets the secondary line.Sets the primary line.toString()Returns a string representation of the object.
-
Constructor Details
-
AppEntity
Creates an entity of a declared type.
Parameters
type: the entity type id, matching anIntentEntitydeclaration. It may not contain:, which separates the type from the id in the identifier the platforms store.id: the stable identifier of this instance. Colons are fine here: the uid splits at the first one, so everything after it is the id.
-
-
Method Details
-
getType
The entity type id. -
getId
The stable identifier of this instance. -
getTitle
The primary line shown by a picker or a search result. -
setTitle
-
getSubtitle
The secondary line, or null. -
setSubtitle
-
getImage
The thumbnail, or null. -
setImage
Sets the thumbnail.
An
EncodedImagerather than anImagebecause the bytes cross to the platform as-is. Handing over an image that still has to be rasterized would mean encoding it here, which on a device is exactly the kind of work that looks instantaneous in the simulator and stalls on hardware.Parameters
image: the thumbnail
Returns
this entity, for chaining
-
addKeywords
-
getKeywords
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-