Skip to content

Commit

Permalink
Merge pull request #5743 from hieupham007/timob-17045
Browse files Browse the repository at this point in the history
timob-17045: Fix 'html' and 'text' properties for label in ListView
  • Loading branch information
vishalduggal committed Jun 5, 2014
2 parents fa7d94a + fda1a18 commit 4bf3043
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public boolean onTouchEvent(MotionEvent event) {
}

}

return super.onTouchEvent(event);
}

Expand All @@ -139,16 +140,23 @@ public void processProperties(KrollDict d)

boolean needShadow = false;

// Only accept one, prefer text to title.
// Only accept one, html has priority
if (d.containsKey(TiC.PROPERTY_HTML)) {
String html = TiConvert.toString(d, TiC.PROPERTY_HTML);
if (html == null) {
html = "";
//If html is null, set text if applicable
if (d.containsKey(TiC.PROPERTY_TEXT)) {
tv.setText(TiConvert.toString(d,TiC.PROPERTY_TEXT));
} else {
tv.setText(Html.fromHtml(""));
}
} else {
tv.setMovementMethod(null);
tv.setText(Html.fromHtml(html));
}
tv.setText(Html.fromHtml(html));
} else if (d.containsKey(TiC.PROPERTY_TEXT)) {
tv.setText(TiConvert.toString(d,TiC.PROPERTY_TEXT));
} else if (d.containsKey(TiC.PROPERTY_TITLE)) { //TODO this may not need to be supported.
} else if (d.containsKey(TiC.PROPERTY_TITLE)) { // For table view rows
tv.setText(TiConvert.toString(d,TiC.PROPERTY_TITLE));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class TiListView extends TiUIView implements OnSearchChangeListener {
* that must be reset every time a view is recycled, to ensure synchronization. Currently, only
* "value" is in this list to correctly update the value of Ti.UI.Switch.
*/
public static List<String> MUST_SET_PROPERTIES = Arrays.asList(TiC.PROPERTY_VALUE, TiC.PROPERTY_AUTO_LINK);
public static List<String> MUST_SET_PROPERTIES = Arrays.asList(TiC.PROPERTY_VALUE, TiC.PROPERTY_AUTO_LINK, TiC.PROPERTY_TEXT, TiC.PROPERTY_HTML);

public static final String MIN_SEARCH_HEIGHT = "50dp";
public static final String MIN_ROW_HEIGHT = "30dp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
Expand Down Expand Up @@ -142,7 +146,10 @@ public static void linkifyIfEnabled(TextView tv, Object autoLink)
{
if (autoLink != null) {
//Default to Ti.UI.AUTOLINK_NONE
Linkify.addLinks(tv, TiConvert.toInt(autoLink, 16));
boolean success = Linkify.addLinks(tv, TiConvert.toInt(autoLink, 16));
if (!success && tv.getText() instanceof Spanned) {
tv.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}

Expand Down

0 comments on commit 4bf3043

Please sign in to comment.