Android Open Source - penmanship Penmanship






From Project

Back to project page penmanship.

License

The source code is released under:

Apache License

If you think the Android project penmanship listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mindsnacks.penmanship;
/*from  ww w . j av a2s . c o  m*/
import android.content.Context;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by tonyc on 1/16/14.
 */
public class Penmanship {
  public static ViewGroup getMarkdroidView(final String name, final Context context) {
    int id = getLayoutId(name, context);
    return (ViewGroup)LayoutInflater.from(context).inflate(id, null);
  }

  private static int getLayoutId(final String name, final Context context) {
    int id = context.getResources().getIdentifier(name, "layout", context.getPackageName());

    if (id == 0) {
      throw new RuntimeException(String.format("Attemped to load Markdroid layout: %s, but it does not exist.", name));
    }

    return id;
  }

  public static List<TextView> getTextViews(ViewGroup container) {
    List<TextView> textViews = new ArrayList<TextView>();

    for (int i = 0; i < container.getChildCount(); i++) {
      View v = container.getChildAt(i);

      if (v instanceof TextView) {
        textViews.add((TextView) container.getChildAt(i));
      } else if (v instanceof ViewGroup) {
        textViews.addAll(getTextViews((ViewGroup) v));
      }
    }

    return textViews;
  }

  public static void applyRichText(ViewGroup container) {
    for (TextView textView : getTextViews(container)) {
      textView.setMovementMethod(LinkMovementMethod.getInstance());
      textView.setText(Html.fromHtml(textView.getText().toString()));
    }
  }
}




Java Source Code List

com.mindsnacks.penmanship.AndroidMarkdownVisitor.java
com.mindsnacks.penmanship.AndroidXMLConstants.java
com.mindsnacks.penmanship.AndroidXMLNode.java
com.mindsnacks.penmanship.BaseVisitor.java
com.mindsnacks.penmanship.Penmanship.java
com.mindsnacks.penmanship.Penmanship.java
com.mindsnacks.penmanship.group_handlers.BaseHandler.java
com.mindsnacks.penmanship.group_handlers.ImageGroupHandler.java
com.mindsnacks.penmanship.group_handlers.TextNodeGroupHandler.java
com.penmanship.example.MainActivity.java