當前位置: 首頁>>代碼示例>>Java>>正文


Java ClipDescription.hasMimeType方法代碼示例

本文整理匯總了Java中android.content.ClipDescription.hasMimeType方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipDescription.hasMimeType方法的具體用法?Java ClipDescription.hasMimeType怎麽用?Java ClipDescription.hasMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.ClipDescription的用法示例。


在下文中一共展示了ClipDescription.hasMimeType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getResultsFromIntent

import android.content.ClipDescription; //導入方法依賴的package包/類
static Bundle getResultsFromIntent(Intent intent) {
    ClipData clipData = intent.getClipData();
    if (clipData == null) {
        return null;
    }
    ClipDescription clipDescription = clipData.getDescription();
    if (clipDescription.hasMimeType("text/vnd.android.intent") && clipDescription.getLabel().equals("android.remoteinput.results")) {
        return (Bundle) clipData.getItemAt(0).getIntent().getExtras().getParcelable("android.remoteinput.resultsData");
    }
    return null;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:RemoteInputCompatJellybean.java

示例2: onClickButtonPasteToUrlField

import android.content.ClipDescription; //導入方法依賴的package包/類
public void onClickButtonPasteToUrlField(View v) {
    ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    if (cm.hasPrimaryClip()) {
        ClipDescription desc = cm.getPrimaryClipDescription();
        Log.e("asd", desc.toString());
        if (desc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
            CharSequence pasteText = cm.getPrimaryClip().getItemAt(0).getText();
            editTextUrl.setText(pasteText);
            download();
        } else {
            Log.e("asd", "not text");
            //makeToast("Unable to paste non-text data. Please copy from Instagram again.");
            Snackbar.make(v, "Unable to paste non-text data. Please copy from Instagram again.", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    } else {
        Log.e("asd", "nothing to paste");
        //makeToast("Clipboard is empty. Please copy from Instagram again.");
        Snackbar.make(v, "Clipboard is empty. Please copy from Instagram again.", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show();
    }
}
 
開發者ID:raj-subhankar,項目名稱:DownInsta,代碼行數:23,代碼來源:MainActivity.java

示例3: getText

import android.content.ClipDescription; //導入方法依賴的package包/類
public static CharSequence getText(Context context) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ClipDescription description = cm.getPrimaryClipDescription();
        ClipData clipData = cm.getPrimaryClip();
        if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
            return clipData.getItemAt(0).getText();
        } else {
            return "";
        }
    } else {
        //noinspection deprecation
        return cm.getText();
    }
}
 
開發者ID:AmniX,項目名稱:AdBlockedWebView-Android,代碼行數:17,代碼來源:ClipboardUtils.java

示例4: getText

import android.content.ClipDescription; //導入方法依賴的package包/類
public static CharSequence getText() {
    android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager();
    if (APILevel.require(11)) {
        ClipboardManager cm = (ClipboardManager) clipboardManager;
        ClipDescription description = cm.getPrimaryClipDescription();
        ClipData clipData = cm.getPrimaryClip();
        if (clipData != null
                && description != null
                && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN))
            return clipData.getItemAt(0).getText();
        else
            return null;
    } else {
        return clipboardManager.getText();
    }
}
 
開發者ID:simplesoft-duongdt3,項目名稱:Android-App-Template,代碼行數:17,代碼來源:ClipboardManagerUtil.java

示例5: canPasteAsPlainText

import android.content.ClipDescription; //導入方法依賴的package包/類
@VisibleForTesting
public boolean canPasteAsPlainText() {
    // String resource "paste_as_plain_text" only exist in O.
    // Also this is an O feature, we need to make it consistant with TextView.
    if (!BuildInfo.isAtLeastO()) return false;
    if (!mCanEditRichlyForPastePopup) return false;
    ClipboardManager clipMgr =
            (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
    if (!clipMgr.hasPrimaryClip()) return false;

    ClipData clipData = clipMgr.getPrimaryClip();
    ClipDescription description = clipData.getDescription();
    CharSequence text = clipData.getItemAt(0).getText();
    boolean isPlainType = description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
    // On Android, Spanned could be copied to Clipboard as plain_text MIME type, but in some
    // cases, Spanned could have text format, we need to show "paste as plain text" when
    // that happens.
    if (isPlainType && (text instanceof Spanned)) {
        Spanned spanned = (Spanned) text;
        if (hasStyleSpan(spanned)) return true;
    }
    return description.hasMimeType(ClipDescription.MIMETYPE_TEXT_HTML);
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:24,代碼來源:SelectionPopupController.java

示例6: clipDataToHtmlText

import android.content.ClipDescription; //導入方法依賴的package包/類
public String clipDataToHtmlText(ClipData clipData) {
    ClipDescription description = clipData.getDescription();
    if (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_HTML)) {
        return clipData.getItemAt(0).getHtmlText();
    }

    if (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        CharSequence text = clipData.getItemAt(0).getText();
        if (!(text instanceof Spanned)) return null;
        Spanned spanned = (Spanned) text;
        if (hasStyleSpan(spanned)) {
            return ApiCompatibilityUtils.toHtml(
                    spanned, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
        }
    }
    return null;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:18,代碼來源:Clipboard.java

示例7: processDragStarted

import android.content.ClipDescription; //導入方法依賴的package包/類
boolean processDragStarted(DragEvent event) {
    // Determine whether to continue processing drag and drop based on the
    // plain text mime type.
    ClipDescription clipDesc = event.getClipDescription();
    if (clipDesc != null) {
        return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
    }
    return false;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:10,代碼來源:ContentFragment.java

示例8: handleSystemDragStart

import android.content.ClipDescription; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.N)
private void handleSystemDragStart(DragEvent event) {
    if (!FeatureFlags.LAUNCHER3_USE_SYSTEM_DRAG_DRIVER || !Utilities.isNycOrAbove()) {
        return;
    }
    if (mLauncher.isWorkspaceLocked()) {
        return;
    }

    ClipDescription description = event.getClipDescription();
    if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return;
    }
    ShortcutInfo info = new ShortcutInfo();
    // Set a dummy intent until we get the final value
    info.intent = new Intent();

    // Since we are not going through the workspace for starting the drag, set drag related
    // information on the workspace before starting the drag.
    ExternalDragPreviewProvider previewProvider =
            new ExternalDragPreviewProvider(mLauncher, info);
    mLauncher.getWorkspace().prepareDragWithProvider(previewProvider);

    DragOptions options = new DragOptions();
    options.systemDndStartPoint = new Point((int) event.getX(), (int) event.getY());

    int halfPadding = previewProvider.previewPadding / 2;
    mDragController.startDrag(
            Bitmap.createBitmap(1, 1, Config.ARGB_8888),
            0, 0,
            new AnotherWindowDragSource(mLauncher), info,
            new Point(- halfPadding, halfPadding),
            previewProvider.getPreviewBounds(), 1f, options);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:35,代碼來源:DragLayer.java

示例9: hasText

import android.content.ClipDescription; //導入方法依賴的package包/類
public static boolean hasText(Context context) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ClipDescription description = cm.getPrimaryClipDescription();
        ClipData clipData = cm.getPrimaryClip();
        return clipData != null
                && description != null
                && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));
    } else {
        //noinspection deprecation
        return cm.hasText();
    }
}
 
開發者ID:AmniX,項目名稱:AdBlockedWebView-Android,代碼行數:15,代碼來源:ClipboardUtils.java

示例10: getResultsFromIntent

import android.content.ClipDescription; //導入方法依賴的package包/類
static Bundle getResultsFromIntent(Intent intent) {
    ClipData clipData = intent.getClipData();
    if (clipData == null) {
        return null;
    }
    ClipDescription clipDescription = clipData.getDescription();
    if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return null;
    }
    if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
        return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
    }
    return null;
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:15,代碼來源:RemoteInputCompatJellybean.java

示例11: getClipParameter

import android.content.ClipDescription; //導入方法依賴的package包/類
/**
 * Gets the current clip parameter from the clipboard.
 *
 * @return The text value of the clip parameter, or null if there is no text on the clipboard.
 */
private static String getClipParameter(Context context) {
    final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    if ((clipboard != null) && clipboard.hasPrimaryClip()) {

        // Get the current primary clip on the clipboard
        final ClipData clip = clipboard.getPrimaryClip();
        if ((clip != null) && (clip.getItemCount() > 0)) {

            final ClipDescription description = clip.getDescription();

            // Return null if the clipboard does not contain plain text or html text
            if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) &&
                    !description.hasMimeType(ClipDescription.MIMETYPE_TEXT_HTML)) {
                return null;
            }

            // Ignore and return null if it's a clip previously copied by LoneColor
            final CharSequence label = description.getLabel();
            if ((label != null) && (label.equals(context.getString(R.string.app_name)))) {
                return null;
            }

            // Get the text from the clipboard
            final CharSequence sequence = clip.getItemAt(0).getText();
            if (sequence != null) {
                return sequence.toString();
            }
        }
    }

    return null;
}
 
開發者ID:appgramming,項目名稱:LoneColor-Android,代碼行數:38,代碼來源:ColorClipboardParameter.java

示例12: hasText

import android.content.ClipDescription; //導入方法依賴的package包/類
public static boolean hasText() {
    android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager();
    if (APILevel.require(11)) {
        ClipboardManager cm = (ClipboardManager) clipboardManager;
        ClipDescription description = cm.getPrimaryClipDescription();
        ClipData clipData = cm.getPrimaryClip();
        return clipData != null
                && description != null
                && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));
    } else {
        return clipboardManager.hasText();
    }
}
 
開發者ID:simplesoft-duongdt3,項目名稱:Android-App-Template,代碼行數:14,代碼來源:ClipboardManagerUtil.java

示例13: a

import android.content.ClipDescription; //導入方法依賴的package包/類
public final Bundle a(Intent paramIntent)
{
  ClipData localClipData = paramIntent.getClipData();
  if (localClipData != null)
  {
    ClipDescription localClipDescription = localClipData.getDescription();
    if ((localClipDescription.hasMimeType("text/vnd.android.intent")) && (localClipDescription.getLabel().equals("android.remoteinput.results"))) {
      return (Bundle)localClipData.getItemAt(0).getIntent().getExtras().getParcelable("android.remoteinput.resultsData");
    }
  }
  return null;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:13,代碼來源:ev.java

示例14: write

import android.content.ClipDescription; //導入方法依賴的package包/類
/**
 * Write the clipboard to the keyboard device using the {@link DeviceWriter}.
 */
public void write() {
    ClipData clipData = clipboardManager.getPrimaryClip();
    ClipDescription clipDescription = clipData.getDescription();

    if (clipData.getItemCount() > 0 && clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        ClipData.Item item = clipData.getItemAt(0);
        String data = String.valueOf(item.getText());

        DeviceWriter.write(data);
    }
}
 
開發者ID:miniME89,項目名稱:PassBeam,代碼行數:15,代碼來源:ClipboardListener.java

示例15: makeClipMemo

import android.content.ClipDescription; //導入方法依賴的package包/類
private void makeClipMemo() {
        /*上一個便簽插入是否結束*/
//        boolean insertFinish = true;
//        if (!insertFinish) {
//            //LogUtil.e("上次插入事務尚未結束");
//            return;
//        }
        long nowTime = System.currentTimeMillis();
        if (nowTime - this.mLastUpdateTime < 1000L) {
            //LogUtil.e("與上次間隔時間太短");
            return;
        }
        newDataModel = new DataModel();
        ClipDescription clipDescription;
        ClipData clipData;
        StringBuilder stringBuilder;
        clipDescription = this.mClipboardManager.getPrimaryClipDescription();
        if ((!clipDescription.hasMimeType("text/plain")) && (!clipDescription.hasMimeType("text/html"))) {
            //LogUtil.e("剪切板裏麵的不是文本內容");
            return;
        }
        this.mLastUpdateTime = nowTime;
        clipData = this.mClipboardManager.getPrimaryClip();
        stringBuilder = new StringBuilder();
        int count = clipData.getItemCount();
        for (int i = 0; i < count; i++) {
            ClipData.Item item = clipData.getItemAt(i);
            if (null != item) {
                stringBuilder.append(item.getText());
            }
        }
        newDataModel.setContent(stringBuilder.toString());
    }
 
開發者ID:xiongwei-git,項目名稱:OneNote,代碼行數:34,代碼來源:WatchingService.java


注:本文中的android.content.ClipDescription.hasMimeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。