mobi.voiceassistant.base
Class ResId

java.lang.Object
  extended by 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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
 
Field Summary
static Parcelable.Creator<ResId> CREATOR
           
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Constructor Summary
ResId(Context pkg, int resourceId)
          Constructs ResId from context's package name and resource's id
ResId(Context context, String string)
           
ResId(Context context, Uri uri)
           
ResId(String packageName, int resourceId)
          Main constructor
 
Method Summary
 int describeContents()
           
 boolean equals(Object o)
           
 boolean equals(String packageName, int resourceId)
           
 String getEntryName()
           
 int getId()
           
 String getPackageName()
           
 String getTypeName()
           
 int hashCode()
           
 boolean isSymbolic()
           
 ResId nonSymbolic()
           
static ResId nonSymbolic(Context context, String string)
           
static ResId nonSymbolic(Context context, Uri uri)
           
 ResId symbolic(Context context)
           
static ResId symbolic(Context context, int resourceId)
           
 String toShortString(Context pkg)
           
 String toString()
           
 Uri toUri()
           
 void writeToParcel(Parcel parcel, int flags)
           
static void writeToParcel(Parcel parcel, ResId resId)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CREATOR

public static final Parcelable.Creator<ResId> CREATOR
Constructor Detail

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 taken
resourceId - Resource id
See Also:
ResId(String, int)

ResId

public ResId(String packageName,
             int resourceId)
Main constructor

Parameters:
packageName - Package name
resourceId - 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
Method Detail

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 name
resourceId - 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