Esempio n. 1
0
        /// <summary>
        /// Handles IMG tags
        /// </summary>
        /// <returns>The image.</returns>
        /// <param name="text">Text.</param>
        /// <param name="attributes">Attributes.</param>
        /// <param name="img">Image.</param>
        static void startImg(SpannableStringBuilder text, IAttributes attributes, Html.IImageGetter img)
        {
            var      src = attributes.GetValue("src");
            Drawable d   = null;

            if (img != null)
            {
                d = img.GetDrawable(src);
            }

            if (d == null)
            {
                throw new NotImplementedException("Missing Inline image implementation");
                //				d = Resources.System.GetDrawable ();
                //					getDrawable(com.android.internal.R.drawable.unknown_image);

                //				d.SetBounds (0, 0, d.IntrinsicWidth, d.IntrinsicHeight);
            }

            int len = text.Length();

            text.Append("\uFFFC");

            text.SetSpan(new ImageSpan(d, src), len, text.Length(),
                         SpanTypes.ExclusiveExclusive);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TextStyles.Android.CustomHtmlParser"/> class.
        /// </summary>
        /// <param name="source">Source.</param>
        /// <param name="textStyles">Text styles.</param>
        /// <param name="defaultStyleID">Default style identifier.</param>
        public CustomHtmlParser(string source, Dictionary <string, TextStyleParameters> textStyles, string defaultStyleID = null)
        {
            _htmlSource   = source;
            _styles       = textStyles;
            _defaultStyle = String.IsNullOrEmpty(defaultStyleID) ? null : _styles [defaultStyleID];

            _spannableStringBuilder = new SpannableStringBuilder();
            _reader      = XMLReaderFactory.CreateXMLReader("org.ccil.cowan.tagsoup.Parser");
            _imageGetter = null;
            _tagHandler  = new CustomTagHandler(textStyles);
        }
Esempio n. 3
0
        // Constructor
        public AndroidNoteCell(Context context, NoteCell cell) : base(context)
        {
            NoteCell = cell;

            var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.AndroidNoteCell, null);

            ContentText = view.FindViewById <TextView>(Resource.Id.ContentText);
            AddView(view);

            imageGetter = new AsyncHtmlImageGetter(ContentText, this.Context);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TextStyles.Android.CustomHtmlParser"/> class.
        /// </summary>
        /// <param name="source">Source.</param>
        /// <param name="textStyles">Text styles.</param>
        /// <param name="defaultStyleID">Default style identifier.</param>
        public CustomHtmlParser(TextStyle instance, string source, Dictionary <string, TextStyleParameters> textStyles, string defaultStyleID = null)
        {
            _instance   = instance;
            _htmlSource = source;
            _styles     = textStyles;

            if (!String.IsNullOrEmpty(defaultStyleID) && _styles.ContainsKey(defaultStyleID))
            {
                _defaultStyle = _styles [defaultStyleID];
            }

            _spannableStringBuilder = new SpannableStringBuilder();
            _reader      = XMLReaderFactory.CreateXMLReader("org.ccil.cowan.tagsoup.Parser");
            _imageGetter = null;
            _tagHandler  = new CustomTagHandler(_instance, _styles);
        }