public java.lang.CharSequence get(int idx) { lock (this) { if (mStrings != null) { java.lang.CharSequence res = mStrings[idx]; if (res != null) { return(res); } } else { if (mSparseStrings != null) { java.lang.CharSequence res = mSparseStrings.get(idx); if (res != null) { return(res); } } else { int num = nativeGetSize(mNative); if (mUseSparse && num > 250) { mSparseStrings = new android.util.SparseArray <java.lang.CharSequence>(); } else { mStrings = new java.lang.CharSequence[num]; } } } string str = nativeGetString(mNative, idx); java.lang.CharSequence res_1 = java.lang.CharSequenceProxy.Wrap(str); int[] style = nativeGetStyle(mNative, idx); if (style != null) { if (mStyleIDs == null) { mStyleIDs = new android.content.res.StringBlock.StyleIDs(); } { for (int styleIndex = 0; styleIndex < style.Length; styleIndex += 3) { int styleId = style[styleIndex]; if (styleId == mStyleIDs.boldId || styleId == mStyleIDs.italicId || styleId == mStyleIDs .underlineId || styleId == mStyleIDs.ttId || styleId == mStyleIDs.bigId || styleId == mStyleIDs.smallId || styleId == mStyleIDs.subId || styleId == mStyleIDs.supId || styleId == mStyleIDs.strikeId || styleId == mStyleIDs.listItemId || styleId == mStyleIDs.marqueeId) { continue; } string styleTag = nativeGetString(mNative, styleId); if (styleTag.Equals("b")) { mStyleIDs.boldId = styleId; } else { if (styleTag.Equals("i")) { mStyleIDs.italicId = styleId; } else { if (styleTag.Equals("u")) { mStyleIDs.underlineId = styleId; } else { if (styleTag.Equals("tt")) { mStyleIDs.ttId = styleId; } else { if (styleTag.Equals("big")) { mStyleIDs.bigId = styleId; } else { if (styleTag.Equals("small")) { mStyleIDs.smallId = styleId; } else { if (styleTag.Equals("sup")) { mStyleIDs.supId = styleId; } else { if (styleTag.Equals("sub")) { mStyleIDs.subId = styleId; } else { if (styleTag.Equals("strike")) { mStyleIDs.strikeId = styleId; } else { if (styleTag.Equals("li")) { mStyleIDs.listItemId = styleId; } else { if (styleTag.Equals("marquee")) { mStyleIDs.marqueeId = styleId; } } } } } } } } } } } } } res_1 = applyStyles(str, style, mStyleIDs); } if (mStrings != null) { mStrings[idx] = res_1; } else { mSparseStrings.put(idx, res_1); } return(res_1); } }
public java.lang.CharSequence get(int idx) { lock (this) { if (mStrings != null) { java.lang.CharSequence res = mStrings[idx]; if (res != null) { return res; } } else { if (mSparseStrings != null) { java.lang.CharSequence res = mSparseStrings.get(idx); if (res != null) { return res; } } else { int num = nativeGetSize(mNative); if (mUseSparse && num > 250) { mSparseStrings = new android.util.SparseArray<java.lang.CharSequence>(); } else { mStrings = new java.lang.CharSequence[num]; } } } string str = nativeGetString(mNative, idx); java.lang.CharSequence res_1 = java.lang.CharSequenceProxy.Wrap(str); int[] style = nativeGetStyle(mNative, idx); if (style != null) { if (mStyleIDs == null) { mStyleIDs = new android.content.res.StringBlock.StyleIDs(); } { for (int styleIndex = 0; styleIndex < style.Length; styleIndex += 3) { int styleId = style[styleIndex]; if (styleId == mStyleIDs.boldId || styleId == mStyleIDs.italicId || styleId == mStyleIDs .underlineId || styleId == mStyleIDs.ttId || styleId == mStyleIDs.bigId || styleId == mStyleIDs.smallId || styleId == mStyleIDs.subId || styleId == mStyleIDs.supId || styleId == mStyleIDs.strikeId || styleId == mStyleIDs.listItemId || styleId == mStyleIDs.marqueeId) { continue; } string styleTag = nativeGetString(mNative, styleId); if (styleTag.Equals("b")) { mStyleIDs.boldId = styleId; } else { if (styleTag.Equals("i")) { mStyleIDs.italicId = styleId; } else { if (styleTag.Equals("u")) { mStyleIDs.underlineId = styleId; } else { if (styleTag.Equals("tt")) { mStyleIDs.ttId = styleId; } else { if (styleTag.Equals("big")) { mStyleIDs.bigId = styleId; } else { if (styleTag.Equals("small")) { mStyleIDs.smallId = styleId; } else { if (styleTag.Equals("sup")) { mStyleIDs.supId = styleId; } else { if (styleTag.Equals("sub")) { mStyleIDs.subId = styleId; } else { if (styleTag.Equals("strike")) { mStyleIDs.strikeId = styleId; } else { if (styleTag.Equals("li")) { mStyleIDs.listItemId = styleId; } else { if (styleTag.Equals("marquee")) { mStyleIDs.marqueeId = styleId; } } } } } } } } } } } } } res_1 = applyStyles(str, style, mStyleIDs); } if (mStrings != null) { mStrings[idx] = res_1; } else { mSparseStrings.put(idx, res_1); } return res_1; } }
internal java.lang.CharSequence applyStyles(string str, int[] style, android.content.res.StringBlock .StyleIDs ids) { if (style.Length == 0) { return(java.lang.CharSequenceProxy.Wrap(str)); } android.text.SpannableString buffer = new android.text.SpannableString(java.lang.CharSequenceProxy.Wrap (str)); int i = 0; while (i < style.Length) { int type = style[i]; if (type == ids.boldId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.italicId) { buffer.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.ITALIC) , style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE ); } else { if (type == ids.underlineId) { buffer.setSpan(new android.text.style.UnderlineSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.ttId) { buffer.setSpan(new android.text.style.TypefaceSpan("monospace"), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.bigId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(1.25f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.smallId) { buffer.setSpan(new android.text.style.RelativeSizeSpan(0.8f), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.subId) { buffer.setSpan(new android.text.style.SubscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.supId) { buffer.setSpan(new android.text.style.SuperscriptSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.strikeId) { buffer.setSpan(new android.text.style.StrikethroughSpan(), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (type == ids.listItemId) { addParagraphSpan(buffer, new android.text.style.BulletSpan(10), style[i + 1], style [i + 2] + 1); } else { if (type == ids.marqueeId) { buffer.setSpan(android.text.TextUtils.TruncateAt.MARQUEE, style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_INCLUSIVE_INCLUSIVE); } else { string tag = nativeGetString(mNative, type); if (tag.StartsWith("font;")) { string sub; sub = subtag(tag, ";height="); if (sub != null) { int size = System.Convert.ToInt32(sub); addParagraphSpan(buffer, new android.content.res.StringBlock.Height(size), style[ i + 1], style[i + 2] + 1); } sub = subtag(tag, ";size="); if (sub != null) { int size = System.Convert.ToInt32(sub); buffer.setSpan(new android.text.style.AbsoluteSizeSpan(size, true), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";fgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.ForegroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } sub = subtag(tag, ";bgcolor="); if (sub != null) { int color = [email protected](sub, -1); buffer.setSpan(new android.text.style.BackgroundColorSpan(color), style[i + 1], style [i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("a;")) { string sub; sub = subtag(tag, ";href="); if (sub != null) { buffer.setSpan(new android.text.style.URLSpan(sub), style[i + 1], style[i + 2] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { if (tag.StartsWith("annotation;")) { int len = tag.Length; int next; { for (int t = tag.IndexOf(';'); t < len; t = next) { int eq = tag.IndexOf('=', t); if (eq < 0) { break; } next = tag.IndexOf(';', eq); if (next < 0) { next = len; } string key = Sharpen.StringHelper.Substring(tag, t + 1, eq); string value = Sharpen.StringHelper.Substring(tag, eq + 1, next); buffer.setSpan(new android.text.Annotation(key, value), style[i + 1], style[i + 2 ] + 1, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE); } } } } } } } } } } } } } } } } i += 3; } return(new android.text.SpannedString(buffer)); }