Java Code Examples for cn.sharesdk.framework.Platform#isAuthValid()

The following examples show how to use cn.sharesdk.framework.Platform#isAuthValid() . 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: UserBean.java    From LiuAGeAndroid with MIT License 6 votes vote down vote up
/**
 * 从本地更新用户信息 - 登录成功后保存到偏好设置
 */
public void updateUserInfoFromLocal() {

    // 移除第三方授权
    Platform wechat = ShareSDK.getPlatform(Wechat.NAME);
    if (wechat.isAuthValid()) {
        wechat.removeAccount(true);
    }
    Platform qq = ShareSDK.getPlatform(QQ.NAME);
    if (qq.isAuthValid()) {
        qq.removeAccount(true);
    }

    // 内存缓存
    UserBean.userAccount = this;
    // 磁盘缓存
    encode();
}
 
Example 2
Source File: UserBean.java    From BaoKanAndroid with MIT License 6 votes vote down vote up
/**
 * 从本地更新用户信息 - 登录成功后保存到偏好设置
 */
public void updateUserInfoFromLocal() {

    // 移除第三方授权
    Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
    if (weibo.isAuthValid()) {
        weibo.removeAccount(true);
    }
    Platform qq = ShareSDK.getPlatform(QQ.NAME);
    if (qq.isAuthValid()) {
        qq.removeAccount(true);
    }

    // 内存缓存
    UserBean.userAccount = this;
    // 磁盘缓存
    encode();
}
 
Example 3
Source File: PlatformAuthorizeUserInfoManager.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
/**
 * 授权的代码
 */
public void doAuthorize(Platform platform) {
	if (platform != null) {
		platform.setPlatformActionListener(myPlatformActionListener);
		if (platform.isAuthValid()) {
			platform.removeAccount(true);
			return;
		}
		//platform.SSOSetting(true);
		platform.authorize();
	}
}
 
Example 4
Source File: PlatformAuthorizeUserInfoManager.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
/**
 * 授权的代码
 */
public void doAuthorize(Platform platform, Activity activity) {
	if (platform != null) {
		platform.setPlatformActionListener(myPlatformActionListener);
		if (platform.isAuthValid()) {
			platform.removeAccount(true);
			return;
		}
		ShareSDK.setActivity(activity);
		//platform.SSOSetting(true);
		platform.authorize();
	}
}
 
Example 5
Source File: SdkTagsMainActivity.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
private void Sina() {
    ShareSDK.setEnableAuthTag(true);
    Platform plat = ShareSDK.getPlatform("SinaWeibo");
    plat.removeAccount(true);
    //plat.SSOSetting(false);
    plat.setPlatformActionListener(this);
    if (plat.isClientValid()) {

    }
    if (plat.isAuthValid()) {

    }
    //plat.authorize();	//要功能,不要数据
    plat.showUser(null);    //要数据不要功能,主要体现在不会重复出现授权界面
}
 
Example 6
Source File: SdkTagsMainActivity.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
private void WeChat() {
    Platform plat = ShareSDK.getPlatform(Wechat.NAME);
    ShareSDK.setEnableAuthTag(true);
    plat.removeAccount(true);
    //plat.SSOSetting(false);
    plat.setPlatformActionListener(this);
    if (plat.isClientValid()) {

    }
    if (plat.isAuthValid()) {

    }
    //plat.authorize();	//要功能,不要数据
    plat.showUser(null);    //要数据不要功能,主要体现在不会重复出现授权界面
}
 
Example 7
Source File: UserInfoAdapter.java    From ShareSDK-for-Android with MIT License 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
	PlatformEntity entity = lists.get(position);
	if (holder instanceof ShareViewHolderTitleNormal) {
		ShareViewHolderTitleNormal holderTitleNormal = (ShareViewHolderTitleNormal) holder;
		holderTitleNormal.textView.setText(entity.getName());
	}
	if (holder instanceof ShareViewAuthorizationNormal) {
		ShareViewAuthorizationNormal shareViewAuthNormal = (ShareViewAuthorizationNormal) holder;
		Platform platform = entity.getmPlatform();
		if (platform == null) {
			shareViewAuthNormal.authorization.setText(context.getString(R.string.userinfo_txt));
			shareViewAuthNormal.authorization.setBackgroundResource(R.drawable.show_sure_author_userinfo_bg);
			shareViewAuthNormal.authorization.setTextColor(Color.parseColor("#FFC794"));
		} else {
			if (platform.isAuthValid()) {
				shareViewAuthNormal.authorization.setText(context.getString(R.string.userinfo_show));
				shareViewAuthNormal.authorization.setBackgroundResource(R.drawable.show_userinfo_bg_);
				shareViewAuthNormal.authorization.setTextColor(Color.WHITE);
			} else {
				shareViewAuthNormal.authorization.setText(context.getString(R.string.userinfo_txt));
				shareViewAuthNormal.authorization.setBackgroundResource(R.drawable.show_sure_author_userinfo_bg);
				shareViewAuthNormal.authorization.setTextColor(Color.parseColor("#FFC794"));
			}
		}
		shareViewAuthNormal.authorization.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				authorizationOnItemClickListener.OnItemClickListener(v, position);
			}
		});
		String name = entity.getName();
		if (!TextUtils.isEmpty(name)) {
			shareViewAuthNormal.textView.setText(entity.getName());
		}
		int icon = entity.getmIcon();
		if (icon > 1) {
			shareViewAuthNormal.platIcon.setImageResource(icon);
		}
	}
}