Back to project page GhostStories.
The source code is released under:
GNU General Public License
If you think the Android project GhostStories listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package games.ghoststories.views.common; //from ww w . j a v a 2 s.c om import games.ghoststories.R; import games.ghoststories.data.PlayerData; import android.content.Context; import android.util.AttributeSet; import android.widget.ImageView; /** * View representing the player yin yang token */ public class YinYangTokenView extends ImageView { /** * Constructor * @param pContext The context the view is running in */ public YinYangTokenView(Context pContext) { super(pContext); } /** * Constructor * @param pContext The context the view is running in * @param pAttrs The attributes of this view */ public YinYangTokenView(Context pContext, AttributeSet pAttrs) { this(pContext, pAttrs, 0); } /** * Constructor * @param pContext The context the view is running in * @param pAttrs The attributes of this view * @param pDefStyle The default style applied to this view */ public YinYangTokenView(Context pContext, AttributeSet pAttrs, int pDefStyle) { //Since the text size is determined based on the view size, it must //be set in onDraw after the component has a height and width. super(pContext, pAttrs, pDefStyle); } /** * Sets the player data used to populate this view * @param pData The player data */ public void setData(PlayerData pData) { mPlayerData = pData; switch(mPlayerData.getColor()) { case BLUE: setImageResource(R.drawable.yin_yang_blue); break; case GREEN: setImageResource(R.drawable.yin_yang_green); break; case RED: setImageResource(R.drawable.yin_yang_red); break; case YELLOW: setImageResource(R.drawable.yin_yang_yellow); break; default: break; } } /** The player data **/ private PlayerData mPlayerData; }