cn.sharesdk.framework.utils.R Java Examples

The following examples show how to use cn.sharesdk.framework.utils.R. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareCore.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
/**
 * 向指定平台分享内容
 * <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);
	}

	String[] flags = new String[] {
			"OnekeyShare",
			plat.getContext().getPackageName(),
			String.valueOf(ShareSDK.getSDKVersionCode())
	};
	sp.setCustomFlag(flags);
	plat.share(sp);
	return true;
}
 
Example #2
Source File: ShareCore.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 向指定平台分享内容
 * <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);
	}

	String[] flags = new String[] {
			"OnekeyShare",
			plat.getContext().getPackageName(),
			String.valueOf(ShareSDK.getSDKVersionCode())
	};
	sp.setCustomFlag(flags);
	plat.share(sp);
	return true;
}
 
Example #3
Source File: ShareCore.java    From ShareSDKShareDifMsgDemo-Android with MIT License 5 votes vote down vote up
/**
 * 向指定平台分享内容
 * <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);
	}

	String[] flags = new String[] {
			"OnekeyShare",
			plat.getContext().getPackageName(),
			String.valueOf(ShareSDK.getSDKVersionCode())
	};
	sp.setCustomFlag(flags);
	plat.share(sp);
	return true;
}
 
Example #4
Source File: ShareCore.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 向指定平台分享内容
 * <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);
	}

	String[] flags = new String[] {
			"OnekeyShare",
			plat.getContext().getPackageName(),
			String.valueOf(ShareSDK.getSDKVersionCode())
	};
	sp.setCustomFlag(flags);
	plat.share(sp);
	return true;
}