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


Java ClipData.getItemAt方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: getText

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 获取剪切板的内容
 *
 * @param context
 * @return
 */
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:l465659833,项目名称:Bigbang,代码行数:28,代码来源:ClipboardUtils.java

示例7: getString

import android.content.ClipData; //导入方法依赖的package包/类
@Override
@WXModuleAnno
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:amap-demo,项目名称:weex-3d-map,代码行数:24,代码来源:WXClipboardModule.java

示例8: 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

示例9: loadFromClipboard

import android.content.ClipData; //导入方法依赖的package包/类
public String loadFromClipboard(Context context) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
    if (clipboardManager.hasPrimaryClip() == false) {
        return null;
    }

    ClipData clipData = clipboardManager.getPrimaryClip();
    ClipData.Item item = null;
    if (clipData.getItemCount() >= 1) {
        item = clipData.getItemAt(0);
    }

    if (item == null || item.getText() == null) {
        return null;
    }

    String clipText = (String) item.getText().toString();
    if (TextUtils.isEmpty(clipText)) {
        return null;
    }


    return clipText;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:25,代码来源:AttackManager.java

示例10: onActivityResultAboveL

import android.content.ClipData; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
    try {
        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;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:29,代码来源:UdeskWebChromeClient.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: pasteText

import android.content.ClipData; //导入方法依赖的package包/类
public static void pasteText(InputConnection inputConnection) {
    try {
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData abc = clipboardManager.getPrimaryClip();
        ClipData.Item myItem = abc.getItemAt(0);
        if (myItem != null) {
            String text = myItem.getText().toString();
            inputConnection.commitText(text, 1);
            defaultTextSpeech.speechText(context.getString(R.string.text_pasted));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:15,代码来源:Common.java

示例13: processDrop

import android.content.ClipData; //导入方法依赖的package包/类
boolean processDrop(DragEvent event, ImageView imageView) {
    // Attempt to parse clip data with expected format: category||entry_id.
    // Ignore event if data does not conform to this format.
    ClipData data = event.getClipData();
    if (data != null) {
        if (data.getItemCount() > 0) {
            Item item = data.getItemAt(0);
            String textData = (String) item.getText();
            if (textData != null) {
                StringTokenizer tokenizer = new StringTokenizer(textData, "||");
                if (tokenizer.countTokens() != 2) {
                    return false;
                }
                int category = -1;
                int entryId = -1;
                try {
                    category = Integer.parseInt(tokenizer.nextToken());
                    entryId = Integer.parseInt(tokenizer.nextToken());
                } catch (NumberFormatException exception) {
                    return false;
                }
                updateContentAndRecycleBitmap(category, entryId);
                // Update list fragment with selected entry.
                TitlesFragment titlesFrag = (TitlesFragment)
                        getFragmentManager().findFragmentById(R.id.titles_frag);
                titlesFrag.selectPosition(entryId);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:33,代码来源:ContentFragment.java

示例14: performPaste

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * A helper method that replaces the note's data with the contents of the clipboard.
 */
private final void performPaste() {

    // Gets a handle to the Clipboard Manager
    ClipboardManager clipboard = (ClipboardManager)
            getSystemService(Context.CLIPBOARD_SERVICE);

    // Gets a content resolver instance
    ContentResolver cr = getContentResolver();

    // Gets the clipboard data from the clipboard
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null) {

        String text=null;
        String title=null;

        // Gets the first item from the clipboard data
        ClipData.Item item = clip.getItemAt(0);

        // Tries to get the item's contents as a URI pointing to a note
        Uri uri = item.getUri();

        // Tests to see that the item actually is an URI, and that the URI
        // is a content URI pointing to a provider whose MIME type is the same
        // as the MIME type supported by the Note pad provider.
        if (uri != null && NotePad.Notes.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {

            // The clipboard holds a reference to data with a note MIME type. This copies it.
            Cursor orig = cr.query(
                    uri,            // URI for the content provider
                    PROJECTION,     // Get the columns referred to in the projection
                    null,           // No selection variables
                    null,           // No selection variables, so no criteria are needed
                    null            // Use the default sort order
            );

            // If the Cursor is not null, and it contains at least one record
            // (moveToFirst() returns true), then this gets the note data from it.
            if (orig != null) {
                if (orig.moveToFirst()) {
                    int colNoteIndex = orig.getColumnIndex(NotePad.Notes.COLUMN_NAME_NOTE);
                    int colTitleIndex = orig.getColumnIndex(NotePad.Notes.COLUMN_NAME_TITLE);
                    text = orig.getString(colNoteIndex);
                    title = orig.getString(colTitleIndex);
                }

                // Closes the cursor.
                orig.close();
            }
        }

        // If the contents of the clipboard wasn't a reference to a note, then
        // this converts whatever it is to text.
        if (text == null) {
            text = item.coerceToText(this).toString();
        }

        // Updates the current note with the retrieved title and text.
        updateNote(text, title);
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:65,代码来源:NoteEditor.java


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