mobi.voiceassistant.base
Class ResId
java.lang.Object
mobi.voiceassistant.base.ResId
- All Implemented Interfaces:
- Parcelable
public final class ResId
- extends Object
- implements Parcelable
Simple tulpe (pair) of String and int.
Being used to identify resources from different apks. Inspired by ComponentName and
constructors RemoteViews. Can be transferred with parcel.
CREATOR
public static final Parcelable.Creator<ResId> CREATOR
ResId
public ResId(Context pkg,
int resourceId)
- Constructs
ResId from context's package name and resource's id
- Parameters:
pkg - Context from which package name will be takenresourceId - Resource id- See Also:
ResId(String, int)
ResId
public ResId(String packageName,
int resourceId)
- Main constructor
- Parameters:
packageName - Package nameresourceId - Resource id
ResId
public ResId(Context context,
Uri uri)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException
ResId
public ResId(Context context,
String string)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException
describeContents
public int describeContents()
- Specified by:
describeContents in interface Parcelable
equals
public boolean equals(Object o)
- Overrides:
equals in class Object
- Parameters:
o - Other object
- Returns:
true if other object is ResId and package name and resource ids are same. false otherwise.- See Also:
equals(String, int)
equals
public boolean equals(String packageName,
int resourceId)
- Parameters:
packageName - Other package nameresourceId - Other resource id
- Returns:
true if other package name and resource id are same as this ones. false otherwise.
isSymbolic
public boolean isSymbolic()
- Returns:
- Whether resource type and antry names are known
getId
public int getId()
- Returns:
- Resource id
getPackageName
public String getPackageName()
- Returns:
- Package name
getTypeName
public String getTypeName()
- Returns:
- Resource type name or
null if resource is not symbolic
getEntryName
public String getEntryName()
- Returns:
- Resource entry name or
null if resource is not symbolic
toUri
public Uri toUri()
toString
public String toString()
- Overrides:
toString in class Object
toShortString
public String toShortString(Context pkg)
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
writeToParcel
public void writeToParcel(Parcel parcel,
int flags)
- Specified by:
writeToParcel in interface Parcelable
writeToParcel
public static void writeToParcel(Parcel parcel,
ResId resId)
symbolic
public ResId symbolic(Context context)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException
nonSymbolic
public ResId nonSymbolic()
symbolic
public static ResId symbolic(Context context,
int resourceId)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException
nonSymbolic
public static ResId nonSymbolic(Context context,
String string)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException
nonSymbolic
public static ResId nonSymbolic(Context context,
Uri uri)
throws PackageManager.NameNotFoundException
- Throws:
PackageManager.NameNotFoundException