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


Java ClipDescription類代碼示例

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


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

示例1: onLongClick

import android.content.ClipDescription; //導入依賴的package包/類
@Override
public boolean onLongClick(View v) {
    ClipData.Item item = new ClipData.Item("" + v.getTag());
    ClipData dragData = new ClipData("" + v.getTag(), new String[] {ClipDescription.MIMETYPE_TEXT_PLAIN},item);

    View.DragShadowBuilder myShadow = new MyDragShadowBuilder(v);

    showDragBuide();
    v.startDrag(dragData,  // the data to be dragged
            myShadow,  // the drag shadow builder
            null,      // no need to use local data
            0          // flags (not currently used, set to 0)
    );
    v.setAlpha(0.2f);
    return true;
}
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:17,代碼來源:StickerApplyAdapter.java

示例2: openTypedAssetFileImpl

import android.content.ClipDescription; //導入依賴的package包/類
private final AssetFileDescriptor openTypedAssetFileImpl(
        Uri uri, String mimeTypeFilter, Bundle opts, CancellationSignal signal)
        throws FileNotFoundException {
    enforceTree(uri);
    final String documentId = getDocumentId(uri);
    if (opts != null && opts.containsKey(ContentResolver.EXTRA_SIZE)) {
        final Point sizeHint = opts.getParcelable(ContentResolver.EXTRA_SIZE);
        return openDocumentThumbnail(documentId, sizeHint, signal);
    }
    if ("*/*".equals(mimeTypeFilter)) {
         // If they can take anything, the untyped open call is good enough.
         return openAssetFile(uri, "r");
    }
    final String baseType = getType(uri);
    if (baseType != null && ClipDescription.compareMimeTypes(baseType, mimeTypeFilter)) {
        // Use old untyped open call if this provider has a type for this
        // URI and it matches the request.
        return openAssetFile(uri, "r");
    }
    // For any other yet unhandled case, let the provider subclass handle it.
    return openTypedDocument(documentId, mimeTypeFilter, opts, signal);
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:23,代碼來源:DocumentsProvider.java

示例3: startDrag

import android.content.ClipDescription; //導入依賴的package包/類
/**
 * 開始拖拽
 *
 * @param v 當前對象
 */
private void startDrag(View v) {
    // 選項內容
    String optionContent = ((Button) v).getText().toString();
    // 記錄當前答案選項的位置
    optionPosition = getOptionPosition(optionContent);
    // 開始拖拽後在列表中隱藏答案選項
    v.setVisibility(INVISIBLE);

    ClipData.Item item = new ClipData.Item(optionContent);
    ClipData data = new ClipData(null, new String[]{ClipDescription.MIMETYPE_TEXT_PLAIN}, item);
    v.startDrag(data, new DragShadowBuilder(v), null, 0);
}
 
開發者ID:alidili,項目名稱:Demos,代碼行數:18,代碼來源:DragFillBlankView.java

示例4: isCommitContentSupported

import android.content.ClipDescription; //導入依賴的package包/類
private boolean isCommitContentSupported(@Nullable EditorInfo editorInfo, @NonNull String mimeType) {
    if (editorInfo == null) {
        return false;
    }

    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) {
        return false;
    }

    if (!validatePackageName(editorInfo)) {
        return false;
    }

    final String[] supportedMimeTypes = EditorInfoCompat.getContentMimeTypes(editorInfo);
    for (String supportedMimeType : supportedMimeTypes) {
        if (ClipDescription.compareMimeTypes(mimeType, supportedMimeType)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:ROKOLabs,項目名稱:ROKOmoji.Emoji.Keyboard.App-Android,代碼行數:23,代碼來源:KeyboardService.java

示例5: onPublicKeyTextClicked

import android.content.ClipDescription; //導入依賴的package包/類
public View.OnClickListener onPublicKeyTextClicked() {
    return new View.OnClickListener() {
        private static final String CLIP_DATA_LABEL_TEXT_DATA = "text_data";

        @Override
        public void onClick(View view) {
            final Context context = assetReceiveView.getContext();

            ClipData.Item item = new ClipData.Item(assetReceiveView.getPublicKey());

            String[] mimeType = new String[1];
            mimeType[0] = ClipDescription.MIMETYPE_TEXT_URILIST;

            ClipData cd = new ClipData(new ClipDescription(CLIP_DATA_LABEL_TEXT_DATA, mimeType), item);

            ClipboardManager cm = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
            cm.setPrimaryClip(cd);

            Toast.makeText(context, R.string.message_copy_to_clipboard, Toast.LENGTH_SHORT).show();
        }
    };
}
 
開發者ID:soramitsu,項目名稱:iroha-demo-android,代碼行數:23,代碼來源:AssetReceivePresenter.java

示例6: testIgnoreDragThatIsntBlocks

import android.content.ClipDescription; //導入依賴的package包/類
/** Drag events are not always block related.  Ignore other blocks. */
@Test
public void testIgnoreDragThatIsntBlocks() throws BlockLoadingException {
    // Setup
    mTouchedBlock = mDraggedBlock = mBlockFactory.obtainBlockFrom(
            new BlockTemplate().ofType("simple_input_output"));
    mTargetBlock = mBlockFactory.obtainBlockFrom(new BlockTemplate().ofType("output_no_input"));

    Mockito.when(mMockBlockClipDataHelper.isBlockData(any(ClipDescription.class)))
            .thenReturn(false);

    setupDrag();
    dragBlockToTarget();

    Mockito.verify(mMockConnectionManager, never())
            .findBestConnection(Matchers.same(mTouchedBlock), anyInt());
    Mockito.verify(mMockController, never())
            .connect(any(Connection.class), any(Connection.class));
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:20,代碼來源:DraggerTest.java

示例7: testDragConnect

import android.content.ClipDescription; //導入依賴的package包/類
/** Drag together two compatible blocks. */
@Test
public void testDragConnect() throws BlockLoadingException {
    // Setup
    mTouchedBlock = mDraggedBlock = mBlockFactory.obtainBlockFrom(
            new BlockTemplate().ofType("simple_input_output"));
    mTargetBlock = mBlockFactory.obtainBlockFrom(new BlockTemplate().ofType("output_no_input"));

    Mockito.when(mMockBlockClipDataHelper.isBlockData(any(ClipDescription.class)))
            .thenReturn(true);
    Mockito.when(
            mMockConnectionManager.findBestConnection(Matchers.same(mTouchedBlock), anyInt()))
            .thenReturn(Pair.create(mTouchedBlock.getOnlyValueInput().getConnection(),
                    mTargetBlock.getOutputConnection()));

    setupDrag();
    dragBlockToTarget();

    Mockito.verify(mMockConnectionManager, atLeastOnce())
            .findBestConnection(Matchers.same(mTouchedBlock), anyInt());
    Mockito.verify(mMockController).connect(
            mTouchedBlock.getOnlyValueInput().getConnection(),
            mTargetBlock.getOutputConnection());
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:25,代碼來源:DraggerTest.java

示例8: testDragNoConnect

import android.content.ClipDescription; //導入依賴的package包/類
/** Drag together two incompatible blocks. */
@Test
public void testDragNoConnect() throws BlockLoadingException {
    // Setup
    mTouchedBlock = mDraggedBlock = mBlockFactory.obtainBlockFrom(
            new BlockTemplate().ofType("simple_input_output"));
    mTargetBlock = mBlockFactory.obtainBlockFrom(new BlockTemplate().ofType("output_no_input"));

    Mockito.when(mMockBlockClipDataHelper.isBlockData(any(ClipDescription.class)))
            .thenReturn(true);
    Mockito.when(mMockConnectionManager.findBestConnection(any(Block.class), anyInt()))
            .thenReturn(null);

    setupDrag();
    dragBlockToTarget();

    Mockito.verify(mMockConnectionManager, atLeastOnce())
            .findBestConnection(Matchers.same(mTouchedBlock), anyInt());
    Mockito.verify(mMockController, never())
            .connect(any(Connection.class), any(Connection.class));
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:22,代碼來源:DraggerTest.java

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

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

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

示例12: handlePasteClip

import android.content.ClipDescription; //導入依賴的package包/類
/**
 * Handles pasting a {@link ClipData} to this {@link RecipientEditTextView}.
 */
private void handlePasteClip(ClipData clip) {
    removeTextChangedListener(mTextWatcher);

    if (clip != null && clip.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        for (int i = 0; i < clip.getItemCount(); i++) {
            CharSequence paste = clip.getItemAt(i).getText();
            if (paste != null) {
                int start = getSelectionStart();
                int end = getSelectionEnd();
                Editable editable = getText();
                if (start >= 0 && end >= 0 && start != end) {
                    editable.append(paste, start, end);
                } else {
                    editable.insert(end, paste);
                }
                handlePasteAndReplace();
            }
        }
    }

    mHandler.post(mAddTextWatcher);
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:26,代碼來源:RecipientEditTextView.java

示例13: onDragEvent

import android.content.ClipDescription; //導入依賴的package包/類
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:19,代碼來源:RecipientEditTextView.java

示例14: handlePasteClip

import android.content.ClipDescription; //導入依賴的package包/類
/**
 * Handles pasting a {@link ClipData} to this {@link TextChipsEditView}.
 */
private void handlePasteClip(ClipData clip) {
    removeTextChangedListener(mTextWatcher);

    if (clip != null && clip.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        for (int i = 0; i < clip.getItemCount(); i++) {
            CharSequence paste = clip.getItemAt(i).getText();
            if (paste != null) {
                int start = getSelectionStart();
                int end = getSelectionEnd();
                Editable editable = getText();
                if (start >= 0 && end >= 0 && start != end) {
                    editable.append(paste, start, end);
                } else {
                    editable.insert(end, paste);
                }
                handlePasteAndReplace();
            }
        }
    }

    mHandler.post(mAddTextWatcher);
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:26,代碼來源:TextChipsEditView.java

示例15: onTextPaste

import android.content.ClipDescription; //導入依賴的package包/類
public void onTextPaste(int[] textInfo) {
    int startSelPos = textInfo[0];
    int prevDevLineCount = textInfo[1];
    ClipboardManager clipboard = (ClipboardManager) ctx.get().getSystemService(Context.CLIPBOARD_SERVICE);

    String pasteData = "";

    // Controllo che la clipboard contenga qualcosa e che sia testo incollabile
    if (clipboard.hasPrimaryClip() &&
            clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
        pasteData = item.getText().toString();
        if (pasteData != null) {
            int linesAdded = countOccurrences('\n', pasteData, 0, '\0');


            recView.get().insertNewline(linesAdded, startSelPos, prevDevLineCount);
        }
    }
}
 
開發者ID:diegobit,項目名稱:SoundNotes,代碼行數:21,代碼來源:RichEditText.java


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