Search in sources :

Example 61 with ClipboardManager

use of android.content.ClipboardManager in project Klyph by jonathangerbaud.

the class ImageFragment method handleCopyTextAction.

private void handleCopyTextAction(Comment comment) {
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("Comment", comment.getMessage());
    clipboard.setPrimaryClip(clip);
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 62 with ClipboardManager

use of android.content.ClipboardManager in project glide by bumptech.

the class FullscreenActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullscreen_activity);
    String resultJson = getIntent().getStringExtra(EXTRA_RESULT_JSON);
    final Api.GifResult result = new Gson().fromJson(resultJson, Api.GifResult.class);
    ImageView gifView = (ImageView) findViewById(R.id.fullscreen_gif);
    gifView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("giphy_url", result.images.original.url);
            clipboard.setPrimaryClip(clip);
            if (gifDrawable != null) {
                if (gifDrawable.isRunning()) {
                    gifDrawable.stop();
                } else {
                    gifDrawable.start();
                }
            }
        }
    });
    RequestBuilder<Drawable> thumbnailRequest = Glide.with(this).load(result).apply(decodeTypeOf(Bitmap.class));
    Glide.with(this).load(result.images.original.url).thumbnail(thumbnailRequest).listener(new RequestListener<Drawable>() {

        @Override
        public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
            return false;
        }

        @Override
        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
            if (resource instanceof GifDrawable) {
                gifDrawable = (GifDrawable) resource;
            } else {
                gifDrawable = null;
            }
            return false;
        }
    }).into(gifView);
}
Also used : ClipboardManager(android.content.ClipboardManager) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) Gson(com.google.gson.Gson) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) ImageView(android.widget.ImageView) View(android.view.View) DataSource(com.bumptech.glide.load.DataSource) Bitmap(android.graphics.Bitmap) Target(com.bumptech.glide.request.target.Target) ImageView(android.widget.ImageView) ClipData(android.content.ClipData) GlideException(com.bumptech.glide.load.engine.GlideException)

Example 63 with ClipboardManager

use of android.content.ClipboardManager in project Meizhi by drakeet.

the class Androids method copyToClipBoard.

public static void copyToClipBoard(Context context, String text, String success) {
    ClipData clipData = ClipData.newPlainText("meizhi_copy", text);
    ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    manager.setPrimaryClip(clipData);
    Toast.makeText(context, success, Toast.LENGTH_SHORT).show();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 64 with ClipboardManager

use of android.content.ClipboardManager in project qianghongbao by lendylongli.

the class MainActivity method showQrDialog.

/** 二维码*/
private void showQrDialog() {
    final Dialog dialog = new Dialog(this, R.style.QR_Dialog_Theme);
    View view = getLayoutInflater().inflate(R.layout.qr_dialog_layout, null);
    view.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String id = getString(R.string.qr_wx_id);
            ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("label", id);
            clipboardManager.setPrimaryClip(clip);
            //跳到微信
            Intent wxIntent = getPackageManager().getLaunchIntentForPackage(WechatAccessbilityJob.WECHAT_PACKAGENAME);
            if (wxIntent != null) {
                try {
                    startActivity(wxIntent);
                } catch (Exception e) {
                }
            }
            Toast.makeText(getApplicationContext(), "已复制到粘贴板", Toast.LENGTH_LONG).show();
            QHBApplication.eventStatistics(MainActivity.this, "copy_qr");
            dialog.dismiss();
        }
    });
    dialog.setContentView(view);
    dialog.show();
}
Also used : ClipboardManager(android.content.ClipboardManager) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) Intent(android.content.Intent) View(android.view.View) ClipData(android.content.ClipData)

Example 65 with ClipboardManager

use of android.content.ClipboardManager in project GeekNews by codeestX.

the class SystemUtil method copyToClipBoard.

/**
     * 保存文字到剪贴板
     * @param context
     * @param text
     */
public static void copyToClipBoard(Context context, String text) {
    ClipData clipData = ClipData.newPlainText("url", text);
    ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    manager.setPrimaryClip(clipData);
    ToastUtil.shortShow("已复制到剪贴板");
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Aggregations

ClipboardManager (android.content.ClipboardManager)125 ClipData (android.content.ClipData)82 Intent (android.content.Intent)17 View (android.view.View)15 TextView (android.widget.TextView)13 Context (android.content.Context)10 Paint (android.graphics.Paint)9 DialogInterface (android.content.DialogInterface)7 Bundle (android.os.Bundle)7 AlertDialog (android.support.v7.app.AlertDialog)7 Editable (android.text.Editable)7 TextPaint (android.text.TextPaint)7 ImageView (android.widget.ImageView)6 TargetApi (android.annotation.TargetApi)5 Spanned (android.text.Spanned)5 AlertDialog (android.app.AlertDialog)4 Uri (android.net.Uri)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 MenuItem (android.view.MenuItem)3