Android Open Source - dexedd Type Util






From Project

Back to project page dexedd.

License

The source code is released under:

MIT License

If you think the Android project dexedd listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nav.dexedd.util;
//from  w  ww  . j  ava2  s  .  co  m
import com.nav.dexedd.R;

/**
 * Type utility methods.
 *
 * @author Eduardo Naveda
 * @since 0.0.1
 */
public class TypeUtil {

    public static enum TypeValue {

        NONE(0), NORMAL(1), FIGHTING(2), FLYING(3), POISON(4), GROUND(5), ROCK(6), BUG(7), GHOST(8), STEEL(9), FIRE(10),
        WATER(11), GRASS(12), ELECTRIC(13), PSYCHIC(14), ICE(15), DRAGON(16), DARK(17), FAIRY(18), UNKNOWN(10001);

        private int type;

        TypeValue(Integer type) {
            this.type = type;
        }

        public static TypeValue getTypeValueByValue(Integer typeValue) {
            for (TypeValue type : TypeValue.values()) {
                if (type.type == typeValue) {
                    return type;
                }
            }
            return NONE;
        }

        public static TypeValue getTypeValueByName(String typeName) {
            for (TypeValue type : TypeValue.values()) {
                if (type.toString().equalsIgnoreCase(typeName)) {
                    return type;
                }
            }
            return NONE;
        }

    }

    /**
     * Returns the resource id for a given {@link TypeValue TypeValue} enum.
     *
     * @param typeValue a Pokmon {@link TypeValue TypeValue} enum
     *
     * @return The type resource id
     */
    public static int getTypeNameRes(TypeValue typeValue) {
        switch (typeValue) {
            case NONE:
                return R.string.none;
            case NORMAL:
                return R.string.normal;
            case FIGHTING:
                return R.string.fighting;
            case FLYING:
                return R.string.flying;
            case POISON:
                return R.string.poison;
            case GROUND:
                return R.string.ground;
            case ROCK:
                return R.string.rock;
            case BUG:
                return R.string.bug;
            case GHOST:
                return R.string.ghost;
            case STEEL:
                return R.string.steel;
            case FIRE:
                return R.string.fire;
            case WATER:
                return R.string.water;
            case GRASS:
                return R.string.grass;
            case ELECTRIC:
                return R.string.electric;
            case PSYCHIC:
                return R.string.psychic;
            case ICE:
                return R.string.ice;
            case DRAGON:
                return R.string.dragon;
            case DARK:
                return R.string.dark;
            case FAIRY:
                return R.string.fairy;
            default:
                return R.string.none;
        }
    }

    /**
     * Returns the color resource id for a given {@link TypeUtil.TypeValue TypeValue} enum.
     *
     * @param typeValue a Pokmon {@link TypeUtil.TypeValue TypeValue} enum
     *
     * @return The type color resource id
     */
    public static int getTypeColorRes(TypeValue typeValue) {
        switch (typeValue) {
            case NONE:
                return R.color.none;
            case NORMAL:
                return R.color.normal;
            case FIGHTING:
                return R.color.fighting;
            case FLYING:
                return R.color.flying;
            case POISON:
                return R.color.poison;
            case GROUND:
                return R.color.ground;
            case ROCK:
                return R.color.rock;
            case BUG:
                return R.color.bug;
            case GHOST:
                return R.color.ghost;
            case STEEL:
                return R.color.steel;
            case FIRE:
                return R.color.fire;
            case WATER:
                return R.color.water;
            case GRASS:
                return R.color.grass;
            case ELECTRIC:
                return R.color.electric;
            case PSYCHIC:
                return R.color.psychic;
            case ICE:
                return R.color.ice;
            case DRAGON:
                return R.color.dragon;
            case DARK:
                return R.color.dark;
            case FAIRY:
                return R.color.fairy;
            default:
                return R.color.none;
        }
    }

    /**
     * Returns the background resource id for a given {@link TypeUtil.TypeValue TypeValue} enum.
     *
     * @param typeValue a Pokmon {@link TypeUtil.TypeValue TypeValue} enum
     *
     * @return The type background resource id
     */
    public static int getTypeBackgroundRes(TypeValue typeValue) {
        switch (typeValue) {
            case NONE:
                return R.drawable.type_background_none;
            case NORMAL:
                return R.drawable.type_background_normal;
            case FIGHTING:
                return R.drawable.type_background_fighting;
            case FLYING:
                return R.drawable.type_background_flying;
            case POISON:
                return R.drawable.type_background_poison;
            case GROUND:
                return R.drawable.type_background_ground;
            case ROCK:
                return R.drawable.type_background_rock;
            case BUG:
                return R.drawable.type_background_bug;
            case GHOST:
                return R.drawable.type_background_ghost;
            case STEEL:
                return R.drawable.type_background_steel;
            case FIRE:
                return R.drawable.type_background_fire;
            case WATER:
                return R.drawable.type_background_water;
            case GRASS:
                return R.drawable.type_background_grass;
            case ELECTRIC:
                return R.drawable.type_background_electric;
            case PSYCHIC:
                return R.drawable.type_background_psychic;
            case ICE:
                return R.drawable.type_background_ice;
            case DRAGON:
                return R.drawable.type_background_dragon;
            case DARK:
                return R.drawable.type_background_dark;
            case FAIRY:
                return R.drawable.type_background_fairy;
            default:
                return R.drawable.type_background_none;
        }
    }

    /**
     * Returns the theme resource id for a given {@link TypeUtil.TypeValue TypeValue} enum.
     *
     * @param typeValue a Pokmon {@link TypeUtil.TypeValue TypeValue} enum
     *
     * @return The type theme resource id
     */
    public static int getTypeStyleRes(TypeValue typeValue) {
        switch (typeValue) {
            case NONE:
                return R.style.Theme_DexThemeNone;
            case NORMAL:
                return R.style.Theme_DexThemeNormal;
            case FIGHTING:
                return R.style.Theme_DexThemeFighting;
            case FLYING:
                return R.style.Theme_DexThemeFlying;
            case POISON:
                return R.style.Theme_DexThemePoison;
            case GROUND:
                return R.style.Theme_DexThemeGround;
            case ROCK:
                return R.style.Theme_DexThemeRock;
            case BUG:
                return R.style.Theme_DexThemeBug;
            case GHOST:
                return R.style.Theme_DexThemeGhost;
            case STEEL:
                return R.style.Theme_DexThemeSteel;
            case FIRE:
                return R.style.Theme_DexThemeFire;
            case WATER:
                return R.style.Theme_DexThemeWater;
            case GRASS:
                return R.style.Theme_DexThemeGrass;
            case ELECTRIC:
                return R.style.Theme_DexThemeElectric;
            case PSYCHIC:
                return R.style.Theme_DexThemePsychic;
            case ICE:
                return R.style.Theme_DexThemeIce;
            case DRAGON:
                return R.style.Theme_DexThemeDragon;
            case DARK:
                return R.style.Theme_DexThemeDark;
            case FAIRY:
                return R.style.Theme_DexThemeFairy;
            default:
                return R.style.Theme_DexThemeNone;
        }
    }
}




Java Source Code List

com.nav.dexedd.activity.DexEntryActivity.java
com.nav.dexedd.activity.Dexedd.java
com.nav.dexedd.activity.MainActivity.java
com.nav.dexedd.activity.SplashActivity.java
com.nav.dexedd.adapter.DexAdapter.java
com.nav.dexedd.adapter.TreeAdapter.java
com.nav.dexedd.fragment.DatabaseInitFragment.java
com.nav.dexedd.fragment.NavigationDrawerFragment.java
com.nav.dexedd.model.Ability.java
com.nav.dexedd.model.EggGroup.java
com.nav.dexedd.model.EvolutionCondition.java
com.nav.dexedd.model.Item.java
com.nav.dexedd.model.Location.java
com.nav.dexedd.model.Move.java
com.nav.dexedd.model.Pokemon.java
com.nav.dexedd.model.Region.java
com.nav.dexedd.model.StatSpread.java
com.nav.dexedd.model.Stat.java
com.nav.dexedd.model.Type.java
com.nav.dexedd.persistence.DexDatabase.java
com.nav.dexedd.persistence.access.Access.java
com.nav.dexedd.persistence.access.DexEntry.java
com.nav.dexedd.persistence.access.Dex.java
com.nav.dexedd.structure.Tree.java
com.nav.dexedd.text.CleanClickableSpan.java
com.nav.dexedd.ui.BetterGridView.java
com.nav.dexedd.ui.BetterScrollView.java
com.nav.dexedd.ui.LabelView.java
com.nav.dexedd.ui.SquareImageView.java
com.nav.dexedd.ui.TreeLayout.java
com.nav.dexedd.ui.TypeTagView.java
com.nav.dexedd.util.AssetUtil.java
com.nav.dexedd.util.ConversionUtil.java
com.nav.dexedd.util.PokemonTextUtil.java
com.nav.dexedd.util.TypeUtil.java