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


Java ClipData.Item方法代码示例

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


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

示例1: processData

import android.content.ClipData; //导入方法依赖的package包/类
private Uri[] processData(Intent data) {

        Uri[] datas = null;
        if (data == null) {
            return datas;
        }
        String target = data.getDataString();
        if (!TextUtils.isEmpty(target)) {
            return datas = new Uri[]{Uri.parse(target)};
        }
        ClipData mClipData = data.getClipData();
        if (mClipData != null && mClipData.getItemCount() > 0) {
            datas = new Uri[mClipData.getItemCount()];
            for (int i = 0; i < mClipData.getItemCount(); i++) {

                ClipData.Item mItem = mClipData.getItemAt(i);
                datas[i] = mItem.getUri();

            }
        }
        return datas;


    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:25,代码来源:FileUpLoadChooserImpl.java

示例2: onFinished

import android.content.ClipData; //导入方法依赖的package包/类
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]);
        }
    }
    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:kranthi0987,项目名称:easyfilemanager,代码行数:25,代码来源:StandaloneActivity.java

示例3: onActivityResultAboveL

import android.content.ClipData; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
    if (requestCode != FILECHOOSER_RESULTCODE || mUploadCallbackAboveL == null)
        return;
    Uri[] results = null;
    if (resultCode == Activity.RESULT_OK) {
        if (intent != null) {
            String dataString = intent.getDataString();
            ClipData clipData = intent.getClipData();
            if (clipData != null) {
                results = new Uri[clipData.getItemCount()];
                for (int i = 0; i < clipData.getItemCount(); i++) {
                    ClipData.Item item = clipData.getItemAt(i);
                    results[i] = item.getUri();
                }
            }
            if (dataString != null)
                results = new Uri[]{Uri.parse(dataString)};
        }
    }
    mUploadCallbackAboveL.onReceiveValue(results);
    mUploadCallbackAboveL = null;
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:24,代码来源:WebActivity.java

示例4: onLongClick

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
    ClipData.Item item = new ClipData.Item("" + v.getTag());
    ClipData dragData = new ClipData("" + v.getTag(), new String[] {ClipDescription.MIMETYPE_TEXT_PLAIN},item);

    View.DragShadowBuilder myShadow = new MyDragShadowBuilder(v);

    showDragBuide();
    v.startDrag(dragData,  // the data to be dragged
            myShadow,  // the drag shadow builder
            null,      // no need to use local data
            0          // flags (not currently used, set to 0)
    );
    v.setAlpha(0.2f);
    return true;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:17,代码来源:StickerApplyAdapter.java

示例5: getString

import android.content.ClipData; //导入方法依赖的package包/类
@ReactMethod
public void getString(Promise promise) {
  try {
    ClipboardManager clipboard = getClipboardService();
    ClipData clipData = clipboard.getPrimaryClip();
    if (clipData == null) {
      promise.resolve("");
    } else if (clipData.getItemCount() >= 1) {
      ClipData.Item firstItem = clipboard.getPrimaryClip().getItemAt(0);
      promise.resolve("" + firstItem.getText());
    } else {
      promise.resolve("");
    }
  } catch (Exception e) {
    promise.reject(e);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ClipboardModule.java

示例6: onActivityResultAboveL

import android.content.ClipData; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
   private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent)
{
       if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null)
           return;
       Uri[] results = null;
       if (resultCode == Activity.RESULT_OK)
	{
           if (intent != null)
		{
               String dataString = intent.getDataString();
               ClipData clipData = intent.getClipData();
               if (clipData != null)
			{
                   results = new Uri[clipData.getItemCount()];
                   for (int i = 0; i < clipData.getItemCount(); i++)
				{
                       ClipData.Item item = clipData.getItemAt(i);
                       results[i] = item.getUri();
                   }
               }
               if (dataString != null)
                   results = new Uri[]{Uri.parse(dataString)};
           }
       }
       uploadMessageAboveL.onReceiveValue(results);
       uploadMessageAboveL = null;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:29,代码来源:x5_MainActivity.java

示例7: getText

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 获取剪切板的内容
 */
public static CharSequence getText(Context context) {

  StringBuilder sb = new StringBuilder();
  if (isNew()) {
    instance(context);
    if (!mNewCliboardManager.hasPrimaryClip()) {
      return sb.toString();
    } else {
      ClipData clipData = (mNewCliboardManager).getPrimaryClip();
      int count = clipData.getItemCount();

      for (int i = 0; i < count; ++i) {

        ClipData.Item item = clipData.getItemAt(i);
        CharSequence str = item.coerceToText(context);
        sb.append(str);
      }
    }
  } else {
    instance(context);
    sb.append(mClipboardManager.getText());
  }
  return sb.toString();
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:28,代码来源:ClipboardUtil.java

示例8: processData

import android.content.ClipData; //导入方法依赖的package包/类
private Uri[] processData(Intent data) {

        Uri[] datas = null;
        if (data == null) {
            return datas;
        }
        String target = data.getDataString();
        if (!TextUtils.isEmpty(target)) {
            return datas = new Uri[]{Uri.parse(target)};
        }
        ClipData mClipData = null;
        if (mClipData != null && mClipData.getItemCount() > 0) {
            datas = new Uri[mClipData.getItemCount()];
            for (int i = 0; i < mClipData.getItemCount(); i++) {

                ClipData.Item mItem = mClipData.getItemAt(i);
                datas[i] = mItem.getUri();

            }
        }
        return datas;


    }
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:25,代码来源:FileUpLoadChooserImpl.java

示例9: 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:medalionk,项目名称:simple-share-android,代码行数:38,代码来源:DocumentsActivity.java

示例10: getString

import android.content.ClipData; //导入方法依赖的package包/类
@Override
@JSMethod
public void getString(@Nullable JSCallback callback) {
    Context context = mWXSDKInstance.getContext();
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

    Map<String, Object> map = new HashMap<>(2);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        ClipData.Item item = clip.getItemAt(0);
        CharSequence text = coerceToText(context, item);

        map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
        map.put(DATA, text != null ? text : "");
    } else {
        map.put(RESULT, RESULT_FAILED);
        map.put(DATA, "");
    }

    if (null != callback) {
        callback.invoke(map);
    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:24,代码来源:WXClipboardModule.java

示例11: PastePrimary

import android.content.ClipData; //导入方法依赖的package包/类
public String PastePrimary() {
    _logger.Debug("PastePrimary");

    ClipData clipData = _clipboardManager.getPrimaryClip();
    ClipData.Item item = clipData.getItemAt(0);

    return item.getText().toString();
}
 
开发者ID:GuepardoApps,项目名称:PasswordSafe-AndroidClient,代码行数:9,代码来源:ClipboardController.java

示例12: buildDragClipData

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public ClipData buildDragClipData(PendingDrag drag) throws IOException {
    Block root = drag.getRootDraggedBlock();
    String xml = BlocklyXmlHelper.writeBlockToXml(root, IOOptions.WRITE_ALL_DATA);

    Intent intent = new Intent();
    intent.putExtra(EXTRA_BLOCKLY_XML, xml);

    // TODO(#489): Encode shadow size/offset/zoom info for remote drop targets.
    ClipData.Item item = new ClipData.Item(intent);

    return new ClipData(mClipLabel, new String[] {mMimeType}, item);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:14,代码来源:SingleMimeTypeClipDataHelper.java

示例13: getText

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public CharSequence getText() {
    if(mClipboardManager.getPrimaryClip().getItemCount() > 0){
       ClipData.Item item =mClipboardManager.getPrimaryClip().getItemAt(0);
        return item.getText();
    }
    return"";
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:9,代码来源:ClipboardManagerImpl11.java

示例14: getText

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public CharSequence getText() {
    if (clip.getPrimaryClip().getItemCount() >= 1) {
        ClipData.Item item = clip.getPrimaryClip().getItemAt(0);
        return item.getText();
    }
    return "";
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:9,代码来源:ClipboardManagerCompatV11.java

示例15: createClipData

import android.content.ClipData; //导入方法依赖的package包/类
private ClipData createClipData(AlbumItem[] items) {
    String[] mimeTypes = new String[items.length];
    for (int i = 0; i < items.length; i++) {
        mimeTypes[i] = MediaType.getMimeType(this, items[i].getUri(this));
    }

    ClipData clipData =
            new ClipData("Images", mimeTypes,
                    new ClipData.Item(items[0].getUri(this)));
    for (int i = 1; i < items.length; i++) {
        clipData.addItem(new ClipData.Item(items[i].getUri(this)));
    }
    return clipData;
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:15,代码来源:AlbumActivity.java


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