MCPcopy Create free account
hub / github.com/InsightIM/Tok-Android / StringUtils

Class StringUtils

app/src/main/java/com/client/tok/utils/StringUtils.java:18–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import java.security.MessageDigest;
17
18public class StringUtils {
19
20 public static String getTextFromResId(int resId) {
21 if (resId <= 0) {
22 return "";
23 } else {
24 return TokApplication.getInstance().getString(resId);
25 }
26 }
27
28 public static String formatTxFromResId(@StringRes int resId, Object... args) {
29 if (args == null || args.length == 0) {
30 return "";
31 }
32 String str = TokApplication.getInstance().getString(resId);
33 return String.format(str, args);
34 }
35
36 public static Spanned formatHtmlTxFromResId(@StringRes int resId, Object... args) {
37 return Html.fromHtml(formatTxFromResId(resId, args));
38 }
39
40 public static Spanned formatHtmlTxFromResId(@StringRes int resId) {
41 return Html.fromHtml(getTextFromResId(resId));
42 }
43
44 public static String inputStream2String(InputStream is) throws IOException {
45 ByteArrayOutputStream baos = new ByteArrayOutputStream();
46 int i;
47 while ((i = is.read()) != -1) {
48 baos.write(i);
49 }
50 return baos.toString();
51 }
52
53 public static boolean isEqualsWithConstant(String constant, String variable) {
54 return constant.equals(variable);
55 }
56
57 public static boolean isEquals(String srstr, String destr) {
58 if (srstr != null) {
59 return isEqualsWithConstant(srstr, destr);
60 }
61 if (destr != null) {
62 return isEqualsWithConstant(destr, srstr);
63 }
64 return false;
65 }
66
67 public static boolean isEmpty(CharSequence content) {
68 return TextUtils.isEmpty(content);
69 }
70
71 public static String getStringValue(TextView view) {
72 if (view != null) {
73 return view.getText().toString().trim();
74 }
75 return "";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected