Example usage for android.content ClipData newHtmlText

List of usage examples for android.content ClipData newHtmlText

Introduction

In this page you can find the example usage for android.content ClipData newHtmlText.

Prototype

static public ClipData newHtmlText(CharSequence label, CharSequence text, String htmlText) 

Source Link

Document

Create a new ClipData holding data of the type ClipDescription#MIMETYPE_TEXT_HTML .

Usage

From source file:de.enlightened.peris.SocialFragment.java

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void storePostInClipboard() {

    //Copy text support for all Android versions
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        final ClipboardManager clipboard = (ClipboardManager) getActivity()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        final ClipData cd = ClipData.newHtmlText(this.selectedPost.author + "'s Social Post",
                this.selectedPost.body, this.selectedPost.body);
        clipboard.setPrimaryClip(cd);/*from ww w . j  av  a  2  s.c  om*/
    } else {
        final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText(this.selectedPost.body);
    }

    final Toast toast = Toast.makeText(this.getActivity(), "Text copied!", Toast.LENGTH_SHORT);
    toast.show();
}

From source file:tv.acfun.video.CommentsActivity.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override//from  w ww.j av  a2s .  c om
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Object o = parent.getItemAtPosition(position);
    if (o == null || !(o instanceof Comment))
        return false;
    Comment c = (Comment) o;
    ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content);
        ((android.content.ClipboardManager) ma).setPrimaryClip(text);
    } else {
        ma.setText(c.content);
    }
    Toast.makeText(this, "#" + c.count + "?", 0).show();
    return true;
}

From source file:de.enlightened.peris.PostsFragment.java

@SuppressLint("NewApi")
private void storePostInClipboard() {

    //Copy text support for all Android versions
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        final ClipboardManager clipboard = (ClipboardManager) this.activity
                .getSystemService(Context.CLIPBOARD_SERVICE);
        final ClipData cd = ClipData.newHtmlText(this.currentThreadSubject, this.selectedPost.body,
                this.selectedPost.body);
        clipboard.setPrimaryClip(cd);//w  w w  .j  a v a  2s.  c  o  m
    } else {
        final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) this.activity
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText(this.selectedPost.body);
    }

    final Toast toast = Toast.makeText(this.activity, "Text copied!", Toast.LENGTH_SHORT);
    toast.show();
}

From source file:tv.acfun.a63.CommentsActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override//from  ww w . j ava  2s. c o  m
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Object o = parent.getItemAtPosition(position);
    if (o == null || !(o instanceof Comment))
        return false;
    Comment c = (Comment) o;
    ClipboardManager ma = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ClipData text = ClipData.newHtmlText(c.userName, c.content, c.content);
        ((android.content.ClipboardManager) ma).setPrimaryClip(text);
    } else {
        ma.setText(c.content);
    }
    Toast.makeText(this, "#" + c.count + "?", 0).show();
    return true;
}