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


Java ClipData.getItemCount方法代码示例

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


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

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

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

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

示例4: 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:erguotou520,项目名称:weex-uikit,代码行数:24,代码来源:WXClipboardModule.java

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

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

示例7: getLatestText

import android.content.ClipData; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getLatestText(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return String.valueOf(clip.getItemAt(0).coerceToText(context));
    }
    return null;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:10,代码来源:ClipboardUtil.java

示例8: getUri

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

示例9: getText

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 获取剪贴板的文本
 *
 * @return 剪贴板的文本
 */
public static CharSequence getText() {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).coerceToText(Utils.getContext());
    }
    return null;
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:14,代码来源:ClipboardUtils.java

示例10: getText

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 获取剪贴板文本,当获取到是空时,返回默认字符串
 *
 * @param textIfNull 剪贴板文本如果为空,返回这个字符串
 * @return 剪贴板文本
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getText(String textIfNull)
{
    ClipboardManager clipboardManager = getClipboardManager();
    ClipData clipData = clipboardManager.getPrimaryClip();
    if(clipData != null && clipData.getItemCount() > 0)
    {
        return clipData.getItemAt(0).coerceToText(Easy.getContext()).toString();
    }

    return textIfNull;
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:19,代码来源:ClipboardTool.java

示例11: getUri

import android.content.ClipData; //导入方法依赖的package包/类
/**
 * 获取剪贴板的uri
 *
 * @return 剪贴板的uri
 */
public static Uri getUri(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).getUri();
    }
    return null;
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:14,代码来源:ClipboardUtils.java

示例12: 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:angcyo,项目名称:RLibrary,代码行数:14,代码来源:ClipboardUtils.java

示例13: onPrimaryClipChanged

import android.content.ClipData; //导入方法依赖的package包/类
@Override
public void onPrimaryClipChanged() {
    ClipData clipData = mClipboardManager.getPrimaryClip();
    int count = clipData.getItemCount();
    if (count > 0) {
        String content = clipData.getItemAt(count - 1).getText().toString();
        if (ItemUtils.addItem(getApplicationContext(), new BaseItem("", content))) {
            mBuilder.setContentText(content);
            mNotification = mBuilder.build();
            mNotificationManager.notify(NOTIFICATION_ID, mNotification);
            PindroidApplication.getINSTANCE().refreshItem();
        }
    }
}
 
开发者ID:gaelthas,项目名称:Pindroid,代码行数:15,代码来源:ClipboardService.java

示例14: getClipboard

import android.content.ClipData; //导入方法依赖的package包/类
public String[] getClipboard() {
    String[] ret;
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
        ret = new String[]{((android.text.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE)).getText().toString()};
    } else {
        ClipData data = ((android.content.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE)).getPrimaryClip();
        ret = new String[data.getItemCount()];
        for (int i = 0; i < data.getItemCount() && i < ret.length; i++) {
            ret[i] = data.getItemAt(i).getText().toString();
        }
    }
    return ret;
}
 
开发者ID:gsantner,项目名称:memetastic,代码行数:14,代码来源:ContextUtils.java

示例15: getItemCount

import android.content.ClipData; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static int getItemCount(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData data = clipboard.getPrimaryClip();
    return data.getItemCount();
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:7,代码来源:ClipboardUtil.java


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