15 December, 2014

SSC - HSC Papers Collection in Divya Bhaskar's Article


This application allows to download Papers Collection of 10th and 12th standard (S.S.C. and H.S.C.).

Simply Gujarat Secondary and Higher Secondary Board provides Previous year Paper Sets. The main intention behind creating this app is you can easily and quickly download any year of examination papers.

This App Contains Following types of Papers Collection:
- 10th Standard Papers (Gujarati Medium)
- 10th Standard Papers (English Medium)
- 10th Standard Question Bank (Gujarati Medium)
- 10th Standard Question Bank (English Medium)
- 12th Standard Papers (Science - Gujarati Medium)
- 12th Standard Papers (Science - English Medium)
- 12th Standard Question Bank (Science - Gujarati Medium)
- 12th Standard Question Bank (Science - English Medium)
- 12th Standard Question Bank (Commerce - Gujarati Medium)
- GUJCAT Papers


SSC - HSC Papers Collection in Divya Bhaskar's Article:

You can Download app from: SSC HSC Papers Collection

‪#‎OnCould7‬ ‪#‎FirstStepSuccess‬ ‪#‎Achievements‬ ‪#‎Proud‬ ‪#‎BestLuck‬‪#‎DreamComesTrue‬

Post by Pratik Butani.

28 November, 2014

Support List tag of HTML in TextView using fromHtml()

As we know Html class processes HTML strings into displayable styled text.
It is not all HTML tags are supported.

There is a lovely method on the android.text.Html class, fromHtml(), that converts HTML into a Spannable for use with a TextView.
Here I found Tags list which is supported as of Android 2.1:

There is not supporting ul and li tags to display list but I found one Snippet while finding solution for List Tag supporting in TextView that i want to share with you all so it may help to other developers.

Just copy and paste following snippet whole class in as Java file in your project and use that class in parameterized:
public static Spanned fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)

Snippet for ListTagHandler:
/**
 * @author Edited By: Pratik Butani
 * @version 1.0
 * @category HTML List in TextView
 * {@link http://stackoverflow.com/a/16169511/1318946}
 */
public class ListTagHandler implements TagHandler {
    private int             index   = 0;
    private List<String>    parents = new ArrayList<String>();

    /* (non-Javadoc)
     * @see android.text.Html.TagHandler#handleTag(boolean, java.lang.String, android.text.Editable, org.xml.sax.XMLReader)
     */
    @Override
    public void handleTag(final boolean opening, final String tag, Editable output,
                    final XMLReader xmlReader) {
        if (tag.equals("ul") || tag.equals("ol") || tag.equals("dd")) {
            if (opening) {
                parents.add(tag);
            } else
                parents.remove(tag);

                index = 0;
            } else if (tag.equals("li") && !opening)
                handleListTag(output);
    }

    /**
     * @param output
     */
    private void handleListTag(Editable output) {
        if (parents.get(parents.size() - 1).equals("ul")) {
            output.append("\n");
            String[] split = output.toString().split("\n");

            int lastIndex = split.length - 1;
            int start = output.length() - split[lastIndex].length() - 1;
            output.setSpan(new BulletSpan(15 * parents.size()), start, output.length(), 0);
        } else if (parents.get(parents.size() - 1).equals("ol")) {
            index++;

            output.append("\n");
            String[] split = output.toString().split("\n");

            int lastIndex = split.length - 1;
            int start = output.length() - split[lastIndex].length() - 1;
            output.insert(start, index + ". ");
            output.setSpan(new LeadingMarginSpan.Standard(15 * parents.size()), start, output.length(), 0);
        }
    }
}

How to use:
TextView textView = (TextView) findViewById(R.id.textView1);
//class ListTagHandler will be used here.
textView.setText(Html.fromHtml(yourHtml, null, new ListTagHandler()));

Keep Sharing...

Thanks :)