本文整理汇总了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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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();
}