2015-01-23 17:09:03 +01:00
|
|
|
package org.mariotaku.twidere.extension.twitlonger;
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
2016-03-19 10:39:03 +01:00
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
2015-01-23 17:09:03 +01:00
|
|
|
public class Utils {
|
|
|
|
|
2016-03-19 10:39:03 +01:00
|
|
|
private static final Pattern PATTERN_TWITLONGER = Pattern.compile(
|
|
|
|
"(https?://)(tl\\.gd|www.twitlonger.com/show)/([\\w\\d]+)", Pattern.CASE_INSENSITIVE);
|
|
|
|
private static final int GROUP_TWITLONGER_ID = 3;
|
|
|
|
|
|
|
|
public static String getTwitLongerId(String text) {
|
|
|
|
if (TextUtils.isEmpty(text)) return null;
|
|
|
|
return PATTERN_TWITLONGER.matcher(text).group(GROUP_TWITLONGER_ID);
|
|
|
|
}
|
2015-01-23 17:09:03 +01:00
|
|
|
|
2016-03-19 10:39:03 +01:00
|
|
|
public static String getTwitLongerUrl(String text) {
|
|
|
|
if (TextUtils.isEmpty(text)) return null;
|
|
|
|
return PATTERN_TWITLONGER.matcher(text).group();
|
|
|
|
}
|
2015-01-23 17:09:03 +01:00
|
|
|
|
|
|
|
}
|