当前位置: 首页>>代码示例>>Java>>正文


Java ClipData类代码示例

本文整理汇总了Java中android.content.ClipData的典型用法代码示例。如果您正苦于以下问题:Java ClipData类的具体用法?Java ClipData怎么用?Java ClipData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClipData类属于android.content包,在下文中一共展示了ClipData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importVideoFromClipData

import android.content.ClipData; //导入依赖的package包/类
private static void importVideoFromClipData(Intent data) {
    ClipData clipData = data.getClipData();

    Log.d(TAG,"Video importFromClipData");

    if (clipData.getItemCount() == 0)
        return;

    ArrayList<Uri> uris = new ArrayList(clipData.getItemCount());

    for (int i = 0 ; i < clipData.getItemCount() ; i++ ){
        Uri uri = clipData.getItemAt(i).getUri();
        uris.add(resolveUri(uri));
    }
    importVideoFromFileUri(uris);
}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:17,代码来源:VideoPicker.java

示例2: importImageFromClipData

import android.content.ClipData; //导入依赖的package包/类
private static void importImageFromClipData(Intent data) {
    ClipData clipData = data.getClipData();

    Log.d(TAG,"importFromClipData");

    if (clipData.getItemCount() == 0)
        return;

    ArrayList<Uri> uris = new ArrayList(clipData.getItemCount());

    for (int i = 0 ; i < clipData.getItemCount() ; i++ ){
        Uri uri = clipData.getItemAt(i).getUri();
        uris.add(resolveUri(uri));
    }
    importImageFromFileUri(uris);
}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:17,代码来源:ImagePicker.java

示例3: onMenuItemClick

import android.content.ClipData; //导入依赖的package包/类
@Override
public boolean onMenuItemClick(MenuItem item, LogLine logLine) {
    if (logLine != null) {
        switch (item.getItemId()) {
            case CONTEXT_MENU_COPY_ID:
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

                clipboard.setPrimaryClip(ClipData.newPlainText(null, logLine.getOriginalLine()));
                Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
                return true;
            case CONTEXT_MENU_FILTER_ID:

                if (logLine.getProcessId() == -1) {
                    // invalid line
                    return false;
                }

                showSearchByDialog(logLine);
                return true;
        }
    }
    return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:LogcatActivity.java

示例4: onOptionsItemSelected

import android.content.ClipData; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.miCopySysInfo:
            ClipboardManager manager = (ClipboardManager)getSystemService(Activity.CLIPBOARD_SERVICE);
            if (manager == null) {
                Toast.makeText(this, "Couldn't access clipboard", Toast.LENGTH_LONG).show();
                return true;
            }

            manager.setPrimaryClip(ClipData.newPlainText(CLIP_TITLE, debugOutput));
            Toast.makeText(this, "Copied to clipboard", Toast.LENGTH_LONG).show();
            return true;

        case R.id.miShareSysInfo:
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT, debugOutput);
            startActivity(i);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:AndProx,项目名称:AndProx,代码行数:24,代码来源:SysInfoActivity.java

示例5: onBindViewHolder

import android.content.ClipData; //导入依赖的package包/类
@Override
public void onBindViewHolder(GifViewHolder holder, int position) {
  final Api.GifResult result = results[position];
  holder.gifView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      ClipboardManager clipboard =
          (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
      ClipData clip =
          ClipData.newPlainText("giphy_url", result.images.fixed_height.url);
      clipboard.setPrimaryClip(clip);

      Intent fullscreenIntent = FullscreenActivity.getIntent(activity, result);
      activity.startActivity(fullscreenIntent);
    }
  });

  requestBuilder.load(result).into(holder.gifView);

  preloadSizeProvider.setView(holder.gifView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:MainActivity.java

示例6: copyLink

import android.content.ClipData; //导入依赖的package包/类
@Override
public void copyLink() {
    if (checkNull()) {
        view.showCopyTextError();
        return;
    }

    ClipboardManager manager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    ClipData clipData = null;
    switch (type) {
        case TYPE_ZHIHU:
            clipData = ClipData.newPlainText("text", Html.fromHtml(zhihuDailyStory.getShare_url()).toString());
            break;
        case TYPE_GUOKR:
            clipData = ClipData.newPlainText("text", Html.fromHtml(Api.GUOKR_ARTICLE_LINK_V1 + id).toString());
            break;
        case TYPE_DOUBAN:
            clipData = ClipData.newPlainText("text", Html.fromHtml(doubanMomentStory.getOriginal_url()).toString());
    }
    manager.setPrimaryClip(clipData);
    view.showTextCopied();

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DetailPresenter.java

示例7: copyText

import android.content.ClipData; //导入依赖的package包/类
@Override
public void copyText() {
    if (checkNull()) {
        view.showCopyTextError();
        return;
    }

    ClipboardManager manager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    ClipData clipData = null;
    switch (type) {
        case TYPE_ZHIHU:
            clipData = ClipData.newPlainText("text", Html.fromHtml(title + "\n" + zhihuDailyStory.getBody()).toString());
            break;
        case TYPE_GUOKR:
            clipData = ClipData.newPlainText("text", Html.fromHtml(guokrStory).toString());
            break;
        case TYPE_DOUBAN:
            clipData = ClipData.newPlainText("text", Html.fromHtml(title + "\n" + doubanMomentStory.getContent()).toString());
    }
    manager.setPrimaryClip(clipData);
    view.showTextCopied();

}
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:24,代码来源:DetailPresenter.java

示例8: onCreate

import android.content.ClipData; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView = (ListView) findViewById(R.id.list_view);

    adapter = new PortListAdapter(MainActivity.this, ports);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            String item = ports.get(i);

            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("copy port", item);
            clipboard.setPrimaryClip(clip);

            Toast.makeText(MainActivity.this, "port '" + item + "' copied", Toast.LENGTH_LONG).show();
        }
    });
}
 
开发者ID:Faresalghazy,项目名称:PortFinder,代码行数:24,代码来源:MainActivity.java

示例9: getIntent

import android.content.ClipData; //导入依赖的package包/类
/**
 * 获取剪贴板的意图
 *
 * @return 剪贴板的意图
 */
public static Intent getIntent() {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).getIntent();
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ClipboardUtils.java

示例10: onBindViewHolder

import android.content.ClipData; //导入依赖的package包/类
@Override
public void onBindViewHolder(GifViewHolder holder, int position) {
  final Api.GifResult result = results[position];
  holder.gifView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      ClipboardManager clipboard =
          (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
      ClipData clip =
          ClipData.newPlainText("giphy_url", result.images.fixed_height.url);
      Preconditions.checkNotNull(clipboard).setPrimaryClip(clip);

      Intent fullscreenIntent = FullscreenActivity.getIntent(activity, result);
      activity.startActivity(fullscreenIntent);
    }
  });

  // clearOnDetach let's us stop animating GifDrawables that RecyclerView hasn't yet recycled
  // but that are currently off screen.
  requestBuilder.load(result).into(holder.gifView).clearOnDetach();

  preloadSizeProvider.setView(holder.gifView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:MainActivity.java

示例11: onFinished

import android.content.ClipData; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void onFinished(Uri... uris) {
    Log.d(TAG, "onFinished() " + Arrays.toString(uris));

    final Intent intent = new Intent();
    if (uris.length == 1) {
        intent.setData(uris[0]);
    } else if (uris.length > 1) {
        final ClipData clipData = new ClipData(
                null, mState.acceptMimes, new ClipData.Item(uris[0]));
        for (int i = 1; i < uris.length; i++) {
            clipData.addItem(new ClipData.Item(uris[i]));
        }
        if(Utils.hasJellyBean()){
            intent.setClipData(clipData);	
        }
        else{
        	intent.setData(uris[0]);
        }
    }

    if (mState.action == DocumentsActivity.State.ACTION_GET_CONTENT) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else if (mState.action == ACTION_OPEN_TREE) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
                | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
                | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
    } else {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
                | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
    }

    setResult(Activity.RESULT_OK, intent);
    finish();
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:38,代码来源:DocumentsActivity.java

示例12: onTouch

import android.content.ClipData; //导入依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
	if (mSearch.getCompoundDrawables()[2] != null) {
		boolean tappedX = event.getX() > (mSearch.getWidth()
				- mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
		if (tappedX) {
			if (event.getAction() == MotionEvent.ACTION_UP) {
				if (mSearch.hasFocus()) {
					ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
					ClipData clip = ClipData.newPlainText("label", mSearch.getText()
							.toString());
					clipboard.setPrimaryClip(clip);
					Utils.showToast(
							mActivity,
							mActivity.getResources().getString(
									R.string.message_text_copied));
				} else {
					refreshOrStop();
				}
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:27,代码来源:BrowserActivity.java

示例13: onLinkMenuClicked

import android.content.ClipData; //导入依赖的package包/类
private void onLinkMenuClicked(Dialog d, int position) {
	switch (position) {
		case 0:
			newTab(currentClickUrl, true);
			break;
		case 1:
			if(getCurrentWebView()!=null) {
				getCurrentWebView().loadUrl(currentClickUrl);
			}
			break;
		case 2:
			ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
			ClipData clip = ClipData.newPlainText("label", currentClickUrl);
			clipboard.setPrimaryClip(clip);
			Utils.showToast(mActivity,
					mActivity.getResources().getString(R.string.message_link_copied));
			break;
	}
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:20,代码来源:BrowserActivity.java

示例14: setEditText

import android.content.ClipData; //导入依赖的package包/类
public void setEditText(@NonNull Context context, @NonNull String text) throws MyException {
    if (null == context) {
        throw new NullPointerException("context");
    }
    if (null == text) {
        throw new NullPointerException("text");
    }
    try {
        //清空内容
        Bundle arguments = new Bundle();
        arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo
                .MOVEMENT_GRANULARITY_LINE);
        arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, true);
        mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
                arguments);
        //粘贴内容
        ClipData clipData = ClipData.newPlainText(context.getPackageName(), text);
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setPrimaryClip(clipData);
        mAccessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
    } catch (Exception e) {
        throw new MyException(e);
    }
}
 
开发者ID:littleRich,项目名称:AutoInteraction-Library,代码行数:25,代码来源:UiNode.java

示例15: handleGallery

import android.content.ClipData; //导入依赖的package包/类
private ArrayList<Uri> handleGallery(Intent data) {
    ArrayList<Uri> uris = new ArrayList<>();
    if (data.getData() != null) { // Single select
        uris.add(data.getData());
    } else { // Multi select
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            ClipData clipData = data.getClipData();
            for (int i = 0; i < clipData.getItemCount(); i++) {
                uris.add(clipData.getItemAt(i).getUri());
            }
        }
    }
    return uris;
}
 
开发者ID:marchinram,项目名称:RxGallery,代码行数:15,代码来源:RxGalleryActivity.java


注:本文中的android.content.ClipData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。