@Test public void testGetString() throws Exception { JSCallback mock = Mockito.mock(JSCallback.class); module.getString(mock); Mockito.verify(mock,Mockito.times(1)).invoke(Mockito.anyObject()); testSetString(); mock = Mockito.mock(JSCallback.class); module.getString(mock); Mockito.verify(mock,Mockito.times(1)).invoke(Mockito.anyObject()); }
@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); } }
WXClipboardModule extends WXModule implements IWXClipboard { @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); } } }
WXClipboardModule extends WXModule implements IWXClipboard { @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); } }  }
WXClipboardModule extends WXModule implements IWXClipboard { @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); } }  @Override @JSMethod void setString(String text); @Override @JSMethod void getString(@Nullable JSCallback callback); }
WXClipboardModule extends WXModule implements IWXClipboard { @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); } }  @Override @JSMethod void setString(String text); @Override @JSMethod void getString(@Nullable JSCallback callback);  }