Java tutorial
/* * Copyright 2013 Bla olar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.wefika.androidResourceResizer; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.Nullable; /** * Created by blazsolar on 25/12/13. */ public enum Density { LOW(120, "Low"), MEDIUM(160, "Medium"), TV(213, "TV"), HIGH(240, "High"), XHIGH(320, "XHigh"), XXHEIGH(480, "XXHigh"), XXXHEIGHT(640, "XXXHigh"); private int mDensity; private String mName; Density(int density, String name) { mDensity = density; mName = name; } @Nullable public static Density getFromString(String density) { if (!StringUtils.isEmpty(density)) { if ("l".equalsIgnoreCase(density)) { return LOW; } else if ("m".equalsIgnoreCase(density)) { return MEDIUM; } else if ("tv".equalsIgnoreCase(density)) { return TV; } else if ("h".equalsIgnoreCase(density)) { return HIGH; } else if ("xh".equalsIgnoreCase(density)) { return XHIGH; } else if ("xxh".equalsIgnoreCase(density)) { return XXHEIGH; } else if ("xxxh".equalsIgnoreCase(density)) { return XXXHEIGHT; } } return null; } @Override public String toString() { return mName; } }