當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。