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
@interface WrapCollectionView : UICollectionView | |
@end | |
@implementation WrapCollectionView | |
- (void) layoutSubviews | |
{ | |
[super layoutSubviews]; | |
if (!CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize])) |
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 VersionComparator implements Comparator<String> { | |
@Override | |
public int compare(String lhs, String rhs) { | |
lhs = lhs.replaceAll("[^0-9.]", ""); | |
rhs = rhs.replaceAll("[^0-9.]", ""); | |
Scanner leftVersionScanner = new Scanner(lhs); | |
Scanner rightVersionScanner = new Scanner(rhs); | |
leftVersionScanner.useDelimiter("\\."); |
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 static int dp2px(Context ctx, float dp) { | |
final float scale = ctx.getResources().getDisplayMetrics().density; | |
return (int) (dp * scale + 0.5f); | |
} | |
public static int px2dp(Context ctx, float px) { | |
final float scale = ctx.getResources().getDisplayMetrics().density; | |
return (int) (px / scale + 0.5f); | |
} |
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 static String replace(String content, String tagExp, String targetExp, Replacer replacer) { | |
Pattern tagPattern = Pattern.compile(tagExp); | |
Pattern targetPattern = Pattern.compile(targetExp); | |
Matcher tagMather = tagPattern.matcher(content); | |
StringBuilder contentBuilder = new StringBuilder(content); | |
int offset = 0; | |
while (tagMather.find()) { | |
String tag = tagMather.group(); | |
Matcher targetMatcher = targetPattern.matcher(tag); | |
if (!targetMatcher.find()) { |