Created
March 28, 2014 04:24
-
-
Save verydapeng/9825388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppStyles { | |
private static final Map<String, String> imageUrlToCssClassMap = new HashMap<>(); | |
private static int counter = 0; | |
public static String getCssClassNameFor(String imageUrl) { | |
if (imageUrlToCssClassMap.containsKey(imageUrl)) { | |
return imageUrlToCssClassMap.get(imageUrl); | |
} | |
String cssClassName = ".makeYouUniqPrefix-" + counter; | |
counter++; | |
StyleInjector.inject(cssClassName + "{background-image: url(" + imageUrl + ")}"); | |
imageUrlToCssClassMap.put(imageUrl, cssClassName); | |
return cssClassName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment