当前位置: 首页>>代码示例>>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;未经允许,请勿转载。