本文整理匯總了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();
}