cn.sharesdk.framework.Platform Java Examples

The following examples show how to use cn.sharesdk.framework.Platform. 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: EditPage.java    From YiZhi with Apache License 2.0 6 votes vote down vote up
private String getJoinSelectedUser(HashMap<String, Object> data) {
	if (data != null && data.containsKey("selected")) {
		@SuppressWarnings("unchecked")
		ArrayList<String> selected = (ArrayList<String>) data.get("selected");
		String platform = ((Platform)data.get("platform")).getName();
		if("FacebookMessenger".equals(platform)) {
			return null;
		}
		StringBuilder sb = new StringBuilder();
		for (String sel : selected) {
			sb.append('@').append(sel).append(' ');
		}
		return sb.toString();
	}
	return null;
}
 
Example #2
Source File: FollowListPage.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
	FollowersResult followersResult = parseFollowers(platform.getName(), res, map);

	if(followersResult == null) {
		UIHandler.sendEmptyMessage(FOLLOW_LIST_EMPTY, this);
		return;
	}
	hasNext = followersResult.hasNextPage;
	if (followersResult.list != null && followersResult.list.size() > 0) {
		curPage++;
		Message msg = new Message();
		msg.what = 1;
		msg.obj = followersResult.list;
		UIHandler.sendMessage(msg, this);
	}
}
 
Example #3
Source File: PlatformPage.java    From LQRWeChat with MIT License 6 votes vote down vote up
public final void showEditPage(final Platform platform) {
	beforeFinish = new Runnable() {
		public void run() {
			boolean isSilent = isSilent();
			boolean isCustomPlatform = platform instanceof CustomPlatform;
			boolean isUseClientToShare = isUseClientToShare(platform);
			if (isSilent || isCustomPlatform || isUseClientToShare) {
				shareSilently(platform);
			} else {
				ShareParams sp = formateShareData(platform);
				if (sp != null) {
					// 编辑分享内容的统计
					ShareSDK.logDemoEvent(3, null);
					if (getCustomizeCallback() != null) {
						getCustomizeCallback().onShare(platform, sp);
					}
					impl.showEditPage(activity, platform, sp);
				}
			}
		}
	};
	finish();
}
 
Example #4
Source File: LoginActivity.java    From Viewer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLogin(String platform, HashMap<String, Object> res) {
       if(platform == null){
        return false;
       }
       
       showProgressDialog(R.string.wait_for_login);
       Platform myPlatform = ShareSDK.getPlatform(platform);
       String uid = myPlatform.getDb().getUserId();
       String thirdSymbol = myPlatform.getName();
       String nickName =  myPlatform.getDb().getUserName();
       // 0 无性别,1男 , 2女
       int sex = 0;
       if("m".equals(myPlatform.getDb().getUserGender())){
        sex = 1;
       }else{
        sex = 2;
       }
       
       mUserLoginHandler.setOtherLoginData(uid,thirdSymbol,nickName,sex);
       mUserLoginHandler.doThing(UserLoginHandler.THIRD_LOGIN);
	return true;
}
 
Example #5
Source File: PlatformGridView.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
private String getName(Platform plat) {
	if (plat == null) {
		return "";
	}

	String name = plat.getName();
	if (name == null) {
		return "";
	}

	int resId = com.mob.tools.utils.R.getStringRes(getContext(), plat.getName().toLowerCase());
	if (resId > 0) {
		return getContext().getString(resId);
	}
	return null;
}
 
Example #6
Source File: OnekeyShareThemeImpl.java    From LQRWeChat with MIT License 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #7
Source File: PlatformPage.java    From GithubApp with Apache License 2.0 6 votes vote down vote up
protected ArrayList<Object> collectCells() {
	ArrayList<Object> cells = new ArrayList<Object>();

	Platform[] platforms = ShareSDK.getPlatformList();
	if (platforms == null) {
		platforms = new Platform[0];
	}
	HashMap<String, String> hides = getHiddenPlatforms();
	if (hides == null) {
		hides = new HashMap<String, String>();
	}
	for (Platform p : platforms) {
		if (!hides.containsKey(p.getName())) {
			cells.add(p);
		}
	}

	ArrayList<CustomerLogo> customers = getCustomerLogos();
	if (customers != null && customers.size() > 0) {
		cells.addAll(customers);
	}

	return cells;
}
 
Example #8
Source File: OnekeyShareThemeImpl.java    From HHComicViewer with Apache License 2.0 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #9
Source File: OnekeyShareThemeImpl.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
final void shareSilently(Platform platform) {
	if (formateShareData(platform)) {
		ShareParams sp = shareDataToShareParams(platform);
		if (sp != null) {
			toast("ssdk_oks_sharing");
			if (customizeCallback != null) {
				customizeCallback.onShare(platform, sp);
			}
			if (disableSSO) {
				platform.SSOSetting(disableSSO);
			}
			platform.setPlatformActionListener(callback);
			platform.share(sp);
		}
	}
}
 
Example #10
Source File: PlatformPage.java    From LiuAGeAndroid with MIT License 6 votes vote down vote up
public final void showEditPage(final Platform platform) {
	beforeFinish = new Runnable() {
		public void run() {
			boolean isSilent = isSilent();
			boolean isCustomPlatform = platform instanceof CustomPlatform;
			boolean isUseClientToShare = isUseClientToShare(platform);
			if (isSilent || isCustomPlatform || isUseClientToShare) {
				shareSilently(platform);
			} else {
				ShareParams sp = formateShareData(platform);
				if (sp != null) {
					// 编辑分享内容的统计
					ShareSDK.logDemoEvent(3, null);
					if (getCustomizeCallback() != null) {
						getCustomizeCallback().onShare(platform, sp);
					}
					impl.showEditPage(activity, platform, sp);
				}
			}
		}
	};
	finish();
}
 
Example #11
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private Bitmap getPlatLogo(Platform plat) {
	if (plat == null) {
		return null;
	}

	String name = plat.getName();
	if (name == null) {
		return null;
	}

	String resName = "logo_" + plat.getName();
	int resId = getBitmapRes(activity, resName.toLowerCase());
	if(resId > 0) {
		return BitmapFactory.decodeResource(activity.getResources(), resId);
	}
	return null;
}
 
Example #12
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public void onClick(View v) {
	if(v.getTag() == null)
		return;
	String tag = (String) v.getTag();
	if (tag.equals("close")) {
		// 取消分享的统计
		for(Platform plat : platforms) {
			ShareSDK.logDemoEvent(5, plat);
		}
		finish();
		return;
	}

	if (tag.equals("ok")) {
		onShareButtonClick(v);
		return;
	}
}
 
Example #13
Source File: OnekeyShareThemeImpl.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
final void shareSilently(Platform platform) {
	if (formateShareData(platform)) {
		ShareParams sp = shareDataToShareParams(platform);
		if (sp != null) {
			toast("ssdk_oks_sharing");
			if (customizeCallback != null) {
				customizeCallback.onShare(platform, sp);
			}
			if (disableSSO) {
				platform.SSOSetting(disableSSO);
			}
			platform.setPlatformActionListener(callback);
			platform.share(sp);
		}
	}
}
 
Example #14
Source File: EditPage.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
private String getJoinSelectedUser(HashMap<String, Object> data) {
	if (data != null && data.containsKey("selected")) {
		@SuppressWarnings("unchecked")
		ArrayList<String> selected = (ArrayList<String>) data.get("selected");
		String platform = ((Platform)data.get("platform")).getName();
		if("FacebookMessenger".equals(platform)) {
			return null;
		}
		StringBuilder sb = new StringBuilder();
		for (String sel : selected) {
			sb.append('@').append(sel).append(' ');
		}
		return sb.toString();
	}
	return null;
}
 
Example #15
Source File: OnekeyShareThemeImpl.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
public final void show(Context context) {
	this.context = context;

	// 显示方式是由platform和silent两个字段控制的
	// 如果platform设置了,则无须显示九宫格,否则都会显示;
	// 如果silent为true,表示不进入编辑页面,否则会进入。
	if (shareParamsMap.containsKey("platform")) {
		String name = String.valueOf(shareParamsMap.get("platform"));
		Platform platform = ShareSDK.getPlatform(name);
		boolean isCustomPlatform = platform instanceof CustomPlatform;
		boolean isUseClientToShare = isUseClientToShare(platform);
		if (silent || isCustomPlatform || isUseClientToShare) {
			shareSilently(platform);
		} else {
			prepareForEditPage(platform);
		}
	} else {
		showPlatformPage(context);
	}
}
 
Example #16
Source File: OnekeyShare.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
public void onCancel(Platform platform, int action) {
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #17
Source File: NetEaseMicroBlog.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform("NetEaseMicroBlog");
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #18
Source File: LoginActivity.java    From xmpp with Apache License 2.0 5 votes vote down vote up
/**
 * 新浪微博登录
 */
private void weibo_login() {
    Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
    if (weibo.isValid()) {
        weibo.removeAccount();
    }

    weibo.setPlatformActionListener(this); // 设置分享事件回调
    weibo.SSOSetting(true); // 设置false表示使用SSO授权方式
    // weibo.authorize();
    weibo.showUser(null);

}
 
Example #19
Source File: KaiXinShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(){
	Platform platform = ShareSDK.getPlatform(KaiXin.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setShareType(Platform.SHARE_IMAGE);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #20
Source File: EmailShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Email.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #21
Source File: OnekeyShareThemeImpl.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
public final void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}
 
Example #22
Source File: FriendAdapter.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
public void onCancel(Platform plat, int action) {
	UIHandler.sendEmptyMessage(0, new Callback() {
		public boolean handleMessage(Message msg) {
			activity.finish();
			return false;
		}
	});
}
 
Example #23
Source File: WechatFavoriteShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatFavorite.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setShareType(Platform.SHARE_TEXT);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #24
Source File: FacebookShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Facebook.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #25
Source File: TumblrShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(Tumblr.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #26
Source File: OnekeyShareThemeImpl.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
public final void onComplete(Platform platform, int action,
		HashMap<String, Object> res) {
	Message msg = new Message();
	msg.arg1 = 1;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #27
Source File: OnekeyShareThemeImpl.java    From LQRWeChat with MIT License 5 votes vote down vote up
public final void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}
 
Example #28
Source File: ShareCore.java    From BigApp_WordPress_Android 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);
	}

	plat.share(sp);
	return true;
}
 
Example #29
Source File: FriendAdapter.java    From GithubApp with Apache License 2.0 5 votes vote down vote up
public void onCancel(Platform plat, int action) {
	UIHandler.sendEmptyMessage(0, new Callback() {
		public boolean handleMessage(Message msg) {
			activity.finish();
			return false;
		}
	});
}
 
Example #30
Source File: OnekeyShare.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
public void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}