/** * 向指定平台分享内容 * * <p><b>注意:</b><br> * 参数data的键值需要严格按照{@link ShareParams}不同子类具体字段来命名, 否则无法反射此字段,也无法设置其值。 */ public boolean share(Platform plat, HashMap<String, Object> data) { if (plat == null || data == null) { return false; } try { String imagePath = (String) data.get("imagePath"); Bitmap viewToShare = (Bitmap) data.get("viewToShare"); if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) { String path = R.getCachePath(plat.getContext(), "screenshot"); File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg"); FileOutputStream fos = new FileOutputStream(ss); viewToShare.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); data.put("imagePath", ss.getAbsolutePath()); } } catch (Throwable t) { t.printStackTrace(); return false; } ShareParams sp = new ShareParams(data); if (customizeCallback != null) { customizeCallback.onShare(plat, sp); } plat.share(sp); return true; }
// #endif public boolean share(Platform plat, HashMap<String, Object> data) { if (plat == null || data == null) { return false; } Platform.ShareParams sp = null; try { sp = getShareParams(plat, data); } catch (Throwable t) { sp = null; } if (sp != null) { if (customizeCallback != null) { customizeCallback.onShare(plat, sp); } plat.share(sp); } return true; }